Scooby-Doo Posted May 20, 2012 Share Posted May 20, 2012 Hi Everyone I am new around here so be gentle, as I think on this project I will be around for quite sometime Im new to php sql and been reading Larry Ullman PHP, now my problem is I just downloaded a snippet of code and I cannot see the fault with creating/inserting a table into my DB $query = CREATE TABLE category ( cat_id int(2) NOT NULL auto_increment, category varchar(25) NOT NULL default '', PRIMARY KEY (cat_id) ) TYPE=MyISAM; INSERT INTO category VALUES (1, 'Fruits'); INSERT INTO category VALUES (2, 'Colors'); INSERT INTO category VALUES (3, 'Games'); INSERT INTO category VALUES (4, 'Vehicles'); CREATE TABLE subcategory ( cat_id int(2) NOT NULL default '0', subcategory varchar(25) NOT NULL default '' ) TYPE=MyISAM; INSERT INTO subcategory VALUES (1, 'Mango'); INSERT INTO subcategory VALUES (1, 'Banana'); INSERT INTO subcategory VALUES (1, 'Orange'); INSERT INTO subcategory VALUES (1, 'Apple'); INSERT INTO subcategory VALUES (2, 'Red'); INSERT INTO subcategory VALUES (2, 'Blue'); INSERT INTO subcategory VALUES (2, 'Green'); INSERT INTO subcategory VALUES (2, 'Yellow'); INSERT INTO subcategory VALUES (3, 'Cricket'); INSERT INTO subcategory VALUES (3, 'Football'); INSERT INTO subcategory VALUES (3, 'Baseball'); INSERT INTO subcategory VALUES (3, 'Tennis'); INSERT INTO subcategory VALUES (4, 'Cars'); INSERT INTO subcategory VALUES (4, 'Trucks'); INSERT INTO subcategory VALUES (4, 'Blkes'); INSERT INTO subcategory VALUES (4, 'Train'); I have tried everything and they all seem to put errors up, I know there is a schoolboy, learning curve error somewhere but where? Thanks for any help in advance Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 20, 2012 Share Posted May 20, 2012 You cannot execute multiple query statements in one mysql_query statement. Are you sure you weren't supposed to copy/paste that directly into your favorite database management tool instead of running it through a php script? In order to run multiple query statements through a php script, you will need to run them individually. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted May 20, 2012 Share Posted May 20, 2012 And what are those errors? Quote Link to comment Share on other sites More sharing options...
Scooby-Doo Posted May 20, 2012 Author Share Posted May 20, 2012 And what are those errors? I have just tried $query = CREATE TABLE category ( cat_id INT(2) NOT NULL AUTO_INCREMENT, category VARCHAR(25) NOT NULL default '', PRIMARY KEY (cat_id)) TYPE=MyISAM; and still got this error unexpected T_STRING in C:\xampp\htdocs\ Quote Link to comment Share on other sites More sharing options...
Scooby-Doo Posted May 20, 2012 Author Share Posted May 20, 2012 I dont know if this is right or wrong..I went into myphpadmin sql and dumped each one individually, at first it gave me an error about MyIsam...removed that and everything is ok...Is Myisam important or is it an old version of xammp that causing the problem Thanks Quote Link to comment Share on other sites More sharing options...
Jessica Posted May 20, 2012 Share Posted May 20, 2012 Are you putting that query in quotes? Post the whole code. Quote Link to comment Share on other sites More sharing options...
fenway Posted May 21, 2012 Share Posted May 21, 2012 Are you putting that query in quotes? Post the whole code. Please don't ask for that -- it's quite clear there is no opening quote. Quote Link to comment Share on other sites More sharing options...
Jessica Posted May 22, 2012 Share Posted May 22, 2012 Well I don't mean the whole page, I meant the relevant section, but I said the wrong thing I'm wondering what the errors are. Quote Link to comment Share on other sites More sharing options...
fenway Posted May 27, 2012 Share Posted May 27, 2012 Well I don't mean the whole page, I meant the relevant section, but I said the wrong thing I'm wondering what the errors are. I figured as much -- but I've seen 80kb attachements recently. As mentioned above, that string isn't quoted at all. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.