weemikey Posted July 25, 2007 Share Posted July 25, 2007 Hi all. I don't think I will ever understand where the single vs. double quotes should go. I have this query that is giving me a sql syntax error at the "theme_id" $sql = "UPDATE theme SET theme.img_file = '".$newname."' WHERE theme.id = '".$theme_id."'"; I've tried every permutation and combination I could think of. I still get the error. It's THREE lines of freakin' code? Is it obvious to anyone else what I'm missing? Is there a reference somewhere that explains where the quotes go and why? Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 25, 2007 Share Posted July 25, 2007 Make your life a lot simpler: $sql = "UPDATE theme SET theme.img_file = '$newname' WHERE theme.id = '$theme_id'"; Its so early for me to come up with a coherent explanation of the quotes though. Im sure i would just confuse the issue. Quote Link to comment Share on other sites More sharing options...
weemikey Posted July 25, 2007 Author Share Posted July 25, 2007 You are an officer and a gentleman. However this is what I get when I run that code: check the manual that corresponds to your MySQL server version for the right syntax to use near '6'.jpg' WHERE theme.id = ''6''' So, is my $theme_id coming IN with quotes on it? Is that the problem? Right above this sql I name a file (we're uploading avatars here). // name the file with img + the member_id + the extension (.jpg etc) $newname = "img/th_".$theme_id.$ext; So, if the filename in the error is '6'.jpg, how do I stop the theme_id from having single quotes on it? So confusing! Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 25, 2007 Share Posted July 25, 2007 I really cant think why you would get a quote there - it should be an integer variable. Can you show how/where youdefine $theme_id? Also, just to make 100% certain this is the problem, try modifying your or die statement(which, presumably you already have hence the above error) $sql = "UPDATE theme SET theme.img_file = '".$newname."' WHERE theme.id = '".$theme_id."'"; mysql_query($sql) or die(mysql_error().'<br />Query: '.$sql); Quote Link to comment Share on other sites More sharing options...
simcoweb Posted July 25, 2007 Share Posted July 25, 2007 In your SQL syntax, try naming the field/column names. That's probably throwing your error. Like this: $sql = "UPDATE theme (col1, col2) SET theme.img_file = '$newname' WHERE theme.id='$theme_id'"; Replace col1, col2 with the actual column names. Let me know what happens. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.