怎么解决原因: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 '' at line 1

<?php
include '../../../conn/f_sqlcon.php';
error_reporting(E_ALL & ~E_NOTICE);
$imgid=$_GET['imgid'];
$text=$_POST['tt'][$imgid-1];
$tupian=$_FILES['dizhi']['tmp_name'];
$lujin="img/dpj/".$_FILES['dizhi']['name'];

if($tupian=='')
{
//设置TEXT
$sql="UPDATE img_dpj SET text=\"$text\" WHERE imgid = {$imgid} ";

}
else
{//设置TEXT和SRC
$sql="UPDATE img_dpj SET src=\"{$lujin}\",text=\"$text\" WHERE imgid = {$imgid} ";

}
move_uploaded_file($tupian, $lujin);

if ($row = mysql_query($sql)) {

echo "<script>alert('更新成功'); location='dpj.php';</script>";

} else {
echo "alert(&#39;更新失败&#39;)";
echo "
";
echo "原因:";
echo mysql_error();
}