Hi All-
I'm trying to work out a php+javascript setup I am working on. Its raw and ugly but thats besides the point 😃
<?
include 'vars.php';
$db_link = mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db(contentmanagement, $db_link);
$query = mysql_query("select data from news where id = '$GET[id]'");
$response = mysql_fetch_array($query);
$blah = "$response[data]";
switch($GET['action'] && $GET[id]) {
case 'foo&$GET[id]':
echo "foo|$blah";
break;
default:
echo 'foo|error';
break;
}
?>
when the above code is executed with the proper URL variables on the page its written into it works fine. However when I use it as a callback component in an AJAX type script I'm writing it won't display $blah as defined under the switch statement. If I change $blah to any non-variable such as "phpbuilder" the callback works. I thought perhaps the switch statement was a global variable (nothing noted about it being one in the PHP.net manual) so I defined $blah as such and I'm still not having any luck.
Here's the javascript processing code just in case it lends any insight:
function createRequestObject() {
var ro;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
ro = new ActiveXObject("Microsoft.XMLHTTP");
}else{
ro = new XMLHttpRequest();
}
return ro;
}
var http = createRequestObject();
function sndReq(action) {
http.open('get', 'rpc.php?action='+action);
http.onreadystatechange = handleResponse;
http.send(null);
}
function sndReqArg(action,id) {
http.open('get', 'rpc.php?action='+action+'&id='+id);
http.onreadystatechange = handleResponse;
http.send(null);
}
function handleResponse() {
if(http.readyState == 4){
var response = http.responseText;
var update = new Array();
if(response.indexOf('|' != -1)) {
update = response.split('|');
document.getElementById(update[0]).innerHTML = update[1];
}
}
}
TIA-
Drew-