So I'm coding up the following example
PHP Code:
<?php
$connect = mysql_connect("localhost","user","foo") or
die ("Check MySQL is up and running and/or the install scrpit");
//create the main database
mysql_create_db("wiley")
or die(mysql_error());
// $query_string = "Create database wiley";
// mysql_query($query_string)
// or die(mysql_error());
// if(mysql_create_db("wiley"))
// {
// print("Database created successfully\n");
// }
// else
// {
// print("Error creating database: %s\n", mysql_error());
// }
//make database an active db
mysql_select_db ("wiley");
//create "movie" table
$movie = "CREATE TABLE movie
(
movie_id int(11) not null auto_increment,
movie_name varchar(255) not null,
movie_type tinyint(2) not null default 0,
movie_year int(4) not null default 0,
movie_leadactor int(11) not null default 0,
movie_director int(11) not null default 0,
primary key (movie_id),
key movie_type (movie_type,movie_year)
)";
//TYPE=MyISAM AUTO_INCREMENT=4 ";
$results = mysql_query($movie)
or die (mysql_error());
//create "movietype" table
$movietype = "CREATE TABLE movietype
(
movietype_id int(11) not null auto_increment,
movietype_lable varchar(100) not null,
primary key (movietype_id)
)";
//TYPE=MyISAM AUTO_INCREMENT=9" ;
$results = mysql_query($movietype)
or die(mysql_error());
//create "people" table
$people = "CREATE TABLE people
(
people_id int(11) not null auto_increment,
people_fullname varchar(255) not null,
people_isactor tinyint(1) not null default 0,
people_isdirector tinyint(1) not null default 0,
primary key (people_id)
)";
//TYPE=MyISAM AUTO_INCREMENT=7";
$results = mysql_query($people)
or die(mysql_error());
echo "Movie Database successfully created!";
?>
When I try to run this php from the browser nothing happens...so I
use the following
php -a createmovie.php
and I get this output
Code:
cmmiller@probot:~/php$ php -a createmovie.php
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/mysql.so' - /usr/local/lib/php/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/gettext.so' - /usr/local/lib/php/gettext.so: cannot open shared object file: No such file or directory in Unknown on line 0
Interactive mode enabled
PHP Fatal error: Call to undefined function mysql_create_db() in /home/cmmiller/php/createmovie.php on line 8
If you look at the last line, it is telling me that the function
mysql_create_db() is undefined???
I check here
http://us2.php.net/mysql_create_db
and it says that it is ok...so I'm really confused as to what is going on?!!?
So php experts, let me know what you think...
thanks