Sample PHP/MySQL Connection & Query Code
May 16th, 2006 by Oliver - Tagged with - Posted in Other Stuff
Sample code to make connecting to a single database on multiple pages a little easier. This code is best used as an ‘include’ into the pages you wish to use DB queries. For more information on how to include go here.
-
$hostname = “127.0.0.1″;
-
$database = “users”;
-
$username = “root”;
-
$password = “mypassword”;
-
$connect_string = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);
Sample query using the ‘$connection_string’ information from above.
This will pull all records from the table ‘users’ from the database we defined above.







