Forum Moderators: coopster

Message Too Old, No Replies

PHP with ADODB and MS Access Form Question

         

bcourt07

10:24 pm on Nov 8, 2007 (gmt 0)

10+ Year Member



I have a form where users enter information to put into an MS Access database. I need to verify that the user exists.

here is my code


<?php
require("config.php");
$Employee_ID = $_POST["Employee_ID"];
if($_GET['action'] == 'post')
{

if(empty($_POST['Employee_ID']) ¦¦ empty($_POST['Date']) ¦¦ empty($_POST['Activity']) ¦¦ empty($_POST['Miles']))
{
error("blank"); //Prints out error message if fields are blank
exit;
}
if(!empty($_POST['Employee_ID']))
{
$query="SELECT Employee_ID FROM analyzer_query WHERE Employee_ID = $Employee_ID";
$rs = $conn->execute($query);
$num_columns = $rs->Fields->Count();
}
if($rs <= 0)
{
echo error ("user"); //Prints out error message if invalid user
exit;
}
else
{
$conn->execute("INSERT INTO Activity_Log (`Employee_ID`, `Date`, `Activity`, `Miles`) VALUES ('{$_POST['Employee_ID']}', '{$_POST['Date']}', '{$_POST['Activity']}', '{$_POST['Miles']}')");
// header("Location: success.php?action=success");
}
}
function error($error)
{
if($error == 'blank')
{ //blank error
echo "Please fill in all the required fields before submitting";
} //user error
if($error == 'user')
{
echo "Please fill in the correct Employee ID";
}
}
?>

Can someone please help me? I'm at a loss with this and i need it done ASAP! Any help would be greatly appreciated!

jatar_k

2:19 pm on Nov 9, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld bcourt07,

can you explain how it isn't working.

do you get an error? does it just do nothing?

bcourt07

2:36 pm on Nov 9, 2007 (gmt 0)

10+ Year Member



Thanks for the welcome!

Well here are the errors i'm getting


Warning: (null)(): Invoke() failed: Exception occurred. Source: Microsoft OLE DB Provider for ODBC Drivers Description: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1. in F:\InetPub\wwwroot\EmployeeWellnessProgram\WellnessSubmit.php on line 15

Fatal error: Call to a member function on a non-object in F:\InetPub\wwwroot\EmployeeWellnessProgram\WellnessSubmit.php on line 16

here is my config.php file also


<?php $conn = new COM ("ADODB.Connection") or die("Cannot start ADO");
$connStr = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=F:\Wellness Program\Copy of HR Employee Wellness Program.mdb;";
$conn->open($connStr); //Open the connection to the database
?>

jatar_k

5:15 pm on Nov 9, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



the key to fixing it is understanding the error message

what is Invoke()?

bcourt07

7:15 pm on Nov 9, 2007 (gmt 0)

10+ Year Member



I have no idea...I'm new to this so i'm clueless basically. i've tried searching for a solution and i come up with nothing.

jatar_k

7:22 pm on Nov 9, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I can't find anything of that name on php.net, unless I am getting old ;)

my guess would be that is a function somewhere in your code

try searching for that function in your files and take a look at it. It seems to be saying that it didn't get the appropriate number of parameters when called.

my other guess is that something in between is failing silently and causing nothing to be sent to the Invoke function