Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > PHP + Access Error: Warning: (null)(): Invoke() failed: Exception occurred.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-25-07, 15:46
mstng07 mstng07 is offline
Registered User
 
Join Date: Oct 2007
Posts: 27
PHP + Access Error: Warning: (null)(): Invoke() failed: Exception occurred.

Okay so here is my source code that submits the form to the database

Code:
<?php require("config.php"); if($_GET['action'] == 'post') { if($_POST['Employee_ID'] != '') { $ret = $db_conn->Execute("SELECT * FROM analyzer_query WHERE Employee_ID = '{$_POST['Employee_ID']}") or die("Error validating Employee ID"); $itemfields = Count("Employee_ID"); if ($itemfields <= 1) { error("user"); exit; } } if(empty($_POST['Employee_ID']) || empty($_POST['Date']) || empty($_POST['Activity']) || empty($_POST['Miles'])) { //if everything is not filled in than prints out error message error("blank"); exit; } else $db_conn->Execute("INSERT INTO Activity_Log (`Employee_ID`, `Date`, `Activity`, `Miles`) VALUES ('{$_POST['Employee_ID']}', '{$_POST['Date']}', '{$_POST['Activity']}', '{$_POST['Miles']}')") or die("Error in connecting to the database"); header("Location: success.php?action=success"); } function error($error) { //if error is equal to blank if($error == 'blank') { echo "Please fill in all the required fields before submitting"; } //if error is equal to blank if($error == 'user') { echo "Please fill in the correct Employee ID"; } } ?>

with the config file
Code:
<?php $db_conn = new COM("ADODB.Connection"); $connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("./Copy of HR Employee Wellness Program.mdb").";"; $db_conn->open($connstr); ?>


and now here is the error i'm getting

Code:
Warning: (null)(): Invoke() failed: Exception occurred. Source: Microsoft OLE DB Provider for ODBC Drivers Description: [Microsoft][ODBC Microsoft Access Driver] Syntax error in string in query expression 'Employee_ID = 'ff'. in F:\InetPub\wwwroot\EmployeeWellnessProgram\WellnessSubmit.php on line 9 Error validating Employee ID

Can anyone help me because i'm absolutely clueless. ???
Reply With Quote
  #2 (permalink)  
Old 10-26-07, 08:23
dimis2500 dimis2500 is offline
Registered User
 
Join Date: Jan 2005
Posts: 337
Code:
$ret = $db_conn-> Execute("SELECT * FROM analyzer_query WHERE Employee_ID = '{$_POST['Employee_ID']}") or die("Error validating Employee ID");
I see a " ' " more at
Code:
'{$_POST['Employee_ID']}")
,
are you sure it have to be there??
Look for errors like that.
Reply With Quote
  #3 (permalink)  
Old 10-26-07, 08:49
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 13,556
microsoft access does not recognize mysql's proprietary `backticks`

also, access is much more rigorous about when you are allowed to quote numeric literals -- i.e. never

this might be allowed in mysql --

... where Employee_ID = '937'

but in access you would have to say --

... where Employee_ID = 937

__________________
r937.com | rudy.ca

pre-order my book Simply SQL from Amazon
Reply With Quote
  #4 (permalink)  
Old 10-26-07, 10:08
mstng07 mstng07 is offline
Registered User
 
Join Date: Oct 2007
Posts: 27
well how do i do the check when i'm getting the information from the form?

Employee_ID = {$_POST['Employee_ID']} ?? or what?

Well tried that and got this
Code:
Warning: (null)(): Invoke() failed: Exception occurred. Source: Microsoft OLE DB Provider for ODBC Drivers Description: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2. in F:\InetPub\wwwroot\EmployeeWellnessProgram\WellnessSubmit.php on line 9 Error validating Employee ID

again
Reply With Quote
  #5 (permalink)  
Old 10-26-07, 20:29
Frunkie Frunkie is offline
Gives Bad Advice
 
Join Date: Mar 2007
Location: 010101010110100
Posts: 706
Quote:
Originally Posted by mstng07
well how do i do the check when i'm getting the information from the form?

Employee_ID = {$_POST['Employee_ID']} ?? or what?

Well tried that and got this
Code:
Warning: (null)(): Invoke() failed: Exception occurred. Source: Microsoft OLE DB Provider for ODBC Drivers Description: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2. in F:\InetPub\wwwroot\EmployeeWellnessProgram\WellnessSubmit.php on line 9 Error validating Employee ID

again

Why not fix your connection issue before you start on form validation..

dimis2500 is correct, you have one too many single quotes in this string:

Code:
$ret = $db_conn-> Execute("SELECT * FROM analyzer_query WHERE Employee_ID = '{$_POST['Employee_ID']}") or die("Error validating Employee ID");

Put another single quote after the closing curly bracket in the Employee_ID var. (See post# 2 for details)
__________________
I and many others around the world are of the strong belief that the universe was created by the Flying Spaghetti Monster. It was He who created all that we see and all that we feel. We feel strongly that the overwhelming scientific evidence pointing towards evolutionary processes is nothing but a coincidence, put in place by Him.
Reply With Quote
  #6 (permalink)  
Old 10-29-07, 05:45
aschk aschk is offline
Registered User
 
Join Date: Mar 2007
Location: 636f6d7075746572
Posts: 734
Still using the COM object eh... My advice, ditch that and use odbc. You'll rue the day that the COM object changes
You probably want some reasoning to my madness :
The COM object is NOT part of PHP and thus you relying on an external object to perform your functions. PHP is only acting as an intepreter here. Therefore, any changes to your COM object will not be changes to PHP, so you may find one day that it stops working or performs irregularly. Also bear in mind that PHP may alter the way that it works with COM objects. You have two points of failure here. If you use PHP only you are ruling out one of those...
Reply With Quote
  #7 (permalink)  
Old 10-30-07, 10:45
mstng07 mstng07 is offline
Registered User
 
Join Date: Oct 2007
Posts: 27
Yeah well I'd switch if I weren't in so deep already so to speak. I got everything working now except where it checks to see if the user is in the database or not. I'm going to try to eliminate the errors i'm getting with it and just do a login page.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On