RE: [PHP] mysql trouble

From: Date: Wed, 26 Feb 2003 01:21:30 +0000
Subject: RE: [PHP] mysql trouble
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-137173@lists.php.net to get a copy of this message
> ### <?php > ### // process form > ### $link = mysql_connect("localhost", "root"); > you need to have the password as the third argument > $link = mysql_connect("localhost", "root", "password"); > > Also, why is it in a variable? > Just make it: > mysql_connect("localhost", "root", "password"); Sometime there are users that do not have a password. Every parameter to mysql_connect() is optional, by the way. Also, you want to assign the result of mysql_connect() to a variable so you can tell the connections apart. If you only have one connection per script, then it's not a big deal. But, if you connect to several databases, then you need that result to tell them apart when you do queries later so PHP knows what connection to send your query through. > ### mysql_select_db("mydb",$db); > ### $sql = "INSERT INTO agenda (nombre, direccion, telefono, email) " + Problem is the plus (+) sign at the end of this line. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/

« previous php.general (#137173) next »