Hey all.
I am trying to see if I can get some info on a script I put togeather to gather information out of one mysql table based on an id that another table has.
my current php file is
<?php
include "connect.php";
include "config.php";
if($_POST["sendRequest"] == "getStats"){
$user_id = ("SELECT user_id FROM '$tableStats'");
$id = ("SELECT id FROM '$tableNames'");
$getStamina = mysql_query("SELECT stamina FROM '$tableStats' WHERE '$user_id' = '$id'");
$row1 = mysql_fetch_array($getStamina);
print "stamina=$row1[stamina]";
} ?>
and my current actionscript on the timeline is essentially requesting what is in the if statement, after the user loggs in
import flash.display.MovieClip
import flash.events.MouseEvent
import flash.net.*
var d = (this.parent as MovieClip).userInfo
var current_user_id:int
var stamina:Number
var variables:URLVariables = new URLVariables
var staminaVar:URLVariables = new URLVariables
var varGetStamina:URLRequest = new URLRequest("php/user_stats.php")
varGetStamina.method = URLRequestMethod.POST
varGetStamina.data = staminaVar
var staminaVarLoader:URLLoader = new URLLoader
staminaVarLoader.dataFormat = URLLoaderDataFormat.VARIABLES
staminaVarLoader.addEventListener(Event.COMPLETE, completeHandler2)
staminaVar.user_id = current_user_id
staminaVar.sendRequest = "getStats"
staminaVarLoader.load(varGetStamina)
function completeHandler2(event:Event):void {
stamina = event.target.data.stamina
output_stamina_txt.text = "stamina " + stamina
}
I have two tables one is user_accounts, the other is user_stats.
I am trying to get the information in user_stats based on the field user_id that matches the id in my user_accounts.
so when the user logs in it will let them view there stats.
I keep getting a NaN value or a 0 . not sure how to fix this. any suggestions or advice welcome.
I am kinda new to this so be gentle.