Ok i'm trying to get this script to make a database but it keeps giving me an error, which i can't seem to figure out why. Maybe someone can look at it and let me know, i just can't see it right now. <?php //connect to MySQL; note we've user our own parameters - you should use //your own for hostname, user, password $connect=mysql_connect("localhost","account","password") or die ("hey idiot, check your server connection."); //create the main database mysql_create_db("database_name") or die(mysql_error()); // make sure our recently created database is an active one mysql_select_db("database_name"); //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 people ( movietype_id int(11) not null auto_increment, movietype_label 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 creation Successfull!"; ?> PHP: and i get this error any ideas? THANKS!
Your hosting has probably disabled the function mysql_create_db(). The number of databases databases might be limited in you hosting plan, and/or can only be created through the CP.
Typically you should create databases from scripts, most users do not have permission in production environments to create databases anyway, just delete the mysql_create_db command and do it in phpmyadmin, leave the select database func there
i have it already, just need to know what to do? Or you meant to add the db and tables etc..? cuz the point of making this is to learn, so that's why i'm doing it this way for now...
thanks, that did work, although it did say that one of the tables was created already, i check though and it was fine. now i have a different error lol, when i run the script to enter the data hehe i'm not having a good day for this, maybe i should pick up again tomorrow <?php //connect to mysql $connect=mysql_connect("localhost", "account", "pass") or die("hey shithead!, Check your server connection."); //make sure we're using the right db mysql_select_db("db_name"); //insert data into "movie"table $insert="insert into movie (movie_id, movie_name, movie_type, movie_year, movie_leadactor, movie_director) values (1, 'Bruce Almighty',2003,1,2), (2, 'Office Space', 5, 1999, 5, 6), (3, 'Grand Canyon', 2, 1991, 4, 3)"; $results=mysql_query($insert) or die(mysql_error()); //insert data into "movie_type" table $type="insert into movietype (movietype_id, movietype_label) values(1,'Sci Fi'), (2, 'Drama'), (3, 'Adventure'), (4, 'War'), (5, 'Comedy'), (6. 'Horror'), (7. 'Action'), (8. 'Kids')"; $results=mysql_query($type) or die(mysql_error()); //insert data into "people" table $people+"insert into people (people_id,people_fullname,people_isactor,people_isdirector) values (1, 'Jim Carrey', 1, 0), (2, 'Lawrence Kasdan', 0, 1), (3, 'Tom Shadyac', 0, 1), (4, 'Kevin Kline', 1, 0), (5, 'Ron Livingston', 1, 0), (6, 'Mike Judge', 0, 1)"; $results=mysql_query($people) or die(mysql_error()); echo "Data inserted successfully!"; ?> PHP: Error: ahhh isn't learning so much fun, but i guess its better to run into mistakes and learn rather then have it all go smooth and not really learn that stuff. kinda helps you understand it all a bit more. Thanks for the help so far it is appreciated!
well i'm trying to learn how to create files that will make the database and then input the information from a script.... so then in the future I can make an auto install script for anything that i learn to write... long ways from that but it's fun so far
Well I was about to create databases and tables and stuff fine from the tutorial at www.w3schools.com , perhaps you should check those out.
I like to read it from a book kinda, dunno just do. Also I paid 60$ for this book from chapters so you can bet i'm gonna read it all I will also look at those too though,