Jump to content

If Statement Syntax


Skipjackrick

Recommended Posts

Is there something wrong here?

 

I can't figure this out.  Looks perfectly normal to me?

 

<?php
if ( $results['team_id'] == 0 ) 
{
$team .= 'Not Specified';
} 
     else 
{
$queryteam = "SELECT 
                       *
                       FROM team
                       WHERE team_id={$results['team_id']}
                       ";
$result = mysql_query($queryteam) or die(mysql_error());

$team = mysql_fetch_assoc($result)
}
?>

Link to comment
https://forums.phpfreaks.com/topic/189462-if-statement-syntax/
Share on other sites

This part is iffy

 

$team .= 'Not Specified';

 

You're appending values to the $team variable by using .=

but in the else statement you are not.

 

Which leads me to believe you need $team = ""; somewhere above that code. Do You?

 

No, I am not using that above.... I see what you mean.

Link to comment
https://forums.phpfreaks.com/topic/189462-if-statement-syntax/#findComment-1000065
Share on other sites

Dang, I found it...too quick to post.....

 

However, I am thankful that you noticed my appending variable..  I didn't mean to do that.

 

The answer....

I was missing a semicolon below.....

 

 

$team = mysql_fetch_assoc($result)

Link to comment
https://forums.phpfreaks.com/topic/189462-if-statement-syntax/#findComment-1000074
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.