Re: [PHP] SELECT + PARSE ERROR
Thanks at All -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SELECT + PARSE ERROR
At 08.04.2002 14:23, you wrote: >Hy, > >I try to do a SELECT but when I test my code I Have a parse error. >If someone can explain to me why. > >Code: > >$db = mysql_connect(newsmanga_db); >$req = "SELECT * FROM dvds WHERE nomdvd='".$nom."".$i"' "; /// PARSE >ERROR IN THIS LINE Try this : $req = "SELECT * FROM dvds WHERE nomdvd='".$nom.$i."' "; or if you want a space between $nom and $i, put it between the Quotes >$res=mysql_query($req, $db); >while ($ligne = mysql_fetch_object ($res)) { > print ""; > print "$ligne->resume"; >} >mysql_free_result ($res); >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SELECT + PARSE ERROR
On Mon, 8 Apr 2002, [iso-8859-1] Jérome Moisy wrote: > Hy, > > I try to do a SELECT but when I test my code I Have a parse error. > If someone can explain to me why. > > Code: > > $db = mysql_connect(newsmanga_db); > $req = "SELECT * FROM dvds WHERE nomdvd='".$nom."".$i"' "; /// PARSE ERROR IN THIS >LINE > $res=mysql_query($req, $db); > while ($ligne = mysql_fetch_object ($res)) { > print ""; > print "$ligne->resume"; > } > mysql_free_result ($res); > First glance, put quotes around newsmanga_db. $db = mysql_connect("newsmanga_db"); However, it doesn't look like you would establish a connection to the database even if you fixed the syntax error. Have a look at the PHP manual in order to see the correct usage of this function. The username/password parameters are optional, but I have a feeling that newsmanga_db is the name of your database, not the database server (usually localhost). You also need to select the database that you intend to query. http://www.php.net/manual/en/function.mysql-connect.php http://www.php.net/manual/en/function.mysql-select-db.php Personally, I'd use this code (going on what you have supplied and what I believe to be true): //--- mysql_connect("localhost", "username", "password"); mysql_select_db("newsmanga_db"); $req = "SELECT * FROM dvds WHERE nomdvd = '" . $nom . $i . "'"; $res = mysql_query($req); while ($ligne = mysql_fetch_object($res)) { print ""; print ""; print $ligne->resume . ""; } mysql_free_result($res); //--- Cheers, Nick Winfield. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SELECT + PARSE ERROR
Hi the error appears because of the comas erroned syntaxis. why don't u try something easire as that : $varalacon = $nom."".$i; (i don't know if there is a space or not...in bold) $req = "SELECT * FROM dvds WHERE nomdvd='$varalacon' "; Hope it helps SR Jérome Moisy a écrit : > Hy, I try to do a SELECT but when I test my code I Have a parse > error.If someone can explain to me why. Code: $db = > mysql_connect(newsmanga_db); > $req = "SELECT * FROM dvds WHERE nomdvd='".$nom."".$i"' "; /// PARSE > ERROR IN THIS LINE > $res=mysql_query($req, $db); > while ($ligne = mysql_fetch_object ($res)) { > print ""; > print "$ligne->resume"; > } > mysql_free_result ($res); > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >
Re: [PHP] SELECT + PARSE ERROR
At 02:23 PM 4/8/2002 +0200, you wrote: >Hy, > >I try to do a SELECT but when I test my code I Have a parse error. >If someone can explain to me why. > >Code: > >$db = mysql_connect(newsmanga_db); >$req = "SELECT * FROM dvds WHERE nomdvd='".$nom."".$i"' "; /// PARSE >ERROR IN THIS LINE Your missing a '.' after the $i . -Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php