php报错Warning: mysql_fetch_array() expects parameter 1 to be resource
<?phperror_reporting(E_ALL^E_NOTICE^E_DEPRECATED);if(!isset($_SESSION)){ob_start();se...
<?php
error_reporting(E_ALL ^ E_NOTICE^ E_DEPRECATED);
if (!isset ($_SESSION)) {
ob_start();
session_start();
}
$hostname="localhost"; //mysql地址
$basename="root"; //mysql用户名
$basepass="root"; //mysql密码
$database="travel"; //mysql数据库名称
$conn=mysql_connect($hostname,$basename,$basepass); //连接mysql
if(!$conn){
die('不能连接数据库'.mysql_error());
}
mysql_select_db($database,$conn); //选择mysql数据库
mysql_query("set names 'utf8'");//mysql编码
$userid=$_GET['userid'];
$sql = "select * from Users where user_id=".$userid;
$result = mysql_query($sql);
$user = mysql_fetch_array($result);
echo "
<tr>
<td> ".$user['user_id']."</td>
<td> ".$user['user_name']."</td>
<td> ".$user['remarks']."</td>
</tr>
";
?>
不知道错在哪里 展开
error_reporting(E_ALL ^ E_NOTICE^ E_DEPRECATED);
if (!isset ($_SESSION)) {
ob_start();
session_start();
}
$hostname="localhost"; //mysql地址
$basename="root"; //mysql用户名
$basepass="root"; //mysql密码
$database="travel"; //mysql数据库名称
$conn=mysql_connect($hostname,$basename,$basepass); //连接mysql
if(!$conn){
die('不能连接数据库'.mysql_error());
}
mysql_select_db($database,$conn); //选择mysql数据库
mysql_query("set names 'utf8'");//mysql编码
$userid=$_GET['userid'];
$sql = "select * from Users where user_id=".$userid;
$result = mysql_query($sql);
$user = mysql_fetch_array($result);
echo "
<tr>
<td> ".$user['user_id']."</td>
<td> ".$user['user_name']."</td>
<td> ".$user['remarks']."</td>
</tr>
";
?>
不知道错在哪里 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询