I recently upgraded to Apache 2.2. As a result I upgraded to PHP5 and in the process, upgraded to the latest version mysql. I now cannot create a new database in mysql from PHP. Has anyone else encountered this problem? Below is the code I am using to create a database. <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'password'; $dbname = 'newdb'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecton to mysql'); $query = "CREATE DATABASE newdb"; $result = mysql_query($query); mysql_select_db('newdb'); mysql_close($conn); ?>I get no errors, but when I check within mysql, the new database has not been created. Your help would be greatly appreciated. I have no idea where to start since I am getting no error messages.
Replace: $result = mysql_query($query); PHP: With: $result = mysql_query($query) OR die(mysql_error()); PHP: And see what error you get. You may have to restore the privileges.
By 'latest version of MySQL', do you mean MySQL5? I think you need to use the mysqli_ functions for that, though could be wrong. nico_swd's right, either way, though I would also suggest replacing "die ('Error connecton to mysql');" with "die(mysql_error());", too. It's silly not giving PHP and MySQL the chance to actually tell you what went wrong
I tried both suggestions and still no errors are displayed and no database is created. Any other ideas? TwistMyArm - I have never used mysqli_functions. Where do I find out more about them?