mysql / php更新语法,传递php变量

时间:2013-01-07 03:01:34

标签: php mysql

我有一个带有列的mysql表:name,active(active is int)。我想将图片上传到服务器,当它们已经在服务器上时,我想将它们设置为活动状态,以便将它们用作新徽标。 (当active = 1时,pic是新标识)我无法弄清楚为什么我的“$ query”不起作用。其他一切都很好。

$name = $_FILES["file"]["name"]; 
if (file_exists("/home/a1829256/public_html/admin/logo/" .$name)){          //if file already on the server
        echo "file is already on the server";
        echo ". Making it the new logo";
        $deselectlogo = "UPDATE newlogo SET active=0 WHERE active>0";               //deselect old
        $deselectlogoResult = mysql_query($deselectlogo);
        $query = ("UPDATE newlogo SET active=1 WHERE name=" .$name);            // make the new logo active
        $queryResult = mysql_query($query);
        if (!$queryResult){echo "error";}
        if ($queryResult){echo "success";}

1 个答案:

答案 0 :(得分:0)

   $query = "UPDATE newlogo SET active=1 WHERE name='".$name."'";            // make the new logo active