Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.