Jump to content


Photo

Insert Issues


  • Please log in to reply
2 replies to this topic

#1 Tyco

Tyco
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 23 March 2006 - 02:04 AM

Well, I have never had this problem and I just cant figuer out what I did wrong. I copied some files to a home-server for dev testing and I had this script running on my hosted server. But, after making some mods and much to the script I could not pass this step. I also dont remember what changes I made.
Anyways heres the problem.

I have this code:
if(mysql_num_rows($result) == 0)
{
mysql_query("INSERT INTO table (name, date, type, email) VALUES('$name', '$time', '$type', '$email') ")
or die(mysql_error());
}

But then I get this error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'date, type, email) VALUES('Frank', 'March 22', 'on', 'Frank@domain.com')' at line 1

Any ideas.... Thanks!

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 23 March 2006 - 02:54 AM

date & type my be reserved words in MySQL so surround each in back ticks (`):
<?php
if(mysql_num_rows($result) == 0)
{
mysql_query("INSERT INTO table (`name`, `date`, `type`, `email`) VALUES('$name', '$time', '$type', '$email') ") or die(mysql_error());
}
?>

Ken

#3 Tyco

Tyco
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 23 March 2006 - 03:19 AM

Opps, now I feel stupid lol.

Ill try it and post back.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users