View Full Version : Publish weird problem, can't understand what's causing it.

12-12-2006, 01:31 AM

I'm having a strange problem on my application, and I can't understand what could possibly cause what I'm about to explain:

I'll try to be brief, and as much abstract as possible,but it's kind of complicated.

I have a ComboBox with 13 items in it. Based on the user selection the appropriate form shows up next to it (the form is created dynamically from mySQL). If the user completes the form without errors a value of true will be sent to a database. If there are discrepancies in the form however, a value of false is sent to the same table, and all the discrepancies are stored in an Array and then sent to another table as well. When I test the app from flash everything works great, but when I test it from the published html/swf it's not quite working. The weird thing is that if you select the first value in the combo box an put errors on purpose in its related form, nothing is going to the database, not the false value, nor the array with the discrepancies. However, if you do the same thing with any another form from any item in the combobox, everything works without any issue. I assume that the flash script is fine, since it works perfectly when tested on the IDE, and perfectly when published as long as you dont fill out the form related to the first combobox item. For the same reason I'm also assuming that the problem doesn't lie in php or mySQL.

If anyone of you would be so kind to help I can send the source. In the meantime I'll post the function I'm using to send data to php and the php function that it's supposed to store thta data in mySQL

Here they are:

function sendInventory() {
var aInventory:Array = new Array();
var aCount:Array = new Array();
var aQty:Array = new Array();
var aMake:Array = new Array();
var aModel:Array = new Array();
var aIn:Array = new Array();

for (var i:Number = 0; i < _root.inventory_mc.dataGrid.length; i++) {
aInventory.push(_root.inventory_mc.dataGrid.getIte mAt(i).sQty);
aCount.push(_root.inventory_mc.dataGrid.getItemAt( i).sIn)
if (aCount[i] != aInventory[i]) {
aQty.push(_root.inventory_mc.dataGrid.getItemAt(i) .sQty);
aMake.push(_root.inventory_mc.dataGrid.getItemAt(i ).sMake);
aModel.push(_root.inventory_mc.dataGrid.getItemAt( i).sModel);
aIn.push(_root.inventory_mc.dataGrid.getItemAt(i). sIn);
var serializer:Serializer = new Serializer();
var Qty:Object = serializer.serialize(aQty);
var Make:Object = serializer.serialize(aMake);
var Model:Object = serializer.serialize(aModel);
var Count:Object = serializer.serialize(aIn);
invLV.qty = Qty;
invLV.make = Make;
invLV.model = Model;
invLV.count = Count;
invLV.session_id = relativeID;
trace (aQty.length)
if (aQty.length == 0) {
invLV.check = "true"
} else {
invLV.check = "false";
invLV.action = "addInventory";
invLV.sendAndLoad(php_path + "/scripts/securityLog.php", invLV, "GET");


the PHP side:

// add Inventory
function addInventory($qty, $make, $model, $count, $session_id, $check) {
if(get_magic_quotes_gpc()) {
$qty = stripslashes($qty);
$make = stripslashes($make);
$model = stripslashes($model);
$count = stripslashes($count);

$aQty = unserialize($qty);
$aMake = unserialize($make);
$aModel = unserialize($model);
$aCount = unserialize($count);

$query = "UPDATE sessions SET check_inv = '$check' WHERE id='$session_id'";

for ($i = 0; $i < count($aQty); $i++) {
$query = "INSERT INTO inventoryLog VALUES (NULL, '$aQty[$i]', '$aMake[$i]', '$aModel[$i]', '$aCount[$i]', '$session_id')";
if(!$query) {
return "msg=" . mysql_error();
} else {
return "msg=ok";

I really have no idea what's going on, and I also have no way to test it from flash since it's working fine from there. I hope it make some sort of sense. Please, any help would be greatly apreciated. This project is very important for me.

Sorry for the long post, Thanks for your time!

12-12-2006, 09:08 AM
Ok I found the problem! It's an http issue. Basically the form associated with the values in the cb is a list of items that the user has to counts. if the numbers don't match every item miscounted is placed into an array, serialized, and sent to PHP. When I was testing I wasn't counting any item in the list list at all. Therefore, the serialized array ended up being a very very long string that apparently apache is not able to handle. I tried using both GET and POST, but I still have the same problem. Is there any another solution or I have to think another way to send that data to PHP?
Honestly, I could leave everything as it is, since the users are supposed to count everything (and if there's a mismatch it's gonna be most likely on a couple of items and not all 47) and this super long string is generated only by one value in the cb not all 13, but I really don't like to have this sort of bug, so any help would be really appreciated.