2011-12-05 48 views
-1

得到錯誤,我在我的代碼現在收到此錯誤:在上傳PHP

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/valerie2/public_html/elinkswap/snorris/upload.php on line 83 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/valerie2/public_html/elinkswap/snorris/upload.php on line 84 

這裏是我的代碼行:

79.dbConnect(); 
80. $SQL="SELECT fileId FROM upload WHERE fileName='".$result."'"; 
81. //echo $SQL; 
82. $rs=mysql_query($SQL); 
83. echo mysql_num_rows($rs); 
84. if(mysql_num_rows($rs)!=0){ 
85.  $extension=strrchr($result,'.'); 
86.  $result=str_replace($extension,time(),$result); 
87.  $result=$result.$extension; 
88. } 
89. return $result; 
90.} 

感謝。

這也是另一個錯誤我得到..

Warning: imagejpeg() [function.imagejpeg]: Unable to open '/home/valerie2/public_html/elinkswap/upload/tmb-desert.jpg' for writing: No such file or directory in /home/valerie2/public_html/elinkswap/snorris/upload.php on line 55 

Warning: imagejpeg() [function.imagejpeg]: Unable to open '/home/valerie2/public_html/elinkswap/upload/desert.jpg' for writing: No such file or directory in /home/valerie2/public_html/elinkswap/snorris/upload.php on line 56 

    53. imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); 
    54. if (is_numeric(strpos($type,"jpeg"))){ 
    55.  imagejpeg($dst_img,"/home/valerie2/public_html/elinkswap/upload/".$thumbFilename); 
    56. imagejpeg($src_img,"/home/valerie2/public_html/elinkswap/upload/".$filename); 
     } 
    57. if (is_numeric(strpos($type,"png"))){ 
     58. imagepng($dst_img,"/home/valerie2/public_html/elinkswap/upload/".$thumbFilename); 
     59. imagepng($src_img,"/home/valerie2/public_html/elinkswap/upload/".$filename); 
     } 

對不起大家,我仍然在學習文件上傳的東西。

+1

@micha終止與錯誤味精腳本它可能不僅僅是一個數據庫連接失敗。它可能與SQL中包含的表,字段或值有關。 –

+0

其中是上傳代碼和味精是明確的請確保你在維權路徑:) – Sedz

+0

好吧我上傳了代碼 – sn1984

回答

1

它,因爲你有什麼問題與您的查詢 嘗試這一點,但後面的錯誤味精

82 $rs=mysql_query($SQL) or die(mysql_error()); 

將上面的代碼從SQL是否存在

0

使用mysql_error()& mysql_errno()來提取錯誤的詳細信息:

$rs=mysql_query($SQL) or die(mysql_error()); 

一個更好的選擇是使用DB類,可以處理這些錯誤給你,讓你的陷阱&手柄DB錯誤而不是簡單地殺死劇本。