I keep getting this whenever I run the below code:
Fatal error: Call to undefined function mysql_connect() in C:\wamp\www\php-academy\113-connect-db.php
<?php
$conn_error ='could not connect';
$mysql_host = 'localhost';
$mysql_user = 'root';
$mysql_pass = '';
mysql_connect($mysql_host, $mysql_user, $mysql_pass) or die($conn_error);
$mysql_db = 'a_database';
mysql_select_db($mysql_db) or die($conn_error);
echo 'Connected!';
?>
I suspect that this is because the extension is not loaded. I would check your php_info(); to find out.
Once you do your code should work, although I prefer to assign the mysql_connect() to a variable and then call that variable in mysql_select_db() as I have below: