Computing.Net > Forums > Programming > unexpected T_FOREACH - PHP ERROR

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

unexpected T_FOREACH - PHP ERROR

Reply to Message Icon

Name: NooK
Date: November 5, 2007 at 07:51:22 Pacific
OS: WinXP Pro
CPU/Ram: 2GB
Product: Asus Clone
Comment:

I have been trying to display data from my wholsalers database onto my website. I feel I'm getting close, but once you fix one error, its on to the next. Im not a coder just learning PHP for the first time.

My Code:

<?php
$connect = mysql_connect ("localhost", "root", "") or die(mysql_error());
mysql_select_db("scpricelist") or die(mysql_error());
?>

<?php
mysql_select_db("scpricelist");
$query = "SELECT ProductTitle FROM pricelist WHERE PartNum = '90-PN513CE-00100'";
$results = mysql_query($query)
or die(mysql_error());
while ($record = mysql_fetch_assoc($results)foreach ($record as $value)
echo "$value";
}
?>

Basically all im trying to do is, diplay product info in my catalogue. I keep getting this error.

Parse error: syntax error, unexpected T_FOREACH in C:\wamp\www\catalog.php on line 49

LINE49
echo "$value";

What am i doing wrong, this can't be that hard....



Sponsored Link
Ads by Google

Response Number 1
Name: NooK
Date: November 5, 2007 at 09:54:41 Pacific
Reply:

PLEASE SEE THIS POST TOO, RELATED:
http://www.computing.net/webdevel/w...


0

Response Number 2
Name: SN
Date: November 6, 2007 at 21:51:56 Pacific
Reply:

You're missing some punctuation and have an extraneous bracket in there:

mysql_select_db("scpricelist");
$query = "SELECT ProductTitle FROM pricelist WHERE PartNum = '90-PN513CE-00100'";
$results = mysql_query($query)
or die(mysql_error());
while ($record = mysql_fetch_assoc($results))
foreach ($record as $value)
echo "$value";


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: unexpected T_FOREACH - PHP ERROR

PHP error www.computing.net/answers/programming/php-error/11806.html

PHP error on page and Can't figure it out www.computing.net/answers/programming/php-error-on-page-and-cant-figure-it-out/19250.html

problem with date() function in PHP www.computing.net/answers/programming/problem-with-date-function-in-php/8855.html