Re: Inserting DATE in mySQL!!
| From: | Hardy Merrill | Date: | Mon, 05 Mar 2001 12:48:16 +0000 |
| Subject: | Re: Inserting DATE in mySQL!! | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-42610@lists.php.net to get a copy of this message | ||
CC Zona [cczona@nospam.invalid] wrote:
> In article <20010305115110.4426.qmail@web3701.mail.yahoo.com>,
> thomasedisonjr@yahoo.com ("Thomas Edison Jr.") wrote:
>
> > I'm using the following code to insert date into my
> > mySQL table named "Booking". I've created variables
> > that store the date with dashes "-" seperating them.
> > But it's not working. It's giving me an error on the
> > $SQl line.
> >
> > following is the code :
> >
> > <?php
> > $db = mysql_connect("localhost","root");
> > mysql_select_db("motorola",$db);
> >
> > $realsdate="$syear"."-"."$smonth"."-"."$stdate";
> >
> > $realedate="$eyear"."-"."$emonth"."-"."$endate";
> >
> > $realstime="$shh".":"."$smm"."-"."$sttime";
> >
> > $realetime="$ehh".":"."$emm"."-"."$entime";
> > $sql = INSERT INTO booking
> > (room,sdate,edate,stime,etime,purpose,reserved) VALUES
> >
> > ('$rooms','$realsdate','$realedate','$realstime','$realetime','$purpose','$res
> > ');
> > $result = mysql_query($sql) or Die ("An unexpected
> > error occured. Please go back and book again.");
> > ?>
>
> Your value for the variable "sql" isn't enclosed in quotes. BTW, tracking
> down problems with a sql query gets easier when you give yourself a more
> informative die() message, such as:
>
> or die ("MySQL says: " . mysql_errorno() . " " . mysql_error() .
> "\nPHP
^^^^^^^^^
Just a technicality, but I think I remember this to be
mysql_errno(). But CC is right - in your "die", give yourself
as much info about the error as possible.
--
Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com
> says: $errormsg");
>
> --
> CC
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net