我一直在通過我的代碼嘗試查找錯誤,但我還沒有成功。你能找到邏輯/語法錯誤
下面顯示的是我輸入和更新文件的片段。
modifyform.php
<li id="li_1" >
<label class="description" for="servername">Server Name </label>
<div>
<input id="element_1" name="Servername" class="element text medium" type="text" maxlength="255" value="<?php echo $person['servername']; ?>"/>
</div><p class="guidelines" id="guide_1"><small>Enter your server name here NOT your server address.</small></p>
</li> <li id="li_2" >
<label class="description" for="Serveraddress">Server Address </label>
<div>
<input id="element_2" name="Serveraddress" class="element text medium" type="text" maxlength="255" value="<?php echo $person['serveraddress']; ?>"/>
</div><p class="guidelines" id="guide_2"><small>This will the DNS name of your server</small></p>
</li> <li id="li_3" >
<label class="description" for="Portnumber">PortNumber </label>
<div>
<input id="element_3" name="Portnumber" class="element text medium" type="text" maxlength="255" value="<?php echo $person['portnumber']; ?>"/>
</div><p class="guidelines" id="guide_3"><small>This will be the port your server is using.</small></p>
<label class="description" for="Status">Server Status </label>
<div>
<input id="element_4" name="Status" class="element text medium" type="text" maxlength="255" value="<?php echo $person['status']; ?>"/>
</div><p class="guidelines" id="guide_4"><small> Display your Server Status</small></p>
</li> <li id="li_4" >
<label class="description" for="Description">Server Description </label>
<div>
<textarea id="element_5" name="Description" class="element textarea medium" value ="<?php echo $person['description']; ?>"></textarea>
</div><p class="guidelines" id="guide_5"><small>Enter server description/rules here.</small></p>
</li>
<li class="buttons">
<input type="hidden" name="id" value="<?php echo $_GET['id']; ?>" />
<input id="saveForm" class="button_text" type="submit" name="submit" value="Modify" />
</li>
</ul>
</form>
<div id="footer">
</div>
</div>
</body>-
</html>
modifyame.php
<?php
mysql_connect("localhost", "user", "password") or die (mysql_error());
#echo "Connected to MYSQL ";
mysql_select_db("starforg_search") or die (mysql_error());
#echo "Connected to Data Base";
/*$query = "SELECT * FROM table WHERE userId='{$user_id}'";
$result = mysql_query ($query) or die (mysql_error());*/
if(!isset($_POST['submit'])) {
$q = "SELECT * FROM addserverame WHERE ID = $_GET[id] AND userId='{$user_id}'";
$result = mysql_query ($q);
$person = mysql_fetch_array ($result);
}
?>
<?
if(isset($_POST['submit'])) {
$u = "UPDATE addserverame SET `servername`='$_POST[Servername]', `serveraddress`='$_POST[Serveraddress]', `portnumber`='$_POST[Portnumber]', `status`='$_POST[Status]', `description`='$_POST[Description]', WHERE ID = $_POST[id] AND userId='{$user_id}'";
mysql_query($u) or die (mysql_error());
echo "Server Info Has Been Modified";
}
?>
問題區域 更新和呼應服務器名,serveraddress和端口號字段是細然而呼應/更新說明和狀態字段不起作用。
我已經看過表格名稱多次,我承認他們是正確的。
這使我相信語法錯誤可能是罪魁禍首。
感謝您的時間
本
回聲$ u和查找錯誤 –
調試自己的代碼!這不是一個問題。 –
另外,逃避你的'$ _POST'變種,你不想要一個討厭的注射。 – Dave