|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hello there. I'm new to MySQL, and I'm trying to use it in conjunction with PHP. However, I'm run into a stumbling block. I need to create a database and I don't have Telnet access, so I can't use any command line references.
Basically, here's the code that I managed: <?php $connection = mysql_connect("localhost","user","pass") or die ("Couldn't connect to server."); $result = mysql_query("CREATE DATABASE $db_name", $connection); if (!$result) { die("Couldn't create $db_name database!"); } else { echo "Database $db_name Has Been Created"; } ?> Now I know that the connection isn't dying because the message that always appears on submittal (btw, $db_name is posted from a form), is that it couldn't create a database, not that it couldn't connect to MySQL. Help would be much appreciated. |
|
#2
|
|||
|
|||
|
Try
$result = mysql_query("CREATE DATABASE $db_name", $connection) OR die(mysql_error()); That way you can see exactly what the MySQL error code is for that attempted query. Look at the MySQL documentation for that error code. (There is a searchable manual at www.mysql.com) |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > Help!! Database Prob.. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|