954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Parse error, unexpected T_STRING on line 26, but I don't see it

<?
$connect = mysql_connect("localhost", "adamf", "adamf123") or
die ("Wrong password, jerk.");

mysql_select_db ("adamf");

$insert="INSERT INTO product (product_id, product_name, product_type, product_brand, product_year)
VALUES (1, 'Cyber', 1, 1, 2001),
(2, 'Motive', 8, 1, 2005),
(3, 'Oracle', 8, 2, 2005)";
$results = mysql_query($insert)
or die(mysql_error());

$type="INSERT INTO producttype (producttype_id, producttype_label)
VALUES (1, 'Heads'),
(2, 'Shafts'),
(3, 'Helmets'),
(4, 'Gloves'),
(5, 'Arm Pads'),
(6, 'Shoulder Pads'),
(7, 'Stringing'),
(8, 'New'),
$results=mysql_query($type)
or die(mysql_error());

echo "Data inserted successfully!";
?>

okay, line 26 is the "echo "Data inserted successfully!"; line, so, my guess is the line above it has the error. However, I don't see what the heck it could be. I'm pretty much copying this out of the wrox book "PHP, Apache, MySQL Web Developement", just with different words and other such things, so it isn't a movie site. I've probably looked at this for 20 minutes, could anybody tell me what's wrong?

raine
Newbie Poster
1 post since Jul 2004
Reputation Points: 10
Solved Threads: 0
 

[PHP]<?
$connect = mysql_connect("localhost", "adamf", "adamf123") or
die ("Wrong password, jerk.");

mysql_select_db ("adamf");

$insert="INSERT INTO product (product_id, product_name, product_type, product_brand, product_year)
VALUES (1, 'Cyber', 1, 1, 2001),
(2, 'Motive', 8, 1, 2005),
(3, 'Oracle', 8, 2, 2005)";
$results = mysql_query($insert)
or die(mysql_error());

$type="INSERT INTO producttype (producttype_id, producttype_label)
VALUES (1, 'Heads'),
(2, 'Shafts'),
(3, 'Helmets'),
(4, 'Gloves'),
(5, 'Arm Pads'),
(6, 'Shoulder Pads'),
(7, 'Stringing'),
(8, 'New')";
$results=mysql_query($type)
or die(mysql_error());

echo "Data inserted successfully!";
?>[/PHP]

According to your error, in your code you forgot to put "; in the end of $type sentence. Hope it works. If this is not, insert data row by row.

PoA
Posting Whiz in Training
237 posts since Jul 2004
Reputation Points: 26
Solved Threads: 9
 

Good answer. I solved my problem too.

biscovaldo
Newbie Poster
2 posts since Jun 2009
Reputation Points: 10
Solved Threads: 0
 
Good answer. I solved my problem too.


I'm sure he heard you. By the way, can I borrow your necronomicon so I can resurrect the dead as well? Come on, this thread is over 5 years old

ShawnCplus
Code Monkey
Team Colleague
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 268
 
I'm sure he heard you. By the way, can I borrow your necronomicon so I can resurrect the dead as well? Come on, this thread is over 5 years old


I'm just new at online foruns.

Probably he will not hear me, but oder IT curious like me will see the answer. I'm not a IT professional. Just learning a little bit.

See you.

biscovaldo
Newbie Poster
2 posts since Jun 2009
Reputation Points: 10
Solved Threads: 0
 

In fact, it helped me now ;) this should be the meaning of an online forum, to give solutions to anyone passing by.,.
Hey, I'm also interested in the necronomicon... after it will be in my hands, the world will be ruled by IT professionals!!!! MUAHAHAHAHAHA

thirdeye
Newbie Poster
1 post since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

I agree with thirdeye and so does Google since this was the #1 result on page 1 when I searched for this error. New is not always the answer when tried and true is available.

thriftgirl62
Light Poster
26 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

St. Louis Cardinals


Player
Team
Pos
G
AB
R
H
2B
3B
HR
RBI
BB
SO
SB
CS
AVG

<?php

//loop though all the records

while ($row = mysql_fetch_array($result))

{

echo "";

echo "" . $row['player'] . "";

echo "" . $row['team'] . "";

echo "" . $row['pos'] . "";

echo "" . $row['g'] . "";

echo "" . $row['ab'] . "";

echo "" . $row['r'] . ""

echo "" . $row['h'] . ""

echo "" . $row['2b'] . ""

echo "" . $row['3b] . ""

echo "" . $row['hr'] . ""

echo "" . $row['rbi'] . ""

echo "" . $row['bb'] . ""

echo "" . $row['so'] . ""

echo "" . $row['sb'] . ""

echo "" . $row['cs'] . ""

echo "" . $row['avg'] . ""


echo "";

}

//wipe out result data and close connection

mysql_free_result($result);

mysql_close();

?>

Derrion1989
Newbie Poster
1 post since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

St. Louis Cardinals


Player
Team
Pos
G
AB
R
H
2B
3B
HR
RBI
BB
SO
SB
CS
AVG

<?php

//loop though all the records

while ($row = mysql_fetch_array($result))

{

echo "";

echo "" . $row['player'] . "";

echo "" . $row['team'] . "";

echo "" . $row['pos'] . "";

echo "" . $row['g'] . "";

echo "" . $row['ab'] . "";

echo "" . $row['r'] . ""

echo "" . $row['h'] . ""

echo "" . $row['2b'] . ""

echo "" . $row['3b] . ""

echo "" . $row['hr'] . ""

echo "" . $row['rbi'] . ""

echo "" . $row['bb'] . ""

echo "" . $row['so'] . ""

echo "" . $row['sb'] . ""

echo "" . $row['cs'] . ""

echo "" . $row['avg'] . ""


echo "";

}

//wipe out result data and close connection

mysql_free_result($result);

mysql_close();

?>

thriftgirl62
Light Poster
26 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

bwahahaha the dead has been resurrected again ha ha

vaultdweller123
Posting Pro
554 posts since Sep 2009
Reputation Points: 42
Solved Threads: 75
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You