-3

Hey friends today I am trying to save user id,date or browser but it is not working...... everytime when I upload my script to my hosting site say syntax error

<?php
$file = fopen(‘log.html’, ‘a’);
fwrite( $file, ‘<b>Ip Address:</b> $REMOTE_ADDR<br/>’);
fwrite( $file, ‘<b>Browser:</b> $HTTP_USER_AGENT<hr/>’);
fclose( $file );
?>
Pogrindis
  • 6,978
  • 5
  • 28
  • 41

2 Answers2

1

You are using the wrong kind of single quotes. Try this instead:

<?php
$file = fopen('log.html', 'a');
fwrite( $file, '<b>Ip Address:</b> $REMOTE_ADDR<br/>');
fwrite( $file, '<b>Browser:</b> $HTTP_USER_AGENT<hr/>');
fclose( $file );
?>
Klaus Byskov Pedersen
  • 111,411
  • 28
  • 180
  • 220
1

PHP strings may be quoted with U+0022 : QUOTATION MARK (") or U+0027 : APOSTROPHE ('), you are using U+2018 : LEFT SINGLE QUOTATION MARK, which is not allowed (HEREDOC and NOWDOC are also valid options, but not ones which make sense in this context).

Quentin
  • 857,932
  • 118
  • 1,152
  • 1,264