Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean giv
<?php$conn=mysql_connect("localhost","root","");if(!$conn){die('Couldnotconnect:'.mys...
<?php
$conn = mysql_connect("localhost","root","");
if (!$conn)
{
die('Could not connect: ' . mysql_error());
}
$sql = mysql_query("SELECT * FROM workers ORDER BY workerID DESC");
$query=mysql_query($sql);
while($row=mysql_fetch_array($query)){
echo $row['FirstName'] . " " . $row['LastName'];
echo "<br />";
}
mysql_close($conn);
?>
我想了很久,,还不是不知道那出问题了 展开
$conn = mysql_connect("localhost","root","");
if (!$conn)
{
die('Could not connect: ' . mysql_error());
}
$sql = mysql_query("SELECT * FROM workers ORDER BY workerID DESC");
$query=mysql_query($sql);
while($row=mysql_fetch_array($query)){
echo $row['FirstName'] . " " . $row['LastName'];
echo "<br />";
}
mysql_close($conn);
?>
我想了很久,,还不是不知道那出问题了 展开
展开全部
连接后
应该是还没有选择库
$db_selected = mysql_select_db('库名称', $conn);
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Not connected : ' . mysql_error());
}
// make foo the current db
$db_selected = mysql_select_db('foo', $link);
if (!$db_selected) {
die ('Can\'t use foo : ' . mysql_error());
}
?>
应该是还没有选择库
$db_selected = mysql_select_db('库名称', $conn);
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Not connected : ' . mysql_error());
}
// make foo the current db
$db_selected = mysql_select_db('foo', $link);
if (!$db_selected) {
die ('Can\'t use foo : ' . mysql_error());
}
?>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询