Re: Re: Subject: Wont create data in my tables

From: Date: Sun, 20 Apr 2003 19:56:33 +0000
Subject: Re: Re: Subject: Wont create data in my tables
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-19514@lists.php.net to get a copy of this message
hay morten check the name of the query where ur exeing it i get ur error when i muck up the query name re-tyoin it for exe goodluck toby --- Morten Nielsen <fantomcat@hotmail.com> wrote: > Hi Neil > > If i use your code i get "Query was empty", but i made sure i > filled out > every form on my page with text so the query shouldn't be empty > right ?. > I have a little idea that it could be the "}" sign that is making > this > error, but not sure. > > I'm stuck right now and got no clue how to get out of this mess. > > I hope you got more ideas how to solve this problem. > > Regards > Morten > > <?php > include("dbconnect.php"); > ?> > > <?php > if ($submit =="Sign!") > { > $query = "insert into guestbook ( > name, > location, > email, > url, > comments > ) > values ('".$name."', ' > ".$location."', ' > ".$email."', ' > ".$url."', ' > ".$comments." > ')"; > } > mysql_query($query) or > die (mysql_error()) > > ?> > > ----- Original Message ----- > From: "Neil Smith" <neil@fresh-toast.uklinux.net> > To: <php-windows@lists.php.net> > Cc: <fantomcat@hotmail.com> > Sent: Sunday, April 20, 2003 12:22 AM > Subject: [PHP-WIN] Re: Subject: Wont create data in my tables > > > > Hi Morten - no , the code is not correct. > > > > That is, because PHP handles variables within quotes differently > for > double > > quotes ( " ) where it replaces with the *actual value* of the > variable, > and > > within single quotes ( ' ) where it doesn't touch the value > inside the > > quotes (it assumes you mean literally, the string '$name') > > > > The way to construct the SQL is like this instead : > > > > $query = "insert into guestbook ( > > name, > > location, > > email, > > url, > > comments > > ) > > values ('".$name."', ' > > ".$location."', ' > > ".$email."', ' > > ".$url."', ' > > ".$comments." > > ')"; > > > > > > Hope that's clear (You can happily tab down like that in real PHP > code > too, > > to make the SQL more readable. Main thing is just to make sure > you match > > the quotes on each end : I usually *print* the SQL until I'm sure > I have > > the statement correct. > > > > HTH > > Neil Smith. > > > > At 20:43 19/04/2003 +0000, you wrote: > > >From: "Morten Nielsen" <fantomcat@hotmail.com> > > >To: <php-windows@lists.php.net> > > >Date: Sat, 19 Apr 2003 13:27:43 +0200 > > >MIME-Version: 1.0 > > >Content-Type: multipart/alternative; > > > boundary="----=_NextPart_000_0109_01C30677.7590E1D0" > > >Message-ID: <BAY1-DAV30arcR4ZDgC00000dbd@hotmail.com> > > >Subject: Wont create data in my tables. > > > > > >Can anybody tell me if this code is correct or not ?. > > > > > ><?php > > >if ($submit =="Sign!") > > >{ > > >$query = "insert into guestbook > (name,location,email,url,comments) > > >values ('$name', '$location', '$email', > > >'$url', '$comments')"; > > >mysql_query($query) or > > >die (mysql_error()) > > >?> > > > > > > -- > > PHP Windows Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > __________________________________________________ Yahoo! Plus For a better Internet experience http://www.yahoo.co.uk/btoffer

« previous php.windows (#19514) next »