Page 1 of 1

attempting to insert row into file

Posted: Fri Sep 27, 2002 12:21 am
by hipgecko
here's my code

Code: Select all

$query = "INSERT INSERT INTO 'calendar' ('number', 'date', 'time', 'title', 'details', 'user', 'timestamp') VALUES ('0', '".$date."', '".$time."', '".$title."', '".$details."', '".$user."', '".$timestamp."')";
    $result = mysql_query($query) or die("Attempt to add record to calendar file failed.");
all i get when attempting to execute the statement is the die error message...

this is my first attempt at using php to process forms... does my syntax look correct?

Posted: Fri Sep 27, 2002 1:41 am
by twigletmac
Firstly try changing your die statement to:

Code: Select all

die(mysql_error().'<p>'.$query.'</p>');
this will give you a more useful error message. As for your syntax, take a look at this:
http://www.mysql.com/doc/en/INSERT.html

Without looking too hard I can see that you have INSERT written twice so if that isn't a typo from when you posted in the forum I'd reduce it down to one.

Mac

ooops

Posted: Sat Sep 28, 2002 12:56 am
by hipgecko
after readying the reply, then checking my code, all i could do is go :o

thanks for pointing out the extra INSERT statement... i was so focused on the double quotes, single quotes, etc... that i completely missed that!

it's working now, and the error message thingy helped too! thanks a bunch!!!

fyi... new code that works:

Code: Select all

$query = "INSERT INTO calendar (number, date, time, title, details, user, timestamp) VALUES ('0', '".$date."', '".$time."', '".$title."', '".$details."', '".$user."', '".$timestamp."')";
    mysql_query($query) or die(mysql_error().'<p>'.$query.'</p>');