This is the first time I’m trying to connect to a database, and so far, its pretty crummy. Let me post my code first.


<?php $link = mysql_connect('localhost', 'root', '[i]password[/i]') or die('Error' . mysql_connect_error()); if(!$link) { $output = "Unable to connect to the database server."; include 'test5-1.php'; exit(); } if(!mysql_set_charset($link, 'utf-8')) { $output = "Unable to set database encoding."; include 'test5-1.php'; exit(); } if(!mysql_select_db($link, 'ziz')) { $output = "Unable to locate the joke database."; include 'test5-1.php'; exit(); } $output = 'Database connection established.'; include 'test5-1.php'; ?>



<?php echo $output; echo $link; ?>


When i type in http://localhost/test5.php into my web browser, it just sits there, loads, and after a while, just stops and does nothing. No output, no nothing. There is a database called ziz in my MySQL database. So is there a PHP error, or a MySQL error, or what, because I’m getting nothing from my browser.
And I’m using the latest versions of PHP and MySQL and the best version of Apache (as stated on thier site).

When you are establishing connection to database server, you have this function - mysql_connect_error(). I am not aware of such function, try to use mysql_error(). Also, for debugging purposes, turn On error_reporting so that it display all errors/warnings.

Sponsor our Newsletter | Privacy Policy | Terms of Service