Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

Can I get some php help. Not sure where to post this.


  • Please log in to reply

#1
Pwdrin

Pwdrin

    New Member

  • Member
  • Pip
  • 3 posts
I am working on a project in school and need some help.

This is the code I have got:
<?phpecho
// Include the database connection file.

if($_GET['debug']=='testmode') // add ?debug=testmode for diagnostics
{
	$debugit=1;
	$debugpar='?debug=testmode';
}
else
{
	$debugit=0;
	$debugpar='';
}

The error I am getting is:
Parse error: syntax error, unexpected T_IF in /home/***/public_html/project/calculator.php on line 4

Does anybody understand why it is not working. The only thing I can understand is the it doesn't notice the closing and opening tag.

Edited by Pwdrin, 06 January 2009 - 03:41 AM.

  • 0

Advertisements


#2
Kieran C

Kieran C

    Member

  • Member
  • PipPip
  • 51 posts
Is that the whole file?

At the start you have <?phpecho. You don't need an echo statement there, just <?php goes at the start of the script - always.

That's why there is an unexpected if statement in the error.

You also have no ending tag (?>), if that is the whole file.

Edited by Kieran C, 06 January 2009 - 05:02 AM.

  • 0

#3
Pwdrin

Pwdrin

    New Member

  • Topic Starter
  • Member
  • Pip
  • 3 posts
No it isn't but thanks. I had got it working then tried adding more into it. And messed it up, I have changed it from <?phpecho and it seems to work. Thanks, shame my teacher can't help :)
  • 0

#4
Kieran C

Kieran C

    Member

  • Member
  • PipPip
  • 51 posts
No problem. echo is a PHP statement used to write text/HTML on a page. Just be sure to leave a space between the PHP opening tag and statements. :)

Edited by Kieran C, 06 January 2009 - 08:13 AM.

  • 0

#5
Pwdrin

Pwdrin

    New Member

  • Topic Starter
  • Member
  • Pip
  • 3 posts
Actually sorted that out quite easy, I read my error more through lol.

The '.' error is on line 227. Would somebody help as I am totally stuck.

while ($i< $num ) // For every row
	{
		// Get the car details to show on the screen
		$output .= 'Annual Carbon Footprint (KgCO2) = ' . ($co2ingrams / 1000 + $co2inkgpublictrans + $totalflying); . '<br>'
		$output .= 'Annual Carbon Footprint due to car only = ' . ($co2ingrams / 1000); . '<br>'
		$output .= 'Annual Carbon Footprint due to public transport only = ' . ($co2inkgpublictrans); .'<br>'
		$output .= 'Annual Carbon Footprint due to flying only = '. ($totalflying); . '<br>'
		$output = 'Car Type ' . mysql_result($result,$i,"Description") . '<br>';
		$output .='Transmission ' . mysql_result($result,$i,"Transmission") . '<br>';
A few lines before and after.

Line 227 is line4 there,
$output .= 'Annual Carbon Footprint (KgCO2) = ' . ($co2ingrams / 1000 + $co2inkgpublictrans + $totalflying); . '<br>'

Edited by Pwdrin, 13 January 2009 - 03:53 AM.

  • 0

#6
Kieran C

Kieran C

    Member

  • Member
  • PipPip
  • 51 posts
Have you defined the $output variable before the while statement?

If not, just remove the full stop, like this. I also changed a few things - you had the semicolons in the wrong spots.

while ($i< $num ) // For every row
	{
		// Get the car details to show on the screen
		$output = 'Annual Carbon Footprint (KgCO2) = ' . ($co2ingrams / 1000 + $co2inkgpublictrans + $totalflying) . '<br>';
		$output .= 'Annual Carbon Footprint due to car only = ' . ($co2ingrams / 1000) . '<br>';
		$output .= 'Annual Carbon Footprint due to public transport only = ' . ($co2inkgpublictrans) .'<br>';
		$output .= 'Annual Carbon Footprint due to flying only = '. ($totalflying) . '<br>';
		$output .= 'Car Type ' . mysql_result($result,$i,"Description") . '<br>';
		$output .='Transmission ' . mysql_result($result,$i,"Transmission") . '<br>';

Should be fine now. :)
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP