PDA

View Full Version : Issue with Loadvar: php timeout...?!!?


Xman51
06-29-2005, 02:51 PM
Hello All,

I am having an issue with my php timing out, I don't understand why. I have made this type of adodb connection string before and it worked fine.

Here is my AS:

var DrawnArr:Array = new Array();

function checkValue(val:Number,arr:Array):Boolean{
for(var i=0;i<arr.length;i++){
if(arr[i]==val){
return true;
}
}
return false;
}

//=================================
// INIT
//=================================
var path = "http://localhost/kikaijin/"; //declare path to php files
var lvOut = new LoadVars(); //create lv object
var lvIn = new LoadVars(); //create lv object
lvIn.onLoad = function (success) {
if(success){
//PHP variable value to textbox
cName.text = lvIn.retCN;
cType.text = lvIn.retCT;
cSubType.text = lvIn.retST;
cMicroType.text = lvIn.retMT;
cDescription.text = lvIn.retCD;
cPower.text = lvIn.retCP;
cLevel.text = lvIn.retCL;

}else{
//...or notify of failure
cName.text = "fail";
cType.text = "fail";
cSubType.text = "fail";
cMicroType.text = "fail";
cDescription.text = "fail";
cPower.text = "fail";
cLevel.text = "fail";
}
}
//=================================
// BTN
//=================================
myBtn.onRelease = function(){
//for (var i=0; i<6; i++){
suit1 = Math.random() * 4;
suit1 = int(suit1)+1;
face1 = Math.random() * 13;
face1 = int(face1)+1;
card1 = ((suit1 - 1) * 13)+face1;
tocard1 = card1+1;
//trace(tocard1);

lvOut.ID = tocard1;
trace(lvOut.ID);
lvOut.sendAndLoad(path + "draw.php", lvIn, "POST");

DrawnArr.push(tocard1);
//}

};

Here is my php:

<?
$cardID= $_POST['ID'];

$conn = new COM("ADODB.Connection") or die("Cannot start ADO");

// Microsoft Access connection string.
$conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:\\phpdev\\www\\kikaijin\\Cards.mdb");

// SQL statement to build recordset.
$rs = $conn->Execute("SELECT * FROM List WHERE ID=$CardID;");

// Display all the values in the records set
while (!$rs->EOF) {
$cardN = $rs->Fields("cName");
$cardT = $rs->Fields("cType");
$cSubT = $rs->Fields("cSubType");
$cMicr = $rs->Fields("cMicroType");
$cDesc = $rs->Fields("cDescription");
$Power = $rs->Fields("cPower");
$Level = $rs->Fields("cLevel");
}
$rs->Close();

echo "&retCN=$cardN";
echo "&retCT=$cardT";
echo "&retST=$cSubT";
echo "&retMT=$cMicr";
echo "&retCD=$cDesc";
echo "&retCP=$Power";
echo "&retCL=$Level";

?>

It took a monumental amount of time to load the return values in my movie and when it did it returned the value "undefined" in every field. So I checked the php itself on my localhost and replaced the value of $cardID with the value "3" and it gave me the following output:

Fatal error: Maximum execution time of 30 seconds exceeded in c:\phpdev\www\kikaijin\draw.php on line 17

Does anyone see the error in my logic...I have gone over the code 1000 times and I don't see it. :eek: :confused:

Thanks in Advance,

Xman51

Xman51
06-30-2005, 01:43 PM
OK, now my AS Code looks like this:

stop();
var DrawnArr:Array = new Array();

function checkValue(val:Number,arr:Array):Boolean{
for(var i=0;i<arr.length;i++){
if(arr[i]==val){
return true;
}
}
return false;
}
//=================================
// INIT
//=================================
var path = "http://localhost/kikaijin/"; //declare path to php files
var lvOut = new LoadVars(); //create lv object
var lvIn = new LoadVars(); //create lv object
lvIn.onLoad = function (success) {
if(success){
//PHP variable value to textbox
GetBack();

cName.text = lvIn.retCN;
cSubType.text = lvIn.retST;
cMicroType.text = lvIn.retMT;
cDescription.text = lvIn.retCD;
cPower.text = lvIn.retCP;
cLevel.text = lvIn.retCL;

}else{
//...or notify of failure
cName.text = "fail";
cType.text = "fail";
cSubType.text = "fail";
cMicroType.text = "fail";
cDescription.text = "fail";
cPower.text = "fail";
cLevel.text = "fail";
}
}
//=================================
function GetCard(){
//cleanText()
suit1 = Math.random() * 5;
suit1 = int(suit1)+1;
face1 = Math.random() * 9;
face1 = int(face1)+1;
card1 = ((suit1 - 1) * 9)+face1;
tocard1 = card1+1;
trace(tocard1);
lvOut.ID = tocard1;
lvOut.dType = "Spell";
lvOut.sendAndLoad(path + "draw1.php", lvIn, "POST");
DrawnArr.push(tocard1);
//}

};
function cleanText(){
cName.text = "";
cType.text = "";
cSubType.text = "";
cMicroType.text = "";
cDescription.text = "";
cPower.text = "";
cLevel.text = "";
}

function backload(clip) {
back_container.loadMovie(clip);
var temp = this.createEmptyMovieClip("tmp", 999);
}

function GetBack(){
var cType = lvIn.retCT;
trace(cType);

if(cType=="Spell"){
backload("deck/Spell.swf");
}
if(cType=="Combat"){
backload("deck/Combat.swf");
}
if(cType=="Item"){
backload("deck/Item.swf");
}
if(cType=="Feat"){
backload("deck/Feat.swf");
}
if(cType=="Skill"){
backload("deck/Skill.swf");
}
if(cType==undefined){
backload("deck/CardFace.swf");
}
}



GetCard();

and my php code looks like this:

<?

//get the value posted from Flash
$cardID= $_POST['ID'];
$DeckID= $_POST['dType'];

//Open the connection
$conn=odbc_connect('Deck','xman51','area51');
if (!$conn)
{
exit("Connection Failed: " . $conn);
}
$sql="SELECT * FROM $DeckID WHERE ID=$CardID;";

//echo $sql;
$rs=odbc_exec($conn, $sql);

$Colnum=odbc_num_fields($rs);

while(odbc_fetch_into($rs,&$Str))

{

for($i=0;$i<$Colnum;$i++)

{
$cardN = $Str[1];
$cardT = $Str[2];
$cSubT = $Str[3];
$cMicr = $Str[4];
$cDesc = $Str[5];
$Power = $Str[6];
$Level = $Str[7];
}

echo "&retCN=$cardN";
echo "&retCT=$cardT";
echo "&retST=$cSubT";
echo "&retMT=$cMicr";
echo "&retCD=$cDesc";
echo "&retCP=$Power";
echo "&retCL=$Level";
}



if (!$rs)
{
exit("Error in SQL");
}

?>

I got it to work perfectly yesterday, it was populating the text fields and everything, but it appears tht the $DeckID variable is mucking it all up and I don't know why? It keeps bringing everything back as undefined... :confused: :eek: :confused: :eek: :confused: :eek: :mad: anybody have an idea?

Thanks in advance,

Xman51

Xman51
07-01-2005, 11:58 AM
Can anyone please assist me? :confused:

Xman51
07-01-2005, 06:56 PM
Resolution: In the sql statement the variable "$cardID" was spelled with a capital "C" thereby screwing up the sql statement.