Jump to content

hansolo

Members
  • Posts

    214
  • Joined

  • Last visited

hansolo's Achievements

Member

Member (2/7)

1

Reputation

  1. ok below i have example of code a way of checking the database for scores as flash detects strings. This does not subtract a value or add a value.It does load the items based on score of bronze or silver or gold . This then post back to flash what the user based on points level are at. This question on how how database game shops are created in flash . When a user buy a product how can i load how mutch money the user has left from the database. as flash loads string from the url ... Has anyone experience in creating shops in games and what method did they use to get no sums can added or subtracted from php to flash, was all the maths complete in the php file .... I am looking for examples of psuedo code the theory behind creating database shop in flash this does work below but its not a question on the code below //points of users $gold = 1500; $silver = 1000; $bronze = 500; $medals = ""; // find user and score points column $result = mysql_query("SELECT * FROM $table WHERE username ='$username'"); //load points while($row = mysql_fetch_array($result)) { echo"&score_col=".$row['score_col']; // if points are 500 or below player has bronze postion $points=$row['score_col']; if($points <= $bronze ){ $medals ="bronze"; echo"&medal=".$medals; echo"&userPostBck=".$username; }//if points are higher than 1000 or below but 1500 postion silver if($points >$bronze and $points <= $silver) { $medals ="silver"; echo"&medal=".$medals; echo"&userPostBck=".$username; }// you guessed it gold is sameif($points > $silver and $points <= $gold or $points >= $gold) { $medals ="gold"; echo"&medal=".$medals; echo"&userPostBck=".$username; }
  2. yes n does have the value. Whats even more fustrating if copy and paste the same code . it sometimes work in new document and then sometimes doesnt. I have been asking are there some setting which might affect this notepadd++ .or the flash playerWhich i decided to do was copy and paste but this happening alot and when the code is more complex. It can be hard to detect real errors. As there doesnt seem to be an error above. ...
  3. why wont the if statment in the flash fie not play. The name does equal ben in the broser and ben loads in the flash trace statemnent <?php$username ="ben";echo"&n=".$username;?> ActionScript Code: var result_lv:LoadVars = new LoadVars(); result_lv.onLoad = function(ok){ if (ok) { trace (result_lv.n); //not playing when "n" does have the value "ben" if(result_lv.n == "ben"){ trace("hit"); } } } send_lv = new LoadVars(); send_lv.sendAndLoad("http://localhost/test2.php.",result_lv,"POST");
  4. I might have to set up the numbers check first in the php file . If im gonna check these scores in flash and post back a string value to flash saying wether the user has bigger or smalller scor value
  5. this the result posted in the browser how ever i still cant get this if statenent to be recognised. The number 500I am wondering if only string values will be recognised as values. when using the load vars. I can place the number in text in a textbox but can check this value in the if statement. If i cant i have to come up with another way of checking scores from the database in flashresult posted for php script in browser below &scoreC=500 var result_lv:LoadVars = new LoadVars(); result_lv.onLoad = function(ok){ if (ok) {trace (result_lv.scoreC); //not being checked hereif(result_lv.scoreC == 500){ trace("hit"); } } } send_lv = new LoadVars(); send_lv.sendAndLoad("http://localhost/test2.php.",result_lv,"POST");
  6. it was in the database your correct i deleted the gaps
  7. hi when i am uploading my text to the browser there is slight gap. The is space of the size of a character on either side of the name medusa. i think this causing an issue for results not being read correct..... i dont know what is causing the gap see text below browser results &character= medusa &score_col=500 <?php $con = mysql_connect("localhost","root","") or die(); mysql_select_db("users_db") or die(); $username ="ben";$table = "username_tbl"; $result = mysql_query("SELECT * FROM $table WHERE username ='$username'");mysql_error();while($row = mysql_fetch_array($result)) { echo"&character=".$row['character_col']."&score_col=".$row['score_col']; }?>
  8. In the onLoad function, trace the ok and character variables to see what they are set to. Don't put them in if statements, just trace them to see what they are. ok i think i have done that but i post them to what they are set to this does return the value of 1 i guess they set to result_lvtrace(result_lv.tombRaider);
  9. ys i think ive got an idea why not running its not getting played in the php code. Even though loading in the browser.. I m gonna simplfy itas i only need to get the data from the character column. I probaly should run mysql query once rather than twice. I try that anyway as the above is not working
  10. no i expect it trace in flash. The variable are loading in both firebug and flash however The if statement created in flash is not tracing .so im unable to use this loaded variable in flash.I dont know why . Im confuse.liike you say this shouldnt have an issue . I must bedoing something incorrect if( result_lv.character== "tomb"){trace("this a success found tomb")}
  11. below is my php codeThese are the values returned in the browser &userName=ben&character=tombso why does this value not return true if( result_lv.character== "tomb"){trace("this a success found tomb") <?php$con = mysql_connect("localhost","root","") or die();mysql_select_db("users_db") or die();// post username here//$user = $_POST['username'];$user = "ben";$table = "username_tbl";$value =3;//$check = mysql_query("SELECT * FROM $table WHERE username = '$user'//")or die();$check2 = mysql_num_rows($check);if ($check2 == 0) {echo"&reply=incorrect username or passwrd";die();}// this value can only be passed if the value is in the databaseif ($check2 == 1) {$selection = mysql_query("SELECT character_col FROM $table WHERE username = '$user'");echo"&tests=".$value;while($row = mysql_fetch_array($selection)) { $hold = $row['character_col']; } } if($hold == "tomb"){ //echo"winner"; echo"&tombRaider="."1"; }else{ echo"loser"; }mysql_close($con);?>
  12. These are the values returned and the response in fire bug. i can see the value has been returned what i am checking for in the browser and flash with a trace command. The if statement in flash to check the value of "&character" which does have the value of "tomb" This if statement which is true is not getting checked I can see this becuase does not get played trace("this a success found tomb")these the value loaded in the browser below. php return values in firebug&userName=ben&character=tomb flash code var result_lv:LoadVars = new LoadVars(); result_lv.onLoad = function(ok){ if (ok) { trace(result_lv.character); if( result_lv.character== "tomb"){ trace("this a success found tomb") } } } send_lv= new LoadVars(); trace(this._name + "pressed"); send_lv.username = "ben" ; send_lv.sendAndLoad("http://localhost/check4.php",result_lv,"POST");
  13. <?php$con = mysql_connect("xxx","xxx","xxx");mysql_select_db("xxx", $con);mysql_query("DELETE FROM ViewIt WHERE misc='1'");mysql_close($con)?> <?php$con = mysql_connect("xxx","xxx","xxx");mysql_select_db("xxx", $con);$sql="INSERT INTO ViewIt (misc, CC)VALUES ('1', '2')";mysql_close($con)?> then you need to submit the values. Ask some guy for the code
  14. post your full code and then maybe some one can highlight in red. To show what you have missed.The red part will stand out mysql_query("INSERT INTO ViewIt (misc, CC)VALUES ('1', '2'));// you have a vairiable$sql="INSERT INTO ViewIt (misc, CC)VALUES ('1', '2')"; this the letters you missed out i have shown them in red mysql_query you had it stored in variable called $sqlwrite this mysql_query
×
×
  • Create New...