Jump to content

Archived

This topic is now archived and is closed to further replies.

Pudgemeister

Noob Needing Help Once Again.

Recommended Posts

Hi All

Someone 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
                                                                                              string

whenever 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 all

Pudgemeister

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
[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.

Share this post


Link to post
Share on other sites
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]<?php

include ("dbinfo.inc.php");
$sql = "CREATE TABLE rate (
'id' bigint(20) NOT NULL auto_increment,
'imagename' varchar(255) NOT NULL default '',
thispudge004@gmail.com 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);

$result

TYPE=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-lol

i 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]thispudge004@gmail.com 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 reading

Pudgemeister

Share this post


Link to post
Share on other sites
What do you want us to do with it?

Share this post


Link to post
Share on other sites
[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]thispudge004@gmail.com 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

Share this post


Link to post
Share on other sites
The following:
[code]thispudge004@gmail.com 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.jpg

This 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 field
15 into the userrate field
20 into the maxrate field
75 into the ratepercent field
2 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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
oh i c-yes i did misunderstand that detail-sorry.

i shall post in the appropriate forum then-thanx

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.