michaelkirby Posted April 8, 2010 Share Posted April 8, 2010 Hi all, I have an upload on and at present it uploads fine to the correct destination. As I'm uploading images I want to be able to store the image in a specific table which is users. $query = "insert into users values where userid= $userid (0,'".$filename."')"; So I run the above query but I errors saying: Unable to perform query insert into users value where userid= 1 (0,'Lighthouse.jpg') I'm storing the user id from the session variable into $user id as below and also putting the filename into the $filename variable. $userid = $_SESSION['userid']; $filename = $_FILES["file"]["name"]; Not sure if I'm doing anything wrong any one able to help? Quote Link to comment https://forums.phpfreaks.com/topic/198012-query-structure-why-would-this-not-work/ Share on other sites More sharing options...
Mchl Posted April 8, 2010 Share Posted April 8, 2010 You can't have WHERE clause in INSERT query, because you're inserting a new row so WHERE has nothing to match to. Perhaps you want UPDATE? Quote Link to comment https://forums.phpfreaks.com/topic/198012-query-structure-why-would-this-not-work/#findComment-1039025 Share on other sites More sharing options...
michaelkirby Posted April 8, 2010 Author Share Posted April 8, 2010 Brilliant!! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/198012-query-structure-why-would-this-not-work/#findComment-1039029 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.