Re: What is wrong with this INSERT?

From: Date: Thu, 29 Mar 2007 14:21:16 +0000
Subject: Re: What is wrong with this INSERT?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-251614@lists.php.net to get a copy of this message
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! On 3/29/07 10:10 AM, "Rahul Sitaram Johari" <sleepwalker@rahulsjohari.com> 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@rahulsjohari.com > > ³I morti non sono piu soli ... The dead are no longer lonely² >

« previous php.general (#251614) next »