(或提示:mysql_num_rows():supplied argument is not a valid MySQL result resource)
1,重现这个错误,mysql>
- select * from users where name = admin;
2,解决这个错误:
- select * from users where name = "admin";
3,错误原因:使用php编写mysql_query语句时没有对字符串进行相关的转义处理。
两个调试后正确的示例:
①
- $result = mysql_query("select * from users where name = "."\"".$_POST["newname"]."\"");
②
- mysql_query("insert into users values (".
- "\"".$_POST["newname"]."\",".
- "\"".$_POST["newpwd"]."\",".
- "\"".$_POST["newage"]."\",".
- "\"".$_POST["gender"]."\"".
- ")");
阅读(4568) | 评论(0) | 转发(0) |