0

I am working on getting active users on a localhost server. While I came up with an error. I am providing the portion which is not working in PHP MySQL:

I changed $REMOTE_ADDR, $PHP_SELF to $_SERVER['$REMOTE_ADDR'], $_SERVER['PHP_SELF'] as those are old version of PHP. Still not getting expected result.

$timestamp = time();

//insert the values
$insert = mysql_db_query($database, " INSERT INTO mytable VALUES('$timestamp', $_SERVER['$REMOTE_ADDR'], $_SERVER['PHP_SELF'] )" );

the error goes like this:

Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in G:\xampp\htdocs\jencyphp\liveonline\online.php on line 21

Raptor
  • 53,206
  • 45
  • 230
  • 366
Jency
  • 269
  • 1
  • 13

1 Answers1

0

Can you please check by doing this. You are missing database table fields name in query so you must need to add that fields.

$timestamp = time();

$insert = mysql_db_query($database, "INSERT INTO mytable (`field1`,`field2`,`field3`) VALUES('".$timestamp."','".$_SERVER['REMOTE_ADDR']."','".$_SERVER['PHP_SELF']."')");
Rajdip Chauhan
  • 345
  • 2
  • 11