关于Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result问题
程序员文章站
2022-04-08 20:37:44
...
刚学php
$con = mysql_connect("localhost","root","","PhysicalTest");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("PhysicalTest", $con);
mysql_query("SET NAMES 'gbk_chinese_ci'");
error_reporting(E_ALL ^ E_NOTICE);
if(isset($_COOKIE['student_id']))
{
$student_id=$_COOKIE['student_id'];
}
$result=mysql_query("SELECT * FROM 成绩 WHERE 学号 ='$student_id'");
$row=mysql_fetch_array($result);
if(empty($row)) echo "";
else{
echo ...
标红的那个为什么会有warning, mysql_fetch_array(): supplied argument is not a valid MySQL result 。。。数据库表格也没有错啊。。。求问怎么回事。
--------------------------------------------------------------------------------------
结果是这样:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '��绩 WHERE 学号 =''' at line 1
是不是因为表名、列名是中文?要改成英文?
下次不用中文了,多谢
$con = mysql_connect("localhost","root","","PhysicalTest");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("PhysicalTest", $con);
mysql_query("SET NAMES 'gbk_chinese_ci'");
error_reporting(E_ALL ^ E_NOTICE);
if(isset($_COOKIE['student_id']))
{
$student_id=$_COOKIE['student_id'];
}
$result=mysql_query("SELECT * FROM 成绩 WHERE 学号 ='$student_id'");
$row=mysql_fetch_array($result);
if(empty($row)) echo "";
else{
echo ...
标红的那个为什么会有warning, mysql_fetch_array(): supplied argument is not a valid MySQL result 。。。数据库表格也没有错啊。。。求问怎么回事。
回复讨论(解决方案)
$result=mysql_query("SELECT * FROM 成绩 WHERE 学号 ='$student_id'");
查询失败了
你可以用 echo mysql_error(); 看一下究竟是什么错
估计是中文表名和字段名的问题
$result=mysql_query("SELECT * FROM 成绩 WHERE 学号 ='$student_id'") or die(mysql_error());
看看有什么错误
$result=mysql_query("SELECT * FROM 成绩 WHERE 学号 ='$student_id'");
查询失败了
你可以用 echo mysql_error(); 看一下究竟是什么错
估计是中文表名和字段名的问题
--------------------------------------------------------------------------------------
结果是这样:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '��绩 WHERE 学号 =''' at line 1
是不是因为表名、列名是中文?要改成英文?
你先这样试试
$result=mysql_query("SELECT * FROM `成绩` WHERE `学号` ='$student_id'");
但不是长久之计,你不愿起英文名字,也可以用汉语拼音呀
你先这样试试
$result=mysql_query("SELECT * FROM `成绩` WHERE `学号` ='$student_id'");
但不是长久之计,你不愿起英文名字,也可以用汉语拼音呀
下次不用中文了,多谢
推荐阅读
-
mysql_fetch_row(): supplied argument is not a valid MySQL result resource,何人能解?该如何解决
-
为何总是Warning: mysql_fetch_object(): supplied argument is not a valid MySQL resul
-
mysql_fetch_array(): supplied argument is not a valid MySQL result resource,该如何处理
-
mysql_fetch_array(): supplied argument is not a valid MySQL result resource....
-
mysql_fetch_array(): supplied argument is not a valid MySQL result resource....
-
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result res,该怎么解决
-
php出现Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result解决办法
-
mysql_fetch_array(): supplied argument is not a valid MySQL result resource,该怎么解决
-
mysql_fetch_array(): supplied argument is not a valid MySQL result resource
-
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resour,该怎么解决