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 "<font size='2' color='#FFFFFF'><p align='center'>"; > print "$ligne->resume</p></font></td></tr>"; > } > 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 "<tr><td>"; print "<font size=\"2\" color=\"#FFFFFF\"><p align=\"center\">"; print $ligne->resume . "</p></font></td></tr>"; } mysql_free_result($res); //--- Cheers, Nick Winfield. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php