froggy
01-05-2009, 05:57 PM
Hi there, I am new to mysql and PHP so hope I explain the problem ok. I am just teaching myself mysql and php.
I want to connect to my database using PHP. I have installed mysql on my pc (using the free mysql download). run it and setup a username of root and no password.
I have created a basic PHP page just to connect to the database:-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test</title>
</head>
<body>
<?php
$dbcnx = @mysql_connect('localhost', 'root', '');
if (!$dbcnx) {
echo '<p>Unable to connect to the ' .
'database server at this time.</p>';
exit();
}
?>
</body>
</html>
Password left blank as i have not set a password for the database.
I am running this php file on a server that has PHP support. However the server doesn't have MySQL on so for the reason of learning i have the mysql running on my pc hard disk.
How can i connect to the database on my pc from my php page running on a server?
Any info needed just ask...
thanx
I want to connect to my database using PHP. I have installed mysql on my pc (using the free mysql download). run it and setup a username of root and no password.
I have created a basic PHP page just to connect to the database:-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test</title>
</head>
<body>
<?php
$dbcnx = @mysql_connect('localhost', 'root', '');
if (!$dbcnx) {
echo '<p>Unable to connect to the ' .
'database server at this time.</p>';
exit();
}
?>
</body>
</html>
Password left blank as i have not set a password for the database.
I am running this php file on a server that has PHP support. However the server doesn't have MySQL on so for the reason of learning i have the mysql running on my pc hard disk.
How can i connect to the database on my pc from my php page running on a server?
Any info needed just ask...
thanx