Re: database conection (newby)
| From: | Miles Thompson | Date: | Thu, 29 Nov 2001 15:07:47 +0000 |
| Subject: | Re: database conection (newby) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-76044@lists.php.net to get a copy of this message | ||
In the include file, call it ""dbname.inc",
<? $db_name = "database_name";
$db_server="Server_name";
$db_user="name";
$db_password="password"?>
and then at the top of a page needing the database ...
<?
require( "dbname.inc" );
$db = mysql_pconnect("$db_server","$db_user", "$db_password");
mysql_select_db("$db_name",$db);
// and then proceed with the rest of the page.
// look at the manual for examples
// adding "or die("Could not connect to server") " to the mysql_pconnect is a good idea, as the script stops there if the connection fails, rather than printing out all your source with a pile of error messages.
Miles Thompson
At 03:52 PM 11/29/2001 +0100, Tommy Straetemans wrote:
Hi I'am totaly new in php i work always with asp. I give the folowing hidden fields to a php script <input type=hidden name=connectie value="mysqlhost.mijndomein.be:3306"> <input type=hidden name=uid value="U0498526"> <input type=hidden name=pwd value="iwinfo59"> <input type=hidden name=database value="D0498526"> and in my php script i try to make my connection as follows: $conn = mysql_connect('%s','%s','%s',$connectie,$uid,$pwd); mysql_select_db('%s',$database,$conn); but i keep getting this error: Warning: Wrong parameter count for mysql_connect() in /home/users/mijndomein.be/admin/x.php on line 27 What do i wrong or is there a method to make my connection with a include file? Tommy Straetemans -- 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