Parse error: syntax error, unexpected '>' in E:\test\test2.php on

i keep geting the following error and have tried everything i know (which is not much)
can some one tell me what is wrong
Parse error: syntax error, unexpected ‘>’ in E:\test\test2.php on line 11
this is the code :

<?php $dts = new DateTime(); echo ($dts); //open up the log file $file = fopen("log.html",‘a’); //write the time of access //fwrite($file, ‘ Time: $dts,
‘ ); //write users name fwrite ($file, ‘ name: $access
'); //write the users IP address fwrite( $file, ‘Ip Address: $REMOTE_ADDR
’); //write out the page that sent them here fwrite($file, ‘Referer: $HTTP_REFFERER
’); //write the users browser details fwrite( $file, ‘Browser: $HTTP_USER_AGENT
’); //and finial, close the log file fclose( $file ); ?>

Did you read the error?

The issue is on line 11 which a quick glance shows that you used a ‘ instead of an ’

Also if you use an ’ instead of " you will need to wrap your PHP variables in ’ . $var . ’ - see code below.

[PHP]

<?php $dts = new DateTime(); echo ($dts); //open up the log file $file = fopen("log.html",'a'); //write the time of access //fwrite($file, ‘ Time: $dts,
‘ ); //write users name fwrite ($file, ' name: ' . $access . '
'); //write the users IP address fwrite( $file, 'Ip Address: ' . $REMOTE_ADDR . '
'); //write out the page that sent them here fwrite($file, 'Referer: ' . $HTTP_REFFERER . '
'); //write the users browser details fwrite( $file, 'Browser: ' . $HTTP_USER_AGENT . '
'); //and finial, close the log file fclose( $file ); ?>

[/PHP]

Yes, I agree with Scott… You need to understand what a “back-tick” quote is compared to a single-quote.
Here is an explanation for you from Stackoverflow which might help explain it…

1.In MySQL, backticks quote names, while single quotes create strings. If you have a column called select, MySQL would throw an syntax error when using this name without backticks -- like in SELECT select FROM foo -- as it would interpret it as keyword which may not occur there.

2.This IF function can be used as a column specification in SELECT statements. See the MySQL reference.

3.This function returns the value from the default column, if value is the empty string. Else it returns the value from value itself. The result will be called value. See the MySQL reference for details.


The MySQL reference they talked about is:
http://dev.mysql.com/doc/refman/5.1/en/control-flow-functions.html

SO, REMEMBER, a back-tick is NOT a single-quote!

Sponsor our Newsletter | Privacy Policy | Terms of Service