上传php时出错

上传php时出错,php,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

现在我的代码中出现以下错误:

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);
        }
对不起,各位,我仍在学习文件上载内容。

使用mysql\u error()&mysql\u errno()提取错误详细信息:

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

更好的选择是使用能够为您处理这些错误的db类,允许您捕获和处理db错误,而不是简单地终止脚本。

这是因为您的查询有问题 尝试此操作,但返回错误消息

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

上面的代码将终止脚本,如果存在SQL错误消息

@micha它可能不仅仅是数据库连接失败。这可能与sql中包含的表、字段或值有关。上传代码和消息在哪里?请确保您在正确的路径上:)如果我在某个地方交叉路径,我会受伤