我正在尝试编辑mysql数据库记录,我的代码似乎存在问题
这是来自页面editVisitor.php
<?
while($row=mysql_fetch_array($result))
{
?>
<?
$message=stripslashes($row["userUserName"]);
$msg_id=$row["useId"];
?>
<li><a href="editUserDetails.php?edit=<?php echo $msg_id; ?>" >
<?php echo $message; ?></a> <a href="#" id="<?php echo $msg_id; ?>" class="delete_button">X</a></li>
<?php
}
?>
这是editUserDetails.php
中的代码,它打开包含更新记录的所有字段的新页面:
<?php
$connection= mysql_pconnect("localhost","root","123") or die (mysql_error());
$db= mysql_select_db("reservebox",$connection) or die (mysql_error());
$selectdata="SELECT * FROM user WHERE useId =" . $edit . "";
mysql_query($selectdata);
$row = mysql_fetch_array($selectdata);
?>
//html form and table code
<input type="text" name="FirstName" id="FirstName" value="<? echo $row['userUserName']; ?>"/>
editVisitorDetails.php没有显示任何数据,我继续收到此错误
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in
答案 0 :(得分:2)
$selectdata="SELECT * FROM user WHERE useId =" . $edit . "";
$query=mysql_query($selectdata);
$row = mysql_fetch_array($query);