Forum Moderators: coopster

Message Too Old, No Replies

Parsing error I can't solve

         

Sandd

10:28 am on Sep 14, 2007 (gmt 0)

10+ Year Member



I query a MySQL table for $row['gender'] which returns b or g depending on the value of the gender field. I can echo the that back and it looks fine. However, when I put that into an IF statement, I get a parse error

"Parse error: syntax error, unexpected T_IS_EQUAL in....line 9."

What's wrong with my syntax? THANKS!

1 $result = mysql_query("SELECT * FROM teamdata");
2 if (!$result) {
3 echo("<p>Error performing query: " . mysql_error() . "</p>");
4 exit();
5 }
6
7 while ($row = mysql_fetch_array($result)) {
8
9 if ($row['gender']) == 'b' {
10 $gender = 'Boys';
11 } else {
12 $gender = 'Girls';
13 }

Receptional Andy

10:29 am on Sep 14, 2007 (gmt 0)



Line 9 appears to have the closing bracket in the wrong place:

if ($row['gender']) == 'b' {

to

if ($row['gender'] == 'b') {

Little_G

10:30 am on Sep 14, 2007 (gmt 0)

10+ Year Member



Hi,

You have a close bracket missing at the end of your if statement on line 9.

Andrew

[edit]We're quick here aren't we![/edit]

[edited by: Little_G at 10:31 am (utc) on Sep. 14, 2007]

Sandd

10:36 am on Sep 14, 2007 (gmt 0)

10+ Year Member



Never mind. Stupid mistake of mine, need to move the ) to the other side. Doh!

Sandd

10:37 am on Sep 14, 2007 (gmt 0)

10+ Year Member



Didn't see your post replies before my 2nd.

THANK YOU!

g1smd

11:04 am on Sep 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I find with these sort of errors that you can stare at them all day and not see the typo, but if you do something else and then come back to it the next day it suddenly becomes very obvious what the problem is... usually.