Re: What is wrong with this INSERT?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Oh I¹m sorry! I was messing with the code when I copied it to the mailing
list. This is the actual code:

    $sql = mysql_query("INSERT INTO olivejuice (WHEN, WHAT, WHO) VALUES
('$WHEN','$WHAT','$WHO')");

And the entire code:

    <?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 = mysql_query("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>";
    }
    ?>



On 3/29/07 10:14 AM, "Daniel Brown" <parasane@xxxxxxxxx> wrote:

> 
>     I see $result = mysql_query($sql), but I don't see $sql = "QUERY
> STATEMENT" anywhere....
> 
> On 3/29/07, Rahul Sitaram Johari < sleepwalker@xxxxxxxxxxxxxxxx
> <mailto:sleepwalker@xxxxxxxxxxxxxxxx> > wrote:
>> Ave,
>> 
>> Does anyone know what I¹m doing wrong?
>> 
>>     <?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>";
>> 
>>     mysql_query("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>";
>>     }
>>     ?>
>> 
>> I have a form which is sending POST data. Everything is working fine to this
>> statement: echo "<SPAN CLASS='BlackText'>$WHEN, $WHAT, $WHO</SPAN><br>";
>> 
>> It is displaying POST data appropriately. It¹s just not Adding Records to
>> the Database! It¹s not giving any Errors!! This is not working:
>> mysql_query("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>";
>> 
>> Yes ­ tablename is fine
>> Yes ­ Fieldnames are fine ­ Connection is fine!
>> I¹ve double checked all these things. I¹m not getting any errors ­ it¹s just
>> not executing the INSERT for some reason!!!
>> 
>> HELP! 
>> 
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> Rahul Sitaram Johari
>> CEO, Twenty Four Seventy Nine Inc.
>> 
>> W: http://www.rahulsjohari.com
>> E: sleepwalker@xxxxxxxxxxxxxxxx
>> 
>> ³I morti non sono piu soli ... The dead are no longer lonely²
>> 
> 
> 



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux