PHP - MySQL connection
Sample code for connecting to a MySQL database using PHP and simple queries.
The USERNAME, PASSWORD and DATABASE_NAME variables must be substituted with those supplied for your web hosting account.
<?php // make our connection $connection = mysql_connect('localhost', dbname=DATABASE_NAME user=USERNAME password=PASSWORD"); // let me know if the connection fails if (!$connection) { print("Connection Failed."); exit; } // declare my query and execute $myresult = mysql_query($connection, "SELECT somevalue FROM sometable WHERE something = 1"); // process results $myvalue = mysql_fetch_row($myresult); // print results print("My Value: $myvalue<br />\n"); ?>