我正在尝试根据个人用户ID从数据库中的表中检索数据。 我一直在说:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /xampp/... on line 50
和
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /xampp/... on line 52
这是我的代码:
37. $sql6 = mysql_query("SELECT * FROM replies WHERE thread_id = $thread_id");
38. $numRows = mysql_num_rows($sql6);
39. $replies = '';
40. if ($numRows < 1) {
41. $replies = "There are no replies yet, you can make the first!";
42. } else {
43. while ($rows = mysql_fetch_array($sql6)) {
44. $reply_content = $rows[5];
45. $reply_username = $rows[7];
46. $reply_date = $rows[8];
47. $reply_author_id = $rows[4];
48.
49. $sql9 = mysql_query("SELECT * FROM users WHERE id = $reply_author_id");
50. $numRows = mysql_num_rows($sql9);
51. if ($numRows < 1) {
52. while ($rows = mysql_fetch_array($sql9)) {
53. $reply_user_fn = $rows['first_name'];
54. $reply_user_ln = $rows['last_name'];
55. $reply_user_id = $rows['id'];
56. $reply_user_pp = $rows['profile_pic'];
57. $reply_user_lvl = $rows['user_level'];
58. $reply_user_threads = $rows['threads'];
59. $reply_user_email = $rows['email'];
60.
61.
62. }
63. }
64. }
65. }
我也放或死(mysql_error());在我所有的SQL查询上,我不断得到:
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 'bla bla bla' at line 1
我页面上的第1行是:
<?php include_once('config.php'); ?> //Connect to database
所以这没有任何意义。请帮帮我。
由于
答案 0 :(得分:1)
尝试交换此(添加''):
$sql9 = mysql_query("SELECT * FROM users WHERE id = '$reply_author_id'");
答案 1 :(得分:0)
我建议,尝试连接查询。试试这个。
$sql9 = mysql_query("SELECT * FROM users WHERE id = ".$reply_author_id);
我总是使用这种格式。我希望这可以帮到你。