note 60871 deleted from function.odbc-exec by betz
| From: | betz@php.net | Date: | Wed, 18 Jan 2006 21:43:10 +0000 |
| Subject: | note 60871 deleted from function.odbc-exec by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-102065@lists.php.net to get a copy of this message | ||
Note Submitter: Rob at WellPoint INC
----
I am relatively new to using PHP (about a year) and I am having some trouble with an ODBC Error I
have been receiving when using the sql command INSERT INTO... I have used this in other webpages and
it has worked, but this one always seems to fail.
Here is the Error:
"[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement."
For what it's worth, here's the code:
<?php
$inpt = file("times.txt");
foreach($inpt as $data)
{
trim($data);
list($realTime, $timeNum) = explode(",", $data);
$timeArr[$realTime] = $timeNum;
}
$defaultReason = "Please enter a reason for this request";
$agent = $_POST['userid'];
$daytype = $_POST['dayType'];
$reqtype = $_POST['reqType'];
$fromdate = $_POST['fromdate'];
$thrudate = $_POST['thruDate'];
$startTime = $_POST['start_time'];
$endTime = $_POST['end_time'];
$reason = $_POST['reason'];
if(($reason == $defaultReason) || ($reason ==""))
$reason = "Not Specified";
$connID = odbc_connect(SCHEDULEDB2, "wfmweb", "timeoff");
if($connID)
{
if($daytype == "Full")
{
$hrs = 8;
$sql = "INSERT INTO full_day_off (userID,from,thru,dayType,reqType,numHrs,reason) VALUES
('$agent', '$fromdate', '$thrudate', '$daytype',
'$reqtype', '$hrs', '$reason')";
$res = odbc_do($connID, $sql);
if(odbc_error())
{
print odbc_errormsg();
print "<br>Full Day<br>";
print "If this problem continues, please notify the <a href='mailto:me@myisp.com?subject=wfm_errors'>site
administrator.</a>";
}
else
{
print "Your request was successfully submitted to the database";
print "<p><a href='../home.shtml'>Click here</a> to return to
the main page.";
}
}
else // daytype is Partial
{
$hrs = $timeArr[$endTime] - $timeArr[$startTime];
$sql = "INSERT INTO partial_day_off (userID,reqdate,from,thru,dayType,reqType,numHrs,reason)
VALUES ('$agent', '$fromdate', '$startTime', '$endTime',
'$daytype', '$reqtype', '$hrs', '$reason')";
$res = odbc_do($connID, $sql);
if(odbc_error())
{
print odbc_errormsg();
print "<br>PartialDay<br>";
print "If this problem continues, please notify the <a href='mailto:me@myisp.com?subject=auction_errors'>site
administrator.</a>";
}
else
{
print "Your request was successfully submitted to the database";
print "<p><a href='../home.shtml'>Click here</a> to return to
the main page.";
}
}
}
else
{
print "Unable to add your request to the database. Please try adding your request
again.<br>";
print "If this problem continues, please notify the <a href='mailto:me@myisp.com?subject=wfm_errors'>site
administrator.</a>";
}
?>
I would appreciated any assistance on this. Thanks.