Please could you guys help!!!!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bigyawn_hippo
Forum Newbie
Posts: 3
Joined: Sat Sep 22, 2007 7:18 am

Please could you guys help!!!!!

Post by bigyawn_hippo »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi i am trying to create a php script which when it runs will create my SQL database and tables or is their always an easier way to do this.

Code: Select all

<?php

$connect = mysql_connect("localhost", "root@localhost", "mysqlpass") or 
   die ("Cannot conect to database");

mysql_create_db("barker")
	or die(mysql_error());

mysql_select_db ("barker");

$movie = "CREATE TABLE movie (
	movie_id int(11) NOT NULL auto_increment,
	movie_name varchar(255) NOT NULL,
	movie_review varchar(255) NOT NULL,
	movie_type tinyint(2) NOT NULL default 0,
	movie_year int(4) NOT NULL default 0,
	movie_age 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());


$movietype = "CREATE TABLE movietype (
	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());


$people = "CREATE TABLE people (
	people_id int(11) NOT NULL auto_increment,
	people_fullname varchar(255) NOT NULL,
	people_isactor tingint(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 was created";

?>
any feedback would be great

ps i m a total newbie at php code sorry if m asking a stupid question


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

[quote="[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1"][b]2.[/b] Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.[/quote]
bigyawn_hippo
Forum Newbie
Posts: 3
Joined: Sat Sep 22, 2007 7:18 am

Slighty amendment

Post by bigyawn_hippo »

Just noticed taht theirs a spelling mistake, i ve change that and it makes no diffrence and the error message explore throws back at me is

HTTP 500 internal server error

cheers
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Please could you guys help!!!!!

Post by superdezign »

bigyawn_hippo wrote:Hi i am trying to create a php script which when it runs will create my SQL database and tables or is their always an easier way to do this.
Doing it outside of PHP is always easier and quicker. The only reason you'd need to write it in PHP is if you plan to use it as an installation process on a different server.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

chmod the file to 0644 and see if that fixes it.
lafflin
Forum Contributor
Posts: 123
Joined: Thu Jul 26, 2007 6:26 pm

Post by lafflin »

Hi, I'm a newb too, but I've been frequenting this place for about a month now.
I have a few bits of newb to newb advice for ya.


The descriptive subject thing. It's important, often you'll get people that will just post back and remind you of that rule, which if they weren't
would be answering your question. Also, this sites serves as a great resource to look through to see if others have had ths same issue your having and without descriptive subject that whole functionality is lost.

This site can be more valuable than any other resource you could possible use as a beginner. I know because for about a month now I've done nothing but learn PHP and this site has been my most valuable resource by far. Look through the sticky posts and read alot of the code from some of the mods.

-------------------------------------------------------------------------------------------------------------------

having said all that, sorry if some of it is obvious,

Are you testing on your own computer?
You can download WAMP (windows, apache, MySQL, PHP) and it has everything you need to run a server on yor windows PC. It's incredibly easy, you don't need to understand the linux filesystem or anything, and it makes for an more standard configuration so long as you leave the defaults.
But then you could also change the php.ini settings to show always show errors in your code when it is run and things of that nature.

The point is that it is much easier to make a DB in PHPMyadmin ( a gui program which installs with WAMP) than it is to do it using php.
you'll also need it for troubleshooting your applications.

You could have known all of this, and if so great, maybe some other newb looking through the site could use some of this info. I'm really just trying to give back to the community because I've gotten so much help here in the recent past.
bigyawn_hippo
Forum Newbie
Posts: 3
Joined: Sat Sep 22, 2007 7:18 am

Thanks for the advice, but .......

Post by bigyawn_hippo »

just one snag i ve installed WAMP onto my computer and used all the default settings like u suggested but phpadmin will not load any ideas ? my web browser gives error message 404

cheers and thanks for bearing with me us newbies must do ur head in
Bon Bon
Forum Commoner
Posts: 66
Joined: Sat Mar 13, 2004 10:21 pm
Location: UK

Post by Bon Bon »

Make sure there is a trailing forward slash on the address you visit:

http://127.0.0.1/phpmyadmin/
Post Reply