PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
guymclaren
Forum Newbie
Posts: 11 Joined: Tue Feb 17, 2009 10:53 pm
Post
by guymclaren » Thu Mar 19, 2009 6:50 am
Code: Select all
$sqlq="SELECT * FROM depts";
$objRS = mysql_query($sqlq);
while($row = mysql_fetch_array($objRS, MYSQL_ASSOC)) {
echo "<tr><td width=155><img src=images/{$row['image']} width=150 height=100></td><td width 425><table width=425><tr><td>{$row['Name']}</td><td align=right>{$row['CODE']}</td></tr><tr><td colspan=2>{$row['description']}";
$sqlc="SELECT * FROM cats WHERE dept={$row['CODE']} ";
$objRSc = mysql_query($sqlc);
while($rowa = mysql_fetch_array($objRSc, MYSQL_ASSOC)){
echo "{$rowa['name']"." ";} //line 32
echo "</td></tr></table></td></tr>";
}
The logic above makes sense to me but does not work, Who wants to tell me why I am being stupid?
The result is as follows.
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting '}' in /var/www/vhosts/laeveldbou.co.za/httpdocs/catalogue/index.php on line 32
papa
Forum Regular
Posts: 958 Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm
Post
by papa » Thu Mar 19, 2009 7:08 am
$sqlc="SELECT * FROM cats WHERE dept= ".$row['CODE'];
Is the first thing I see.
guymclaren
Forum Newbie
Posts: 11 Joined: Tue Feb 17, 2009 10:53 pm
Post
by guymclaren » Thu Mar 19, 2009 7:15 am
No thats not the problem..... It has to do with the nesting. I am busy trying to see exactly where it breaks.commenting each line.
papa
Forum Regular
Posts: 958 Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm
Post
by papa » Thu Mar 19, 2009 7:18 am
You are not closing your second while loop.
guymclaren
Forum Newbie
Posts: 11 Joined: Tue Feb 17, 2009 10:53 pm
Post
by guymclaren » Thu Mar 19, 2009 7:44 am
Thanks, That was one of the errors. the other was here
Code: Select all
$sqlc="SELECT * FROM cats WHERE dept= '".$row['CODE']."'";