PHP使用appserv-win32-2.5.9 ,测试如下程序出现如下错误,
感觉程序没什么错误,为什么会提示下面的错误信息啊?appserv-win32-2.5.9是我刚刚装的,请高手解决一、程序部分:<?$mysql_server_name="...
感觉程序没什么错误,为什么会提示下面的错误信息啊?
appserv-win32-2.5.9 是我刚刚装的,请高手解决
一、程序部分:
<?
$mysql_server_name = "localhost";
$mysql_username = "root";
$mysql_password = "123454";
$mysql_database = "database";
$sql = "slecte * from table";
$conn = mysql_connect($mysql_server_name,$mysql_username,$mysql_password);
$result = mysql_db_query($mysql_database,$sql,$conn);
$row = mysql_fetch_row($result);
echo "<table border = 1 cellspacing = 0 cellpadding = 0>\n";
echo "<tr>\n";
for ($i = 0;$i < mysql_num_fields($result);$i++)
{
echo "<td nowrap>" . mysql_field_name($result,$i) . "</td>\n";
}
echo "</tr>\n";
mysql_data_seek($result,0);
while($row = mysql_fetch_row($result))
{
echo "<tr>\n";
for($i = 0;$i < mysql_num_fields($result);$i++)
{
echo "<td nowrap>$row[$i]</td>\n";
}
echo "</tr>\n";
}
echo "</table>";
mysql_free_result($result);
?>
二、相应错误提示
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in E:\AppServ\www\sql.php on line 19
Warning: mysql_num_fields(): supplied argument is not a valid MySQL result resource in E:\AppServ\www\sql.php on line 22
Warning: mysql_data_seek(): supplied argument is not a valid MySQL result resource in E:\AppServ\www\sql.php on line 28
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in E:\AppServ\www\sql.php on line 29
Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in E:\AppServ\www\sql.php on line 42
二、程序部分
<?
$mysql_server_name = "localhost";
$mysql_username = "root";
$mysql_password = "123454";
$mysql_database = "mydatabase";
$sql = "slecte * from mytable where id = '1'";
$conn = mysql_connect($mysql_server_name,$mysql_username,$mysql_password);
//$result = mysql_db_query($mysql_database,$sql,$conn);
//选取您要处理的数据库
mysql_select_db($mysql_database,$conn);
//进行查询
$result = mysql_query($sql);
if($conn)
{
echo "连接成功!";
}
else
{
echo "连接失败!";
}
if ($result)
{
echo "连接成功!";
}
else
{
echo "程序出错!";
}
mysql_close($conn); //关闭连接
?>
测试结果仍然是:
连接成功!程序出错!
看来主要原因还是在这里,请高手帮忙解决啊?我是新手,确实搞不懂了啊 展开
appserv-win32-2.5.9 是我刚刚装的,请高手解决
一、程序部分:
<?
$mysql_server_name = "localhost";
$mysql_username = "root";
$mysql_password = "123454";
$mysql_database = "database";
$sql = "slecte * from table";
$conn = mysql_connect($mysql_server_name,$mysql_username,$mysql_password);
$result = mysql_db_query($mysql_database,$sql,$conn);
$row = mysql_fetch_row($result);
echo "<table border = 1 cellspacing = 0 cellpadding = 0>\n";
echo "<tr>\n";
for ($i = 0;$i < mysql_num_fields($result);$i++)
{
echo "<td nowrap>" . mysql_field_name($result,$i) . "</td>\n";
}
echo "</tr>\n";
mysql_data_seek($result,0);
while($row = mysql_fetch_row($result))
{
echo "<tr>\n";
for($i = 0;$i < mysql_num_fields($result);$i++)
{
echo "<td nowrap>$row[$i]</td>\n";
}
echo "</tr>\n";
}
echo "</table>";
mysql_free_result($result);
?>
二、相应错误提示
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in E:\AppServ\www\sql.php on line 19
Warning: mysql_num_fields(): supplied argument is not a valid MySQL result resource in E:\AppServ\www\sql.php on line 22
Warning: mysql_data_seek(): supplied argument is not a valid MySQL result resource in E:\AppServ\www\sql.php on line 28
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in E:\AppServ\www\sql.php on line 29
Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in E:\AppServ\www\sql.php on line 42
二、程序部分
<?
$mysql_server_name = "localhost";
$mysql_username = "root";
$mysql_password = "123454";
$mysql_database = "mydatabase";
$sql = "slecte * from mytable where id = '1'";
$conn = mysql_connect($mysql_server_name,$mysql_username,$mysql_password);
//$result = mysql_db_query($mysql_database,$sql,$conn);
//选取您要处理的数据库
mysql_select_db($mysql_database,$conn);
//进行查询
$result = mysql_query($sql);
if($conn)
{
echo "连接成功!";
}
else
{
echo "连接失败!";
}
if ($result)
{
echo "连接成功!";
}
else
{
echo "程序出错!";
}
mysql_close($conn); //关闭连接
?>
测试结果仍然是:
连接成功!程序出错!
看来主要原因还是在这里,请高手帮忙解决啊?我是新手,确实搞不懂了啊 展开
6个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询