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个回答
展开全部
$sql = "slecte * from table"; 应该是select。table是自己的表名,用户名密码什么的就不说了。
题目的错误在于一条资源都没有获取到,所以错误。
题目的错误在于一条资源都没有获取到,所以错误。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
一个明显的错误:$sql = "slecte * from table"; 改成$sql = "select * from table";
其他程序,我仔细验证,没任何错误,您试试吧。
其他程序,我仔细验证,没任何错误,您试试吧。
追问
太感谢,测试成功了!
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
$DB_Server = "localhost";
$DB_Username = "root";
$DB_Password = "1234556";
$DB_DBName = "jishigou";
$Connect = @mysql_connect($DB_Server, $DB_Username, $DB_Password) or die("Couldn't connect.");
mysql_query('set names "gbk"');
mysql_select_db('jishigou');
链接数据库换成这种
$DB_Username = "root";
$DB_Password = "1234556";
$DB_DBName = "jishigou";
$Connect = @mysql_connect($DB_Server, $DB_Username, $DB_Password) or die("Couldn't connect.");
mysql_query('set names "gbk"');
mysql_select_db('jishigou');
链接数据库换成这种
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2012-01-04 · 知道合伙人互联网行家
关注
展开全部
$sql = "slecte * from table";
table 使用了自带关键字,修改一下表名。
table 使用了自带关键字,修改一下表名。
追问
测试了,错误提示还是没任何改变。
追答
$sql = "select * from `table`";
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
$result = mysql_db_query($mysql_database,$sql,$conn);
改成:
$result = mysql_select_db($mysql_database,$sql,$conn);
试试?
改成:
$result = mysql_select_db($mysql_database,$sql,$conn);
试试?
追问
测试了,变成了下面的错误:Warning: Wrong parameter count for mysql_select_db() in E:\AppServ\www\sql.php on line 19
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in E:\AppServ\www\sql.php on line 21
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询