...

View Full Version : PHP & AJAX request



bsydz2
01-29-2007, 01:06 AM
This is driving me nuts...
using the scriptalicious library to handle an ajax request, and the serialized array i'm passing to the php page (via POST) isn't being parsed properly by the foreach loop i have in place. It works perfectly on two testing environments, and on a different host, so i think i may just need to set a variable in my php,ini, but i can't figure it out...

the javascript function i'm using on the first page is below:
function updateOrder(){
var options = {
method : 'post',
parameters : Sortable.serialize('item_list')
};

new Ajax.Request('reorder.php', options);
}

the php page:
<? my connection string ?>
<?
$i=1;
foreach($_POST['item_list'] as $key=>$value) {
$q_order = "UPDATE table SET the_order = ".$i." WHERE id =".$value;
mysql_query($q_order, $db->query);
$i++;
}
?>

Someone had suggested exploding what should be an array on the php page into an array itself (implying perhaps the posted value was being interpreted as a string instead of an array), but that didn't work.

Any help or insight at all would be huge.
Thanks in advance.

meth
01-29-2007, 02:31 AM
Upload a file to the problematic server called phpinfo.php with the following code:



<?php phpinfo(); ?>


Do a search on the resulting page for 'register_globals'. I'll bet it's set to 'Off'.

Should this be the case, recode to declare your variables properly or upload a htaccess file with the following directive override:



php_value register_globals 1



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum