Re: Please help!!! Can't connect PHP with MySQL
try this simple code:
<?php
mysql_connect('localhost', 'mysql_user', 'mysql_pass')
or die('could not connect:' . mysql_error());
mysql_db_name ('DB_name');
mysql_select_db('DB_name')or die('could not select DB');
?>
or
//connect to a singl db
function qdbconn() {
$dbUser = "myuser";
$dbPass = "mypassword";
$dbName = "mydatabase";
$dbHost = "myhost";
if (!($link= mysql_connect($dbHost, $dbUser, $dbPass))) {
error_log(mysql_error(), 3, "temp/phplog.err");
}
if (!mysql_select_db($dbName, $link)) {
error_log(mysql_error(), 3, "/temp/phplog.err");
}
}
/*
if you like, you could extend this function by creating links (for example, $link1,
$link2) to multiple databases on the same server.This code also records a MySQL error message to the
PHP error log.
*/
Subject
Written By
Posted
Re: Please help!!! Can't connect PHP with MySQL
October 28, 2005 12:12PM
November 15, 2005 04:06PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.