Phree Posted April 6, 2006 Share Posted April 6, 2006 Hi,new user here suffering from a serious headache. I have been trying to figure this out for days. I've scoured the net trying to figure out the answer and I finally need to ask for some help. I run a website where users can upload media directly from a mobile/cell phone and the media appears straight on the website...When a user signs up, they are given a unique code which is entered into the database along with all their registration details. Then when they send their media, I have a query that matches up the unique code and pulls their username out and credits them with that post. I am now trying to add the HTTP_USER_AGENT to the database but I just cannot seem to figure out the correct syntax. Here's what I have:[code]$mms_phone_info = $_SERVER['HTTP_USER_AGENT'];$query = "INSERT INTO phone VALUES ('$mms_phone_info','')";[/code]This works great - it puts the $mms_phone_info in the table 'phone'. But what I really want to do, is UPDATE the field called "phonedetails" in the table "users". I have tried heaps of variations of this:[code]$query = "UPDATE users SET phonedetails = ".$mms_phone_info."WHERE phonepwd='{$_GET['username']}'";[/code]But it just doesn't work.I have something similar to update the number of uploads that gets incremented upon each new post:[code]$query = "UPDATE users SET nuploads=nuploads+1, ". "lastupload=NOW() WHERE phonepwd='{$_GET['username']}'"; $result = mysql_query($query);[/code]and that works perfectly.I'd appreciate ANY help anyone can give me - I'm at my wits end! Apologies for the first post essay!Thanks :) Quote Link to comment https://forums.phpfreaks.com/topic/6751-trying-to-insert-a-variable-into-table/ Share on other sites More sharing options...
jworisek Posted April 6, 2006 Share Posted April 6, 2006 [!--quoteo(post=362319:date=Apr 6 2006, 12:42 PM:name=Phree)--][div class=\'quotetop\']QUOTE(Phree @ Apr 6 2006, 12:42 PM) [snapback]362319[/snapback][/div][div class=\'quotemain\'][!--quotec--][code]$query = "UPDATE users SET phonedetails = ".$mms_phone_info."WHERE phonepwd='{$_GET['username']}'";[/code][/quote]Is it just a typo that you have [b]".$mms_phone_info."WHERE[/b] with no space? if there isn't it will read it all as one word. Try :[code]$query = "UPDATE users SET phonedetails = '$mms_phone_info' WHERE phonepwd='{$_GET['username']}'";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/6751-trying-to-insert-a-variable-into-table/#findComment-24565 Share on other sites More sharing options...
Phree Posted April 6, 2006 Author Share Posted April 6, 2006 jworisek! You are a STAR!! I tried the syntax you posted and it worked first time :)Thank-you <so> much! This has been one of those problems where you feel you're never going to get it sorted...You send the image, check the database and just expect it not to have worked. BIG smiles when I just checked it now and it's worked!Thanks again...Top posting! Quote Link to comment https://forums.phpfreaks.com/topic/6751-trying-to-insert-a-variable-into-table/#findComment-24567 Share on other sites More sharing options...
jworisek Posted April 6, 2006 Share Posted April 6, 2006 Believe me, I have stared at my fair share of queries and racked my brain only to find I had a typo ;) Quote Link to comment https://forums.phpfreaks.com/topic/6751-trying-to-insert-a-variable-into-table/#findComment-24571 Share on other sites More sharing options...
fenway Posted April 6, 2006 Share Posted April 6, 2006 Try and get into the habit of using mysql_error() when things start acting strange -- it will prevent many a headache. Quote Link to comment https://forums.phpfreaks.com/topic/6751-trying-to-insert-a-variable-into-table/#findComment-24600 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.