-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
  • 7,755
  • 5
  • 31
  • 44

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
  • 117,245
  • 29
  • 183
  • 222
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
  • 914,110
  • 126
  • 1,211
  • 1,335