Pudgemeister Posted July 26, 2006 Share Posted July 26, 2006 Hi AllSomeone Recently Made Me A Code For A Rating Script And Was Very Helpful And Quick About it.Only Probkem Being Is That When I Converted The Files Back Into PHP files From Text Files-Some Symbols Got Changed (At Least I Think).I Changed Some I Am Almost Sure Are Correct Now But I Get A Damn "Unexpected T_string in this file im bout to show u on line 10 bla bla u know"first thing is first-im tired of having no idea what these things are: array stringwhenever anyone explains it to me-they use alot of technical terms that a noob cant understand.can someone explain what these things are and how and when you use them in the simplest of ways please!!!rite heres the part where it goes wrong:[code]include ("dbinfo.inc.php");CREATE TABLE `rate` ( 'id' bigint(20) NOT NULL auto_increment,[/code]it is going wrong on the create table part (t_string error).i gave the other luines cus ive seen before sumtimes its the line before that is the prob.and again-cud u explain relli simply why it is wrong and how to avoid it again.thanx allPudgemeister Quote Link to comment https://forums.phpfreaks.com/topic/15712-noob-needing-help-once-again/ Share on other sites More sharing options...
wildteen88 Posted July 26, 2006 Share Posted July 26, 2006 This is becuase PHP came to an unexpected result. It found the word create and got confused. This is becuase CREATE is not a defined keyword/function in PHP. But only for SQL.You should do this instead:[code]include ("dbinfo.inc.php");$sql = "CREATE TABLE `rate` ( 'id' bigint(20) NOT NULL auto_increment, // rest of SQL code here";// perform our query$result = mysql_query($sql);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15712-noob-needing-help-once-again/#findComment-64151 Share on other sites More sharing options...
trq Posted July 26, 2006 Share Posted July 26, 2006 [url=http://www.hudzilla.org/phpbook[/url]This[/url] might help you. Php is a programming language, explaining snippets of it will not help you. Quote Link to comment https://forums.phpfreaks.com/topic/15712-noob-needing-help-once-again/#findComment-64152 Share on other sites More sharing options...
Pudgemeister Posted July 26, 2006 Author Share Posted July 26, 2006 ok thank u for the help people but ive decided if im ever going to get this part of the database created-i mite as wel post the entire page of code.its what ive been given and not what i made myself-i am too noob tbh.ok this is the code:[code]<?phpinclude ("dbinfo.inc.php");$sql = "CREATE TABLE rate ('id' bigint(20) NOT NULL auto_increment,'imagename' varchar(255) NOT NULL default '',[email protected] table for picture'userrate' bigint(20) NOT NULL default '0','maxrate' bigint(20) NOT NULL default '0','ratepercent' decimal(10,0) NOT NULL default '0','views' bigint(20) NOT NULL default '0',PRIMARY KEY ('id'),UNIQUE KEY 'imagename' ('imagename'))";$result = mysql_query($sql);$resultTYPE=MyISAM AUTO_INCREMENT=9 ;-- -- Dumping data for table 'rate'-- INSERT INTO 'rate' VALUES (1, '1.jpg', 15, 20, 75, 2);INSERT INTO 'rate' VALUES (2, '2.jpg', 3, 5, 60, 0);INSERT INTO 'rate' VALUES (3, '3.jpg', 3, 5, 60, 1);INSERT INTO 'rate' VALUES (4, '4.jpg', 0, 0, 0, 0);INSERT INTO 'rate' VALUES (5, '5.jpg', 13, 15, 87, 3);INSERT INTO 'rate' VALUES (6, '6.jpg', 3, 5, 60, 1);INSERT INTO 'rate' VALUES (7, '7.jpg', 7, 10, 70, 2);INSERT INTO 'rate' VALUES (8, '8.jpg', 4, 5, 80, 1);?>[/code]the part i have edited is the $sql part-i know its wrong-very wrong-loli need to know the correct code for all this-and also i need to know what certain parts of the code actually mean ???ok the parts i need to know bout are: [code][email protected] table for picture[/code][code]PRIMARY KEY ('id'),UNIQUE KEY 'imagename' ('imagename')[/code][code]TYPE=MyISAM AUTO_INCREMENT=9 ;[/code][code]-- -- Dumping data for table 'rate'-- INSERT INTO 'rate' VALUES (1, '1.jpg', 15, 20, 75, 2);INSERT INTO 'rate' VALUES (2, '2.jpg', 3, 5, 60, 0);INSERT INTO 'rate' VALUES (3, '3.jpg', 3, 5, 60, 1);INSERT INTO 'rate' VALUES (4, '4.jpg', 0, 0, 0, 0);INSERT INTO 'rate' VALUES (5, '5.jpg', 13, 15, 87, 3);INSERT INTO 'rate' VALUES (6, '6.jpg', 3, 5, 60, 1);INSERT INTO 'rate' VALUES (7, '7.jpg', 7, 10, 70, 2);INSERT INTO 'rate' VALUES (8, '8.jpg', 4, 5, 80, 1);[/code]i know what insert into means n all but the values n all i dont get.thanx for readingPudgemeister Quote Link to comment https://forums.phpfreaks.com/topic/15712-noob-needing-help-once-again/#findComment-64180 Share on other sites More sharing options...
trq Posted July 26, 2006 Share Posted July 26, 2006 What do you want us to do with it? Quote Link to comment https://forums.phpfreaks.com/topic/15712-noob-needing-help-once-again/#findComment-64188 Share on other sites More sharing options...
Pudgemeister Posted July 27, 2006 Author Share Posted July 27, 2006 [quote][b][u]i need to know the correct code for all this-and also i need to know what certain parts of the code actually mean [/u] [/b] [b][u]ok the parts i need to know bout are:[/u] [/b] [code][email protected] table for picture[/code][code]PRIMARY KEY ('id'),UNIQUE KEY 'imagename' ('imagename')[/code][code]TYPE=MyISAM AUTO_INCREMENT=9 ;[/code][code]-- -- Dumping data for table 'rate'-- [/code] [code]INSERT INTO 'rate' VALUES (1, '1.jpg', 15, 20, 75, 2);INSERT INTO 'rate' VALUES (2, '2.jpg', 3, 5, 60, 0);INSERT INTO 'rate' VALUES (3, '3.jpg', 3, 5, 60, 1);INSERT INTO 'rate' VALUES (4, '4.jpg', 0, 0, 0, 0);INSERT INTO 'rate' VALUES (5, '5.jpg', 13, 15, 87, 3);INSERT INTO 'rate' VALUES (6, '6.jpg', 3, 5, 60, 1);INSERT INTO 'rate' VALUES (7, '7.jpg', 7, 10, 70, 2);INSERT INTO 'rate' VALUES (8, '8.jpg', 4, 5, 80, 1);[/code]i know what insert into means n all but the values n all i dont get.[/quote]did u even read my post????neway yeh plz help people Quote Link to comment https://forums.phpfreaks.com/topic/15712-noob-needing-help-once-again/#findComment-64597 Share on other sites More sharing options...
wildteen88 Posted July 27, 2006 Share Posted July 27, 2006 The following:[code][email protected] table for picture[/code]isnt a valid MySQL command, seems to be placed in the wrong place.The code:[code]PRIMARY KEY ('id'),UNIQUE KEY 'imagename' ('imagename')[/code]Sets up a the id field to be a primary key. Each table should at least have a primary key. The next line sets the imagename field to be unique. It stops you from adding duplicate images into the database, for example if you have an image called holiday.jpg already in the database you cannot have another image called holiday.jpgThis bit of code:[code]TYPE=MyISAM AUTO_INCREMENT=9 ;[/code]Sets the engine for the table, and tells mysql where to start to auto incrementing from, in this case 9.This is an SQL comment:[code]-- -- Dumping data for table 'rate'-- [/code]A comment is code that does't get excuted - just like the HTML comment tags (<!-- comment here -->), but without the triangular brackets.This inserts the data into their respective fileds for the rate table:[code]INSERT INTO 'rate' VALUES (1, '1.jpg', 15, 20, 75, 2);INSERT INTO 'rate' VALUES (2, '2.jpg', 3, 5, 60, 0);INSERT INTO 'rate' VALUES (3, '3.jpg', 3, 5, 60, 1);INSERT INTO 'rate' VALUES (4, '4.jpg', 0, 0, 0, 0);INSERT INTO 'rate' VALUES (5, '5.jpg', 13, 15, 87, 3);INSERT INTO 'rate' VALUES (6, '6.jpg', 3, 5, 60, 1);INSERT INTO 'rate' VALUES (7, '7.jpg', 7, 10, 70, 2);INSERT INTO 'rate' VALUES (8, '8.jpg', 4, 5, 80, 1);[/code]So for this line:[code]INSERT INTO 'rate' VALUES (1, '1.jpg', 15, 20, 75, 2);[/code]It'll insert number 1 into the id field, 1.jpg into the imagename field15 into the userrate field20 into the maxrate field75 into the ratepercent field2 into the views field of the rate table.It'll do that for each INSERT INTO clause.I havn't gone into much detail, but just skimmed the surface, I would recommend you to go through the SQL Tutorials over at [url=http://www.w3schools.com/sql/sql_intro.asp]w3schools.com[/url] in order to understand the SQL syntax better. Also prehaps go through the tutoials over at [url=http://www.php-mysql-tutorial.com/]php-mysql-tutorial.com/[/url] in order to learn how to use PHP and MySQL together. Quote Link to comment https://forums.phpfreaks.com/topic/15712-noob-needing-help-once-again/#findComment-64610 Share on other sites More sharing options...
Pudgemeister Posted July 27, 2006 Author Share Posted July 27, 2006 thanx for showing me what those parts meant.now if only someone would be kind enough to show me the little errors in it so it will do what i want it to without ne hiccups-cant be THAT much wrong with it? Quote Link to comment https://forums.phpfreaks.com/topic/15712-noob-needing-help-once-again/#findComment-64621 Share on other sites More sharing options...
trq Posted July 27, 2006 Share Posted July 27, 2006 i think you misunderstand the point of this forum. This forum is for people wanting help learning php.If you just want stuff fixed, hire a programmer. Quote Link to comment https://forums.phpfreaks.com/topic/15712-noob-needing-help-once-again/#findComment-64636 Share on other sites More sharing options...
Pudgemeister Posted July 27, 2006 Author Share Posted July 27, 2006 oh i c-yes i did misunderstand that detail-sorry.i shall post in the appropriate forum then-thanx Quote Link to comment https://forums.phpfreaks.com/topic/15712-noob-needing-help-once-again/#findComment-64650 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.