2013-12-19 23 views
0

我环顾四周,无法找到我的问题的答案。 我想从数据库中的一行,但它只是给了我一个公告称:注意:从数据库请求数据时错误地将数组转换为字符串转换

声明:Array对/ XAMPP字符串转换/ ...

这里是我的代码:

$sql6 = mysql_query("SELECT * FROM replies WHERE thread_id = $thread_id"); 
    $numRows = mysql_num_rows($sql6); 
    $replies = ''; 
    if ($numRows < 1) { 
     $replies = "There are no replies yet, you can make the first!"; 
    } else { 
     while ($rows = mysql_fetch_array($sql6)) { 
      $reply_content = $rows[5]; 
      $reply_username = $rows[7]; 
      $reply_date = $rows[8]; 
      $reply_author_id = [4]; 

      $sql9 = mysql_query("SELECT * FROM users WHERE id = $reply_author_id"); 
      $numRows = mysql_num_rows($sql); 
      if ($numRows < 1) { 
       while ($rows = mysql_fetch_array($sql)) { 
        $reply_user_fn = $rows['first_name']; 
        $reply_user_ln = $rows['last_name']; 
        $reply_user_id = $rows['id']; 
        $reply_user_pp = $rows['profile_pic']; 
        $reply_user_lvl = $rows['user_level']; 
        $reply_user_threads = $rows['threads']; 
        $reply_user_email = $rows['email']; 


        } 
       } 
      } 
     } 

请帮帮我。我对PHP相当陌生,而且我没有看到我做错了什么。

+3

哪行数不错误是指什么? –

+0

是这行是一个错字? '$ reply_author_id = [4];'? – Konsole

回答

0

我是相当新的PHP为好,但不应该在你的,而比较是

mysqli_fetch_array($sql6) 

,而不是

mysql_fetch_array($sql6)? 
+0

你是正确的当涉及到安全,但它不会给任何错误:) –

+0

啊,我明白了。我不知道。我刚刚看到我的代码有我,你的没有,哈哈。 –

0

错字

$sql9 = mysql_query("SELECT * FROM users WHERE id = $reply_author_id"); 
$numRows = mysql_num_rows($sql); //here $sql will be $sql9 
代码

-----------------------------------------------^

if ($numRows < 1) { 
while ($rows = mysql_fetch_array($sql)) {//here $sql will be $sql9 

------------------------------------------- ------------^

正确的代码:

$sql9 = mysql_query("SELECT * FROM users WHERE id = $reply_author_id"); 
$numRows = mysql_num_rows($sql9); //here $sql will be $sql9 
if ($numRows < 1) { 
while ($rows = mysql_fetch_array($sql9)) {//here $sql will be $sql9 
+0

这摆脱了错误,但现在我得到一个新的错误,说我的mysql语法中有一个错误。 – nitrous

+0

你能否详细说明你的错误?在这里粘贴 –

相关问题