note 60871 added to function.odbc-exec

From: Date: Wed, 18 Jan 2006 21:36:52 +0000
Subject: note 60871 added to function.odbc-exec
Groups: php.notes 
Request: Send a blank email to php-notes+get-102064@lists.php.net to get a copy of this message
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. ---- Server IP: 12.160.245.96Probable Submitter: 162.95.80.214 (proxied: 1.0 webproxy01 (NetCache NetApp/5.6.2), inw2kws02, 1.0 webproxy01 (NetCache NetApp/5.6.2)) ---- Manual Page -- http://www.php.net/manual/en/function.odbc-exec.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60871 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60871&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60871&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60871&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60871&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60871&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60871&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60871&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60871&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#102064) next »