xman51
06-21-2005, 03:04 PM
Hello All,
I have part of a PHP page I am trying to write which i want it to write information to a database. I have the odbc system dsn created on my machine. And I was able to execute a simple "Select * From" Clause using the same source, but this sql statement i have in the code below is giving me all sorts of trouble:
<html>
<body>
<?php
$userIP=$_SERVER["REMOTE_ADDR"];
$DateStr=date("l dS of F Y h:i:s A");
$FlashVer="Flash V6";
$BrowseVer=$_SERVER["HTTP_USER_AGENT"];
$conn=odbc_connect('FlashStats','','');
if (!$conn)
{
exit("Connection Failed: " . $conn);
}
$sql="INSERT INTO [Jun 2005] (IPAddress, DateTime, Flashversion, Browserversion) " .
"VALUES ('$userIP', '$DateStr', '$FlashVer', '$BrowseVer') ";
echo $sql;
$rs=odbc_exec($conn,$sql);
if (!$rs)
{
exit("Error in SQL");
}
?>
</body>
</html>
And here is the output in the browser:
INSERT INTO [Jun 2005] (IPAddress, DateTime, Flashversion, Browserversion) VALUES ('127.0.0.1', 'Tuesday 21st of June 2005 09:57:46 AM', 'Flash V6', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)')
Warning: SQL error: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement., SQL state 37000 in SQLExecDirect in c:\phpdev\www\test\odbc.php on line 21
Error in SQL
Does anyone know what the hell this means and how to fix it?!?!? :confused:
Thanks in advance,
Xman51
I have part of a PHP page I am trying to write which i want it to write information to a database. I have the odbc system dsn created on my machine. And I was able to execute a simple "Select * From" Clause using the same source, but this sql statement i have in the code below is giving me all sorts of trouble:
<html>
<body>
<?php
$userIP=$_SERVER["REMOTE_ADDR"];
$DateStr=date("l dS of F Y h:i:s A");
$FlashVer="Flash V6";
$BrowseVer=$_SERVER["HTTP_USER_AGENT"];
$conn=odbc_connect('FlashStats','','');
if (!$conn)
{
exit("Connection Failed: " . $conn);
}
$sql="INSERT INTO [Jun 2005] (IPAddress, DateTime, Flashversion, Browserversion) " .
"VALUES ('$userIP', '$DateStr', '$FlashVer', '$BrowseVer') ";
echo $sql;
$rs=odbc_exec($conn,$sql);
if (!$rs)
{
exit("Error in SQL");
}
?>
</body>
</html>
And here is the output in the browser:
INSERT INTO [Jun 2005] (IPAddress, DateTime, Flashversion, Browserversion) VALUES ('127.0.0.1', 'Tuesday 21st of June 2005 09:57:46 AM', 'Flash V6', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)')
Warning: SQL error: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement., SQL state 37000 in SQLExecDirect in c:\phpdev\www\test\odbc.php on line 21
Error in SQL
Does anyone know what the hell this means and how to fix it?!?!? :confused:
Thanks in advance,
Xman51