I am using PHP5 and MYSQL 4.xx on Windows 2000 with IIS.
This installation has been functioning for several months and I have created databases from the command line, run PHP scripts, etc.
Now I am trying to create a database through code.
Here is my code:
<?php
mysql_connect('localhost', 'user', 'password')
or die("Failure to communicate");
$try_create = mysql_create_db("weblogs");
if ($try_create > 0) {
echo ("Successfully created database.<BR>\n");
mysql_select_db("weblogs");
$query = "CREATE TABLE login (ID SMALLINT NOT NULL
AUTO_INCREMENT PRIMARY KEY, username VARCHAR(20), password
VARCHAR(20))";
$result = mysql_query($query);
// Since I am not using the standard MySQL
// date format, I date as an integer
$query2 = "CREATE TABLE mylog (ID SMALLINT NOT NULL
AUTO_INCREMENT PRIMARY KEY, date INT(8), blogtext TEXT)";
$result2 = mysql_query($query2);
mysql_close();
if ($result > 0 && $result2 > 0) {
echo ("Successfully created tables<BR>\n");
} else {
echo ("Unable to create tables.");
}
} else {
echo ("Unable to create database");
}
?>
I get the following error:
Fatal error: Call to undefined function mysql_create_db() in C:\Inetpub\stuff\PHP\createdb.php on line 4
So line 4 is :
$try_create = mysql_create_db("weblogs");
Isn't the function mysql_create_db("weblogs") defined as $try_create?
I am quite new to PHP/MYSQL so there is probably something quite simple that I am not understanding.
Any assistance would be greatly appreciated.
Thank You