PHP MySql Tutorial
Uncategorized January 8th, 2009
$connection = mysql_connect(Config::$db_host,Config::$db_user,Config::$db_pass);
if (!$connection) { die('Could not connect: ' . mysql_error()); }
mysql_select_db(Config::$db_database, $connection);
mysql_query($query) or die("Couldn't execute query. " . mysql_error() . "
" . $query);;
mysql_close($connection);
$connection = mysql_connect(Config::$db_host,Config::$db_user,Config::$db_pass);
if (!$connection) { die('Could not connect: ' . mysql_error()); }
mysql_select_db(Config::$db_database, $connection);
$query = "SELECT * FROM table_name";
$result = mysql_query($query) or die("Couldn't execute query. " . mysql_error() . "
" . $query);
while($row = mysql_fetch_assoc($result))
{
foreach ($row as $key => $val) { echo $key." = ".$value." | "; }
}
Did you enjoy this tutorial? Be sure to subscribe to the our RSS feed not to miss our new tutorials!
... or make it popular on




Recent Comments