Jump to content

Insert Issues


Tyco

Recommended Posts

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:
[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());
}
[/code]

But then I get this error:
[code]
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
[/code]

Any ideas.... Thanks!
Link to comment
Share on other sites

date & type my be reserved words in MySQL so surround each in back ticks (`):
[code]<?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());
}
?>[/code]

Ken
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.