Jump to content

syntax error, unexpected T_STRING


PhpxZ

Recommended Posts

Nothing wrong with the code you have shown, its likely before that piece.

 

Here is the full code

 

	while ($row = mysql_fetch_array($result)) {
	if ($row['reason'] == NULL) {
		$count = true;
		echo '<div style="margin:5px;padding:15px;';
		if ($bright) {
			echo 'background-color:#f4f3f0;border:1px solid #a0a0a0';
			$bright = false;
		}
		else {
			echo 'background-color:#e5ecf9;border:1px solid #9da9bf';
			$bright = true;
		}
		$accid = $row['accid'];
		$result2 = mysql_query('SELECT * FROM accounts WHERE id='. $accid .'');
		$row2 = mysql_fetch_array($result2);
		$accNAME = $row2['name'];
		if($row['submited'] != NULL){
		$submited = $row['submited'];
		} else {
		$submited = "informacijos n?ra";
		}
		$metai = date('Y') - $row['age'];
		echo '"> <p align="right">Date: '.$submited.'</p>
<b>Character Name:</b> '. $row['charname'] .'<br /> 
  if($row['sex'] == 1) {

<b>Sex:</b> Male<br />
}
else{
<b>Sex:</b> Female<br />
}
<b>Age:</b> '. $row['age'] .' (' .$metai. ')<br /><br />

 

 

 

I get the error for the line

 

if($row['sex'] == 1) {

You can't have an if statement in the middle of an echo statement like that.

You can do this:
<?php
echo '"> <p align="right">Date: '.$submited.'</p>
<b>Character Name:</b> '. $row['charname'] .'<br /><b>Sex:</b> ' . (($row['sex'] == 1)?'Male':'Female') . '<br /><b>Age:</b> ';
?>

 

Ken

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.