Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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....

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

![]() |
![]() |
![]() |

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