Jump to content

hansolo

Members
  • Posts

    214
  • Joined

  • Last visited

Everything posted by hansolo

  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
  15. $password_wrd=md5($_POST['pass']);$usercheck = $_POST['username']; $insert = "INSERT INTO $table(username, password)// as the syntax highlighted in red is confusing VALUES ('".$_POST['username']."', '".$_POST['pass']."')";$add_member = mysql_query($insert); can this line be written as you have above to if just place the variable names which contain the $_POSTlikethis below VALUES ('".$_POST['username']."', '".$_POST['pass']."')";can i write this in this way $password_wrd=md5($_POST['pass']);$usercheck = $_POST['username']; $insert = "INSERT INTO $table(username, password)VALUES ('$usercheck','$password' );$add_member = mysql_query($insert);
  16. I am a beginner and what i say i could have wrong. I think they are saying you have stored you statement in a variable. but you have not run the query. you have to run the query the built in words mysql_query then store the value in variable. ( A variable will have a dollar sign ) mysql_query("INSERT INTO ViewIt (misc, CC)VALUES ('1', '2')); // you have a vairiable$sql="INSERT INTO ViewIt (misc, CC)VALUES ('1', '2')";
  17. thank you thats it exactly. The syntax makes sense to me. I like how you have wrote the syntax. The other way was confusing were to place the quotations
  18. I think thats a good idea how do combine this query to search for the usnerame and password. I need to just join these lines below to locate the correct columns $check = mysql_query("SELECT * FROM users WHERE password = '".$password_undefined."'")or die();//$check = mysql_query("SELECT * FROM users WHERE usernames = '".$_POST['username']."'")or die();
  19. ok that s right maybe i should just throw an error to user when they get it wrong rathe than being specific
  20. the users wont be storing any private information. Its just for an avatar ..The details need not to be seen for privacy rather than needed to be realy secure as the details will only ne a password and name to login no other private details I was told its a function so it had to be stored inside a variable $password_udefined=md5($_POST['pass']);$check = mysql_query("SELECT * FROM users WHERE password = '".$password_udefined."'")or die();
  21. When checking for a password thats encrypted in (md5) ive been placing the md 5 to locate the password in front of the $_POS['password'] but this not locating the passw ord. The text below as worked to locate the user in the database. I think i am plcing the md 5 incorrect as can locate the password in the databse $check = mysql_query("SELECT * FROM users WHERE password = '".$_POST['password']."'")or die();
  22. i thought i say something like this below as the dollar $info select the query with username again at the top. Why not wrote like i have below im missing I can see it says if the passwod is not equal to the $info is fetching the array which looks for the username in the table.Should i jut create one whick looks forth username and the password at the same time $check = mysql_query("SELECT * FROM users WHERE password = '".$_POST['pass]."'")or die();
  23. this checks for users in databse i understand the majority of the code apart from 1 section. The section which i dont know the mening of is herethis section hereif ($_POST['pass'] != $info['password']) { i see info has the value mysql fetch arrary which has the value of $check which checks is the first my sql query. That the part that is confusing me as the first variable £$check is checking if the user exists in the users table. Why does it use this check rather than checking for the password... I will post the tutorial as might be able to see it better as it have colour coding. <?phpmysql_connect("localhost","buffoonb_user","password") or die();mysql_select_db("buffoonb_alsdatabase") or die();$check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'")or die();$check2 = mysql_num_rows($check);if ($check2 == 0) {print "words=User doesn't exist.&checklog=3";die();}while($info = mysql_fetch_array( $check )){if ($_POST['pass'] != $info['password']) {print "words=Incorrect Password.&checklog=4";die();}else{print "words=You are logged in.&checklog=5";die();}}?>
  24. The following syntax is outputted in mysql. when i create a table. I understand its select all from users table.Dont know what the the following statement is referring too (The limit to 0, 30 ) SELECT * FROM `users` LIMIT 0 , 30
×
×
  • Create New...