Re: What is wrong with this INSERT?
| From: | Rahul Sitaram Johari | Date: | Thu, 29 Mar 2007 14:35:12 +0000 |
| Subject: | Re: What is wrong with this INSERT? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-251621@lists.php.net to get a copy of this message | ||
BY THOR! That worked! "WHEN" Is a reserved word and that is what was causing
the problem. Changed it to "THETIME" and query went through fine!!
Can't thank you enough! This was driving me crazy! Look how many mistakes I
made in just making this post in this mailing list!
Honorable *bow*
Thanks!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Rahul Sitaram Johari
CEO, Twenty Four Seventy Nine Inc.
W: http://www.rahulsjohari.com
E: sleepwalker@rahulsjohari.com
³I morti non sono piu soli ... The dead are no longer lonely²
On 3/29/07 10:30 AM, "Tijnema !" <tijnema@gmail.com> wrote:
> On 3/29/07, Rahul Sitaram Johari <sleepwalker@rahulsjohari.com> wrote:
>>
>> My Apologies Everyone! I gave you all the wrong code Twice!! A pox on me - I
>> tell you!
>>
>> This is the ACTUAL code that I'm working with - and it's not working:
>>
>> <?php
>> //Add Record Function
>> if($_POST['Submit']) {
>> $db = mysql_connect("localhost","usr","pwd");
>> mysql_select_db("thedb",$db) or die("Critical Error
>> :".mysql_error());
>> $WHEN = date(mdyHi);
>> $WHAT = $_POST['WHAT'];
>> $WHO = $_POST['WHO'];
>> echo "<SPAN CLASS='BlackText'>$WHEN, $WHAT,
>> $WHO</SPAN><br>";
>>
>> $sql = "INSERT INTO tbl (WHEN, WHAT, WHO) VALUES
>> ('$WHEN','$WHAT','$WHO')";
>> $result = mysql_query($sql) or die("Fatal Error :".mysql_error());
>> echo "<span class='SmallText'><EM><STRONG>~: message
>> sent
>> :~</STRONG></EM></span><BR><BR>";
>> }
>> ?>
>>
>> Please disregard the previous code I sent. Thank you!
>
> If you checked the MySQL Manual you would see that WHEN is a reserved
> word. I think that gives problem, so you could change the WHEN key
> into another key, or use some quotes around it. I recommend the first
> option :)
>
> Tijnema
>
> ps. List of reserved words for MySQL:
> http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html
>>
>>
> <snip>
>>
>>