2013-12-19 22 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

你能否詳細說明你的錯誤?在這裏粘貼 –

相關問題