Mysql Error Out Of Nowhere

Discussion in 'PHP' started by Mr Plow, Aug 11, 2006.

  1. #1
    $query = "UPDATE `users` SET `picture` = '$file_name' WHERE `username` ='$username'";
                echo "debug: functions $query";
                mysql_query($query);
                echo mysql_error();
                echo mysql_info();
    PHP:
    results in:

    debug: functions UPDATE `users` SET `picture` = 'blahblah3964.gif' WHERE `username` ='blahblahusername'Rows matched: 1 Changed: 1 Warnings: 0

    and yet...no rows were changed! I checked the entire database!

    picture is a varchar, by the way. and file_name is a string.
     
    Mr Plow, Aug 11, 2006 IP
  2. Gordaen

    Gordaen Peon

    Messages:
    277
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hmm, I'm not sure on that one, you could try updating the query like this:

    $query = sprintf("UPDATE `users` SET `picture` = '%s' WHERE `username` ='%s'",
       mysql_real_escape_string($file_name),
       mysql_real_escape_string($username));
    PHP:
    Try printing the relevant portion of the db before and after the change to see if there is any difference whatsoever. Maybe set $blah = mysql_query($query); and verify $blah is okay?
     
    Gordaen, Aug 11, 2006 IP
  3. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Without seeing the real error, it impossible for us to tell. Turn up your error reporting, paste the actual query here and in phpMyAdmin to see what errors they give you. As Gordaen suspects, it's probably a malformed string.
     
    T0PS3O, Aug 11, 2006 IP