Page 1 of 1

Insert Statement error (with ms access db)

Posted: Wed Jul 13, 2005 10:24 am
by funsutton
I get the following error message, and I don't understand where it is coming from. Can anyone help?

Code: Select all

Fatal error: Uncaught exception 'com_exception' with message 'Source: Microsoft JET Database Engine
Description: Syntax error in INSERT INTO statement.' in F:\web\websites\fia\home\logger1.php:35 
Stack trace: #0 F:\web\websites\fia\home\logger1.php(35): 
com->Execute('INSERT INTO log...') #1 {main} thrown in F:\web\websites\fia\home\logger1.php on line 35

Here is the code:

Code: Select all

<? 
$ipaddress = $_SERVER["REMOTE_ADDR"];
$url = $_SERVER["PHP_SELF"];	
if ($url == "/") {
	$url = "/index.html";
	}
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$date = (date ("F j, Y, g:i:s a"));
$nologip = array("");
$browser = $_SERVER["HTTP_USER_AGENT"];
$time = time();
$search = "search.msn.com";
$resultmsn = strpos($browser, $search);
$searchgoogle = "bot";
$resultgoogle = strpos($browser, $searchgoogle);
$searchyahoo = "Yahoo! Slurp";
$resultyahoo = strpos($browser, $searchyahoo);
$searcharchiver = "archiver";
$resultarchiver = strpos($browser, $searcharchiver);
$searchcrawler = "crawler";
$resultcrawler = strpos($browser, $searchcrawler);
$searchjeeves = "Jeeves";
$resultjeeves = strpos($browser, $searchjeeves);

  if ((in_array($ipaddress, $nologip)) OR ($resultmsn !== false) OR ($resultgoogle !== false) OR ($resultyahoo !== false) OR ($resultarchiver !== false) OR ($resultcrawler !== false) OR ($resultjeeves !== false))  {
  		echo "";
	}
$db = 'f:\web\databases\fia\log.mdb';
$conn = new COM ("ADODB.Connection") or die( "Cannot start ADO" ); 
$conn->Open( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=".$db );
$sql = "INSERT INTO log (Hostname,Page,Date,Browser,Referer,Timestamp) VALUES('$hostname','$url','$date','$browser','$referer','$time')";
$rs = $conn->Execute( $sql );
$conn->Close(); //Close database connection 
$conn->Release(); //Release resources for this connection 
?>

Posted: Wed Jul 13, 2005 2:31 pm
by pickle
Output $sql before it's executed and I'll bet it won't look exactly like you think it should.