n8frog Posted September 27, 2010 Share Posted September 27, 2010 Ok. I have been losing my mind trying to figure this one out. I have a very simple php/mysql query that is supposed to insert data into a table on my database. The query syntax looks correct to me but maybe I'm missing something. The query looks like this: $query=("INSERT INTO frogindex (name, email, city, region, country, title, desc, url, letter) VALUES ('$name','$email1','$city','$region','$country','$title','$desc','$url','$letter')"); mysql_query($query) or die (mysql_error()); This returns an error saying that the syntax is incorrect. The funny thing is that I tried running this query in phpmyadmin and changed the variables out for static data and it worked just fine!?! I am confused. I then tried to get phpmyadmin to create php for me for this query and it gave me this: $sql= "INSERT INTO `frog_data`.`frogindex` (`name`, `email`, `city`, `region`, `country`, `title`, `desc`, `url`, `letter`) VALUES (`joe`, `joe@joesaddy.net`, `new york`, `new york`, `usa`, `mysite`, `blablabla`, `http://www.mysite.mine`, `1`)"; I entered this into my script to see how it goes and again I got an error saying something about bad syntax. The odd thing is I'm sure that the first bit of code above was working before but does not now. Any help here? The syntax of the first code example seems right to me. Quote Link to comment https://forums.phpfreaks.com/topic/214497-syntax-problem/ Share on other sites More sharing options...
Pikachu2000 Posted September 27, 2010 Share Posted September 27, 2010 desc is a MySQL reserved word. Enclose it in backticks (which are not single-quotes) `desc` and try it again. Quote Link to comment https://forums.phpfreaks.com/topic/214497-syntax-problem/#findComment-1116158 Share on other sites More sharing options...
n8frog Posted September 27, 2010 Author Share Posted September 27, 2010 Thank you Pika! You helped me out yet again! You da man! I feel very silly now as I actually did know that but for some reason I didn't clue in. Note to self... take a break! lol Sometimes another set of eyes is a real help! Quote Link to comment https://forums.phpfreaks.com/topic/214497-syntax-problem/#findComment-1116162 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.