Jump to content

[SOLVED] What is wrong with this code?


sanderphp

Recommended Posts

I'm getting a "Parse error: syntax error, unexpected T_STRING in /home/sanderan/public_html/php/cycling/singlerecord.php on line 25" error on the echo ('results[0] line.

I had this working before but not sure what I changed.

 

 

if(count($results)){
echo('.$results[0]['id'].'  '.$results[0]['date'].' '.$results[0]['total_distance'] '.$results[0]['total_time']  '.$results[0]['ave_speed'].');

}else{
echo('Sorry - no result found');
}

Link to comment
https://forums.phpfreaks.com/topic/106233-solved-what-is-wrong-with-this-code/
Share on other sites

 

<?php
if(count($results)){
echo('.$results[0]['id'].'  '.$results[0]['date'].' '.$results[0]['total_distance'] '.$results[0]['total_time']  '.$results[0]['ave_speed'].');

}else{
echo('Sorry - no result found');
}
?>

 

to

 

<?php
if(count($results)){
$sp=" ";
echo($results[0]['id'] .$sp. $results[0]['date'].$sp.$results[0]['total_distance'].$sp.$results[0]['total_time'].$sp.$results[0]['ave_speed']}.$sp);

}else{
echo('Sorry - no result found');
}
?>

 

(the colour coding here will, hopefully, help you see what you did wrong in the first case).

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.