Jump to content

Error with insert statement


andrew_ww

Recommended Posts

Hello,

 

the following code is producing 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 '', ipaddress='1.1.1.1'' at line 1

 

<?php
// Get MySQL connection
require_once('required/connection.php');
  $dateTimePageOpened = date("Y-m-d H:i");
  $pageOpened = $_SERVER['REQUEST_URI'];
  $ipaddress = $_SERVER['REMOTE_ADDR'];
  $sessionvar = $_SESSION['auth'];

  $sql = "INSERT INTO tbl_log SET";
  $sql .= " dateTimeOpened='$dateTimepageOpened";
  $sql .= ", page='$pageOpened'";
  $sql .= ", ipaddress='$ipaddress'";
$sql .= ", sessionvar='$sessionvar'";

  mysql_query($sql);
    $Result = mysql_query($sql, $DII) or die(mysql_error());

?>

Link to comment
https://forums.phpfreaks.com/topic/52642-error-with-insert-statement/
Share on other sites

Thanks the missing single quote has fixed it (nearly...)

 

While the code is sending information to the database, the datetime field is being updated as this : 0000-00-00 00:00:00

 

Any suggestions as to why the true time / date is not being updated.

 

thanks again.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.