Folks any help is appreciated,
What I have is a script which processes the results of a Flash movie and passes them into a database
in order to encode the variables that are coming out of the POST I have setup two arrays one for each table
for the two tables then I use these arrays to build the strings for the sql statements
for Emps table
For ResponsePst Table
after having tried most things I know the error message I am getting are:
"Invalid argument supplied for foreach() " and
"odbc_exec(): supplied argument is not a valid ODBC-Link resource in"
Now I'm guessing the the first error causes the second error.
The sql I am getting out of the script is:
sqluser = INSERT INTO Emps () VALUES (); for Emps and
SQLResp =INSERT INTO ResponsePst (R_id,,dateString) VALUES ('_, 'December 1 - 2004 - 11:27 am'); for ResponsePst Table
The question is how do I fix the first error? Would need to use 1 large array to extract info from the POST data then split it up somehow.
The Start of wisdom is to realise you know nothing. I'll be a genius then!
What I have is a script which processes the results of a Flash movie and passes them into a database
in order to encode the variables that are coming out of the POST I have setup two arrays one for each table
Code:
$userFields_array=array("PayRef","Fname","Lname","Est");
$responseFields_array=array("PayRef","Code","ELquest1","ELquest2","ELquest3","ELquest4","ELquest5","ELquest6","ELquest7","ELquest8","ELquest9","ELquest10","ELquestComm","PstLO1","PstLO2","PstLO3","PstLO4","PstLO5","PstLO6","PstLO7","PstLO8","PstLOComm","TI1","TI2","TI3","TI4","TI5","TI6","TI7","TI8","TIComm","TF1","TF1Comm","TF2","TF2Comm");
for the two tables then I use these arrays to build the strings for the sql statements
for Emps table
Code:
//set up sql fragments
$sqluserA="INSERT INTO Emps (";
$sqluserB="";
$sqluserC=") VALUES (";
$sqluserD="";
$sqluserE=");";
// get vars out of post data, compile list of field names
foreach ($UserFields_array as $key => $value) {
$sqluserB=$sqluserB.$value.",";
$sqluserD=$sqluserD."'".htmlentities($_POST[$value], ENT_QUOTES)."',";
}
// tidy ends of loop compiled strings
$sqluserB=substr($sqluserB,0,-1);
$sqluserD=substr($sqluserD,0,-1);
// concatenate sql string
$sqluser=$sqluserA.$sqluserB.$sqluserC.$sqluserD.$sqluserE;
$rs=odbc_exec($con,$sqluser);
echo "sqluser = ".$sqluser."<br/>";
if($rs){
$retVal = 1;
}else{
$retVal=0;
}
return $retVal;
}
For ResponsePst Table
Code:
//set up sql fragments
echo "insertR called";
$sqlRespA="INSERT INTO ResponsePst (R_id,";
$sqlRespB="";
$sqlRespC=",dateString) VALUES ('".$_POST[payRef]."_".$_POST[Code];
$sqlRespD="";
$sqlRespE=", '".date("F j - Y - g:i a")."');";
// get vars out of post data, compile list of field names
foreach($ResponseFields_array as $key => $value) {
$sqlRespB=$sqlRespB.$value.",";
$sqlRespD=$sqlRespD."'".htmlentities($_POST[$value], ENT_QUOTES)."',";
}
// tidy ends of loop compiled strings
$sqlRespB=substr($sqlRespB,0,-1);
$sqlRespD=substr($sqlRespD,0,-1);
// concatenate sql string
$sqlResp=$sqlRespA.$sqlRespB.$sqlRespC.$sqlRespD.$sqlRespE;
$rs=odbc_exec($con,$sqlResp);
echo "SQLResp =".$sqlResp."<br/>";
if($rs){
$retVal = 1;
}else{
$retVal=0;
}
return $retVal;
}
after having tried most things I know the error message I am getting are:
"Invalid argument supplied for foreach() " and
"odbc_exec(): supplied argument is not a valid ODBC-Link resource in"
Now I'm guessing the the first error causes the second error.
The sql I am getting out of the script is:
sqluser = INSERT INTO Emps () VALUES (); for Emps and
SQLResp =INSERT INTO ResponsePst (R_id,,dateString) VALUES ('_, 'December 1 - 2004 - 11:27 am'); for ResponsePst Table
The question is how do I fix the first error? Would need to use 1 large array to extract info from the POST data then split it up somehow.
The Start of wisdom is to realise you know nothing. I'll be a genius then!