I have this function and it refuses to work:

function updateRow($artist,$folder,$name,$position,$size,$type,$body,$date) {
    $link = db_connect();
    mysql_select_db("afhbase", $link);
    $query = sprintf("
        UPDATE gallery
        SET gallery.name='%s', gallery.position='%s', gallery.type='%s', gallery.body='%s', gallery.date='%s',
        WHERE gallery.artist='%s'", mysql_escape_string($name), mysql_escape_string($position), mysql_escape_string($type), mysql_escape_string($body), mysql_escape_string($date), mysql_escape_string($artist));
    mysql_query($query);
    mysql_close($link);
}

but this function does work:

function updateRow($artist,$folder,$name,$position,$size,$type,$body,$date) {
    $link = db_connect();
mysql_select_db("afhbase", $link);
$query = sprintf("
    UPDATE gallery
    SET gallery.name='%s'
    WHERE gallery.artist='%s'", mysql_escape_string($name), mysql_escape_string($artist));
mysql_query($query);
mysql_close($link);}
}

the first function doesnt throw any errors, it just doesnt update anything in the table. ITS BEEN DRIVING ME INSANE!

1 answer

o.k.w 2355
0
points

You have one more trailing comma in the 1st update code after gallery.date='%s'. It should just be:

$query = sprintf("
    UPDATE gallery
    SET gallery.name='%s', gallery.position='%s', gallery.type='%s', gallery.body='%s', gallery.date='%s'
    WHERE gallery.artist='%s'", mysql_escape_string($name), .......
Answered over 9 years ago by o.k.w