Cant Connect to MYSQL database from PHP
Posted: Sun May 03, 2009 11:15 am
Hi
Im new to PHP and am trying to connect to MYSQL database but all I get is blank page!
My Code is:
But all I get is a blank page. I have run this code which works:
So it must be to do with connecting to the database. I cant understand why I dont even get an msg saying "Unable to connect to MySQL".
Any ideas?
Thanks
Im new to PHP and am trying to connect to MYSQL database but all I get is blank page!
My Code is:
Code: Select all
<?php
$username = "root";
$password = "";
$hostname = "localhost";
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
echo "Connected to MySQL<br>";
?>Code: Select all
<?php
echo 'PHP is working.<br>';
echo phpinfo();
?>Any ideas?
Thanks