夥計們,我有這些代碼來更新數據庫中的記錄。更新數據庫中的記錄
請檢查這些信息是否正確?
<?php
session_start();
include "db.php";
$username = $_SESSION['username'];
$query="SELECT * FROM members where username='".mysql_real_escape_string($username)."'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$userid =mysql_result($result,$i, 'userid');
$firstname =mysql_result($result,$i,'firstname');
$lastname =mysql_result($result,$i,'lastname');
$username =mysql_result($result,$i,'username');
$email =mysql_result($result,$i,'email');
$age =mysql_result($result,$i,'age');
?>
<form action="update.php" method="post">
<input type="hidden" name="u_userid" value="<? echo "$userid" ?>">
<table>
<tr><td>ID:</td> <td><? echo "$userid"?></td></tr>
<tr><td>First Name:</td> <td> <input type="text" name="u_firstname" value="<? echo "$firstname"?>"></td></tr>
<tr><td>Last Name: </td> <td><input type="text" name="u_lastname" value="<? echo "$lastname"?>"></td></tr>
<tr><td>Username:</td> <td> <input type="text" name="u_username" value="<? echo "$username"?>"></td></tr>
<tr><td>Email:</td> <td> <input type="text" name="u_email" value="<? echo "$email"?>"></td></tr>
<tr><td>Age: </td> <td><input type="text" name="u_age" value="<? echo "$age"?>"></td></tr>
<tr><td></td><td><input type="Submit" value="Update Info">
</td></tr>
</form>
<tr><td></td><td><form action="form2.html" method="post">
<input type="submit" value="Cancel"></form></td></tr>
</table
和update.php
<?php
session_start();
include "db.php";
$userid =mysql_result($result, 'userid');
$firstname =mysql_result($result, 'firstname');
$lastname =mysql_result($result, 'lastname');
$username =mysql_result($result, 'username');
$email =mysql_result($result, 'email');
$age =mysql_result($result, 'age');
include "db.php";
$query="UPDATE members SET firstname='$u_firstname' , lastname='$u_lastname', username='$u_username' , email='$u_email', age='$u_age' ";
$result=mysql_query($query);
mysql_close();
echo "Record Updated
<br><br>
<form action=\"form2.html\" >
<input type=\"submit\" value=\"ok!\" />
</form>
";
?>
實際上它顯示了很多的錯誤/警告這樣
警告:mysql_result():提供的參數不是第7行的C:\ web \ htdocs \ salome \ this \ update.php中的有效MySQL結果資源
警告:mysql_result():提供的參數是不是在C一個有效的MySQL結果資源:\網絡\ htdocs中\撒羅米\上線這個\ update.php 8
警告:mysql_result():提供的參數是不是第C行的C:\ web \ htdocs \ salome \ this \ update.php中有效的MySQL結果資源
警告:mysql_result():提供的參數不是C:\ web \ htdocs中的有效MySQL結果資源\ salome \ this \ update.php on line 10
警告:mysql_result():提供的參數不是C:\ web \ htdocs \ salome \ this \ update.php中有效的MySQL結果資源。 È11
警告:mysql_result():提供的參數是不是在C一個有效的MySQL結果資源:\網絡\ htdocs中\撒羅米\上線這個\ update.php 12
我該怎麼辦..
請幫我... :-(
我推薦一本很好的手冊,一步一步的演練。他們值得的時間。 – TheJacobTaylor 2010-07-20 06:13:16