Jump to content


Photo

Noob Needing Help Once Again.


  • Please log in to reply
9 replies to this topic

#1 Pudgemeister

Pudgemeister
  • Members
  • PipPipPip
  • Advanced Member
  • 94 posts
  • LocationCornwall, England, UK,

Posted 26 July 2006 - 04:32 PM

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:

include ("dbinfo.inc.php");

CREATE TABLE `rate` (
  'id' bigint(20) NOT NULL auto_increment,

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

[div align="center"][a href="http://imageshack.us" target="_blank"][/a]
[/div]

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 26 July 2006 - 04:37 PM

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:
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);


#3 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 26 July 2006 - 04:38 PM

ThisThis[/url] might help you. Php is a programming language, explaining snippets of it will not help you.

#4 Pudgemeister

Pudgemeister
  • Members
  • PipPipPip
  • Advanced Member
  • 94 posts
  • LocationCornwall, England, UK,

Posted 26 July 2006 - 05:09 PM

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:

<?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);

?>

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:

thispudge004@gmail.com table for picture

PRIMARY KEY  ('id'),
UNIQUE KEY 'imagename' ('imagename')

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);

i know what insert into means n all but the values n all i dont get.

thanx for reading

Pudgemeister
[div align="center"][a href="http://imageshack.us" target="_blank"][/a]
[/div]

#5 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 26 July 2006 - 05:16 PM

What do you want us to do with it?

#6 Pudgemeister

Pudgemeister
  • Members
  • PipPipPip
  • Advanced Member
  • 94 posts
  • LocationCornwall, England, UK,

Posted 27 July 2006 - 11:24 AM

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:

thispudge004@gmail.com table for picture

PRIMARY KEY  ('id'),
UNIQUE KEY 'imagename' ('imagename')

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);

i know what insert into means n all but the values n all i dont get.



did u even read my post????

neway yeh plz help people
[div align="center"][a href="http://imageshack.us" target="_blank"][/a]
[/div]

#7 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 27 July 2006 - 11:49 AM

The following:
thispudge004@gmail.com table for picture
isnt a valid MySQL command, seems to be placed in the wrong place.

The code:
PRIMARY KEY  ('id'),
UNIQUE KEY 'imagename' ('imagename')
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:
TYPE=MyISAM AUTO_INCREMENT=9 ;
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:
-- 
-- Dumping data for table 'rate'
--
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:
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);
So for this line:
INSERT INTO 'rate' VALUES (1, '1.jpg', 15, 20, 75, 2);
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 w3schools.com in order to understand the SQL syntax better. Also prehaps go through the tutoials over at php-mysql-tutorial.com/ in order to learn how to use PHP and MySQL together.

#8 Pudgemeister

Pudgemeister
  • Members
  • PipPipPip
  • Advanced Member
  • 94 posts
  • LocationCornwall, England, UK,

Posted 27 July 2006 - 12:41 PM

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?
[div align="center"][a href="http://imageshack.us" target="_blank"][/a]
[/div]

#9 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 27 July 2006 - 01:34 PM

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.

#10 Pudgemeister

Pudgemeister
  • Members
  • PipPipPip
  • Advanced Member
  • 94 posts
  • LocationCornwall, England, UK,

Posted 27 July 2006 - 02:09 PM

oh i c-yes i did misunderstand that detail-sorry.

i shall post in the appropriate forum then-thanx
[div align="center"][a href="http://imageshack.us" target="_blank"][/a]
[/div]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users