Hello again all,
I have recently updated some of my server side PHP files to use $_POST insted of $_GET and everything seemed to be working fine however I must have done something (although Im not sure what since I hav’nt worked on these files in a while) because now I keep getting the following when ever I try to perform any operations:
Error type: LoadXML Description: Wrong XML
When I load the connector page directly I get:
[b]
Contents of $_POST:
Array()
Contents of $_GET:
Array()
// nothing is being passed in either get or post??
( ! ) Notice: Undefined index: ids in C:\wamp\www\resources\lib\cons\mySettings\areaPreferences_gridUpdateV2.php on line 125
Call Stack
#TimeMemoryFunctionLocation
10.0010403544{main}( )…\areaPreferences_gridUpdateV2.php:0
( ! ) Notice: Undefined index: !nativeeditor_status in C:\wamp\www\resources\lib\cons\mySettings\areaPreferences_gridUpdateV2.php on line 129
Call Stack
#TimeMemoryFunctionLocation
10.0010403544{main}( )…\areaPreferences_gridUpdateV2.php:0
( ! ) Notice: Undefined index: _Preference_Level in C:\wamp\www\resources\lib\cons\mySettings\areaPreferences_gridUpdateV2.php on line 48
Call Stack
#TimeMemoryFunctionLocation
10.0010403544{main}( )…\areaPreferences_gridUpdateV2.php:0
20.0178875056update_row( )…\areaPreferences_gridUpdateV2.php:142
( ! ) Notice: Undefined index: _Area_Code in C:\wamp\www\resources\lib\cons\mySettings\areaPreferences_gridUpdateV2.php on line 48
Call Stack
#TimeMemoryFunctionLocation
10.0010403544{main}( )…\areaPreferences_gridUpdateV2.php:0
20.0178875056update_row( )…\areaPreferences_gridUpdateV2.php:142
[/b]
You’ll notice that both the $_GET and $_POST arrays seem to be empty which is causing everything else to collaps in a heap of Undefined index errors
my data processor is set up as follows:
areaDataProcessor = new dataProcessor ("resources/lib/cons/mySettings/areaPreferences_gridUpdateV2.php");
// create an action to show an error message to the user in the event of a problem
areaDataProcessor.defineAction("error",function (response){
var message = response.getAttribute("message")
alert ("The following error occoured while attempting an area grid operation" + " "+message);
return false
});
areaDataProcessor.enableDataNames(true);
areaDataProcessor.init(areaGrid);
my server side dataprocessor script looks like so:
session_start();
// check that the user is autherised
if (!(($_SESSION['Authorised'] == true) && ($_SESSION['User_Level']) >= 1 )) {
header("Location:index.php");
}
// check that the user has been properly autherised and redirect to the index if not
define('CONFIG_PATH', $_SERVER['DOCUMENT_ROOT'] . '/resources');
require_once (CONFIG_PATH . '\config.php');
require_once(LIBRARY_PATH . '\queries\class.db.proqueries.php');
// include all files required for database connection and queries
$host = $dbConfig ['dbSettings']['mysql']['host'];
$dbName = $dbConfig ['dbSettings']['mysql']['dbname'];
$userName = $dbConfig ['dbSettings']['mysql']['username'];
$pwd = $dbConfig ['dbSettings']['mysql']['password'];
// create variables for connection settings.from config file
$dbConnection = new Proc_Query($host, $dbName, $userName, $pwd);
if (!(isset($_SESSION ['ID']))){
echo "Error while updating area preferences: No user id passed in SESSION variable";
exit();
}
// a global variable to hold the id of any new record
$tid = "";
// create db connection and query class using config settings
/*
* A function to perform a preference update on a given area using data passed
* via the dataprocessor
* @param a Proc_Query object to create a connection and perform the updat query
* @return a string value representing the process status
*/
function update_row($dbConnection,$rowId) {
try {
$dbConnection-> updateVisitiorAreaPrefs($_SESSION['ID'],$_POST[$rowId.'_Preference_Level'], $_POST[$rowId.'_Area_Code']);
}
catch (Exception $e){
echo "The following error occoured while attempting to set area preference" .
" " . $e->getMessage() .
" " . "In file" .
" " . $e->getFile() .
" " . "on line" .
" " . $e->getLine();
exit();
}
return "update";
}
/*
* A function to remove a given student based on data passed from the dataprocessor
@param a Proc_Query object to create a connection and perform the delete query
* @return a string value representing the process status
*/
function delete_row($dbConnection,$rowId) {
try {
$dbConnection-> removeVisitiorAreaPref($_SESSION['ID'] , $_POST[$rowId.'_Area_Code']);
}
catch (Exception $e){
echo "The following error occoured while attempting to delete an preference" .
" " . $e->getMessage() .
" " . "In file" .
" " . $e->getFile() .
" " . "on line" .
" " . $e->getLine();
exit();
}
return "delete";
}
/*
* A function to add a given palcement selection for a vistior based on data passed from the dataprocessor
* @param a Proc_Query object to create a connection and perform the add query
* @return a string value representing the process status
*/
function add_row($dbConnection,$rowId) {
global $tid;
try {
$dbConnection->addAreaPreference($_POST[$rowId.'_Area_Code'], $_POST[$rowId.'_Preference_Level'],$_SESSION['ID']);
}
catch (Exception $e){
echo "The following error occoured while attempting to set placement preference" .
" " . $e->getMessage() .
" " . "In file" .
" " . $e->getLine() .
" " . "on line" .
" " . $e->getLine();
exit();
}
$tid =$_POST['Placement_ID'];
return "insert";
}
//include XML Header (as response will be in xml format)
header("Content-type: text/xml");
echo('<?xml version="1.0" encoding="iso-8859-1"?>');
//output update results
echo "<data>";
// explode the id string passed in the post
print_r($_POST);
$ids = explode(",",$_POST["ids"]);
//for each id strings row loop
for ($i=0; $i < sizeof($ids); $i++) {
$rowId = $ids[$i]; //id or row which was updated
$mode = $_POST[$rowId."_!nativeeditor_status"]; //get request mode
// switch to the appropreate operation based on the mode passed.
switch($mode){
case "inserted":
//row adding request
$action = add_row($dbConnection,$rowId);
break;
case "deleted":
//row deleting request
$action = delete_row($dbConnection,$rowId);
break;
default:
//row updating request
$action = update_row($dbConnection,$rowId);
break;
}
echo "<action type='".$action."' sid='".$rowId."' tid='".$tid."'/>";
}
echo "</data>";
?>
Can anyone see any problems? I’ve been sat here since 10:00 am on a Saturday trying to work out where Ive messed up.
Can anyone help?
Thanks in advance.