Hey guys,
The following code doesn't work. On similar pages I haven't been able to access tables using two seperate connects. I know for most of you MySQL is your strongest suit, but I've found they're fairly similar sans the function names. (significant code included only)
<?php
while (list($key, $val) = @each($HTTP_POST_VARS)) {
$GLOBALS[$key] = $val;
}
function Output_Entries($AGSNumID, $LearnDesc, $Completed, $DateStart, $DateComp, $LearnComment)
{
if(!$LearnDesc){ $LearnDesc = 'N/A'; }
if(!$Completed){ $Completed = 'N/A'; }
if(!$DateStart){ $DateStart = 'N/A'; }
if(!$DateComp){ $DateComp = 'N/A'; }
if(!$LearnComment){ $LearnComment = 'N/A'; }
// Insert Variables into table
$AGSNum=$AGSNumID;
$cnx = odbc_connect( 'AHW' , 'root', '' );
if(!$cnx) {
Error_handler( "Error in odbc_connect" , $cnx );
}
$cur= odbc_exec( $cnx, "Insert into TblLearnPlan (AGSNum, LearnDesc, Completed, DateStart, DateComp, LearnComment) values ('$AGSNum', '$LearnDesc', '$Completed', '$DateStart', '$DateComp', '$LearnComment');" );
if (!$cur) {
Error_handler( "Error in odbc_exec( no cursor returned ) " , $cnx );
}
odbc_close( $cnx);
// Display variables in a table
$cnx = odbc_connect( 'AHW' , 'root', '' );
if(!$cnx) {
Error_handler( "Error in odbc_connect" , $cnx );
}
$cur= odbc_exec( $cnx, "select AGSNum, LearnDesc, Completed, DateStart, DateComp, LearnComment from TblLearnPlan WHERE AGSNum='$AGSNum' AND LearnDesc='$LearnDesc';");
odbc_fetch_row( $cur );
$AGSNum= odbc_result( $cur, 1 );
$LearnDesc= odbc_result( $cur, 2 );
$Completed= odbc_result( $cur, 3 );
$DateStart= odbc_result( $cur, 4 );
$DateComp= odbc_result( $cur, 5 );
$LearnComment= odbc_result( $cur, 6 );
if( ! $cur ){
Error_handler( "Error in odbc_exec( no cursor returned ) " , $cnx );
}
echo "
<table border=1>
<p><h3><u>Learning Plan Details</u><h3><BR>
<table><tr><td>AGS Number:</td><td>$AGSNum</td></tr>
<tr><td>Learning Plan Description:</td><td>$LearnDesc</td></tr>
<tr><td>Has it been Completed?:</td><td>$Completed</td></tr>
<tr><td>Date Started:</td><td>$DateStart</td></tr>
<tr><td>Date Completed:</td><td>$DateComp</td></tr>
<tr><td>Learning Plan Comments:</td><td>$LearnComment</td></tr>
</table>
<INPUT type=\"Submit\" value=\"Update\">
</form>\n
<p>
<a href=\"Main.php\">Return to the main screen</a><p>
<a href=\"Modify.php\">Return to the Modify AHW Details screen</a>
";
odbc_close( $cnx);
}
The error I'm getting is:
Warning: SQL error: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression., SQL state 22005 in SQLExecDirect in C:\Program Files\Apache Group\Apache2\htdocs\TEST\minifini\InsertLearnR.php on line 57
As an aside, the following SQL code doesn't work for me either.
"select Completed, DateStart, DateComp, LearnComment from TblLearnPlan WHERE AGSNum='$AGSNumID' AND LearnDesc='$LearnDescID'"