<?php //this is your default page for your unprotected directories $ip = $_SERVER["REMOTE_ADDR"]; include 'config.php'; //edit the location of your logging file or MySQL database in the config.php //set the date $v_date = date("l d F H:i:s"); print "<table width='500' align='center' border='1'><tr><td>"; print "<table width='100%'><tr><td bgcolor='#C8D4DF'>"; echo "<center><font face='Verdana'><h3>Unauthorized Access Warning Message</h3></font>"; print "</td></tr>"; print "<tr><td bgcolor='#FFF0C0'>"; print "<center><h3>You should not be here</h4><p>"; print "</td></tr>"; print "<tr><td bgcolor='#FFF0C0'>"; echo "<center><font size='2' face='Verdana'>Your IP address is ". $ip . " and has been logged</font><p>"; echo "$v_date<p>"; echo "<center><font size='1' face='Verdana'><strong>You will be redirected to an authorized page.</strong></font>"; print "</td></tr></table></td></tr></table>"; //open the MySQL database and write to the table mysql_connect('localhost', 'username', 'password') or die('Database will not open'); mysql_select_db('test'); // Insert a row of information into the table "example" mysql_query("INSERT INTO iplog (ip, date) VALUES($ip, $v_date) ") or die(mysql_error()); echo "Data logged successfully!<br />"; ?>
When I try to execute this I get this error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' Sunday 16 July 14:39:48)' at line 2
However, line 2 has nothing to do with the date. I'm using MySQL 5.0.21 with XAMP. Any ideas why this is happening? Or, perhaps what the proper syntax would be to insert the date? Thanks in advance for your help!