Jump to content

Noob Needing Help Once Again.


Pudgemeister

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.