-
Posts
206 -
Joined
-
Last visited
Never
Posts posted by Jiraiya
-
-
You don't have enough gold, you currently have . Come back when you getmore.
thats what is displayed
-
it displayed
"You don't have enough gold, you currently have {$row['gold']}. Come back when you getmore."
-
this code works better in the sense that now the web page shows up but the script still isnt doing anything it keeps displaying "You don't have enough gold. Come back when you getmore.
-
this is the entire code so far i still didnt find any errors
<?php mysql_connect("database", "username", "password") or die(mysql_error()); mysql_select_db("members") or die(mysql_error()); $sql = mysql_query("SELECT * FROM users WHERE username = '$username'"); $row = mysql_fetch_array($sql); if ($row['gold'] >= 100) { $sql = "UPDATE users SET gold = gold-100, potions = potions+1 WHERE username = '$username'") or die(mysql_error()); echo "<center>You have bought one health potion.</center>"; }else{ echo "<center>You don't have enough gold. Come back when you getmore.</center>"; } ?>
-
i checked that and it still shows up white on the web browers
<?php $sql = mysql_query("SELECT * FROM users WHERE username = '$username'"); $row = mysql_fetch_array($sql); if ($row['gold'] >= 100) { $sql = "UPDATE users SET gold=gold-100, potions=potions+1 WHERE username = '$username'") or die(mysql_error(); echo "<center>You have bought one health potion.</center>"; }else{ echo "<center>You don't have enough gold. Come back when you getmore.</center>"; } ?>
-
i still dont see what is wrong with that line
-
is there something wrong with the code it keeps coming up blank on my webpage.
<?php $sql = mysql_query("SELECT * FROM users WHERE username = '$username'"); $row = mysql_fetch_array($sql); if ($row['gold'] >= 100) { $sql = "UPDATE users SET gold=gold-100, potions=potions+1 WHERE username = '$username'") or die(mysql_error()); echo '<center>You have bought one health potion</center>'; }else{ echo '<center>You don't have enough gold. Come back when you get more.</center>'; } ?>
-
yes thanks
-
I looked online for tutorials on how to do this but i still don't understand im trying to use a if statement that if($row['gold'] >= 100) then it subtracts 100 from row gold and then adds 1 to row "potions" if anyone could help me or send a tutorial my way i would be very grateful.
-
the "kills" variable is never reset to 0 it keeps increasing
-
I was wondering if i would be able to expand on this code i made so that it does the same thing but for different set numbers kinda like this
if kills >50 & <100 set rank x
if rank = x echo cannot rank up
if kills >100 & < 150 set rank x
if rank = x echo...
if kills > 150 & < 200 set rank x
if rank = x
but with it being all in one script, and how would i do this this my current code shown below.
$sql = mysql_query("SELECT * FROM table WHERE username = '$username'"); $row = mysql_fetch_array($sql); if($row['kills'] >= 25){ mysql_query("UPDATE `table` SET `variable` = 'new rank' WHERE username = '$username'") or die(mysql_error()); echo '<center>You have ranked up. '.$username.'</center>'; }else{ echo '<center>Your not good enough to rank up yet!</center>'; }
-
the script is working but its not doing what i need it to do. im trying to get it to verifiy that both variables for both players are both equal to "Forest Of Death" and if either players location variable is not set to "Forest Of Death" i dont want the rest of the script to run here is the whole code
$UserSL = $UserS['location']; // syntax error need sem-colon $NPCL = $NPC['location']; // syntax error need sem-colon if($NPCL == "Home") {echo "User is at thier house! <br><br>"; exit(); } if($UserSL == "Home") {echo "You must be in the city to fight! <br><br>"; exit(); } echo "Begin the fight!"; if(!isset($_GET['user'])) { echo "You have not selected a user to fight!<br><br>"; $NPCS = mysql_query("SELECT * FROM `users`"); while($Show = mysql_fetch_array($NPCS)) { echo "<a href=\"AttackPlayer.php? Action=Attack&user=" . $Show['username'] . "\">" . $Show['username'] . "</a><br>"; } exit(); } $NPC = mysql_escape_string($_GET['user']); $username = $_COOKIE['ID_my_site']; if($_GET[Action] = Attack) { if($username == $NPC){echo "You cannot fight yourself! <br><br>"; exit();} $UserS = mysql_query("SELECT * FROM `users` WHERE username='$username'"); $UserS = mysql_fetch_array($UserS); $UserH = $UserS['health']; if($UserH == '0'){echo "You have no health you cannot fight! <br><br>"; exit();} $UserA = $UserS['skill']; $UserK = $UserS['kills'] +1; $UserSkill = $UserS['skill']; $UserA *= .1; $NPCS = mysql_query("SELECT * FROM `users` WHERE username='$NPC'"); $NPCS = mysql_fetch_array($NPCS); $NPCH = $NPCS['health']; if($NPCH == '0'){echo "You cannot attack someone that has no health! <br><br>"; exit();} $NPCA = $NPCS['skill']; $NPCSkill = $NPCS['skill']; $NPCA *= .1; $run = 1; While($run > 0){ $NPCH -= $UserA; if($NPCH <= 0) { $xp = $NPCSkill * .020; echo "You win and have gained " . $xp . " skill from " . $NPC . ""; $UserA = $UserSkill + $xp; mysql_query("UPDATE `users` SET skill='$UserA', health='$UserH', kills='$UserK' WHERE username='$username'"); $NPCA = $NPCSkill * .97; mysql_query("UPDATE `users` SET skill='$NPCA', health='0' WHERE username='$NPC'"); exit(); } $UserH -= $NPCA; if($UserH <= 0) { echo "You have lost"; $xp = $UserSkill * .030; $UserA = $NPCSkill + $xp; mysql_query("UPDATE `users` SET skill='$UserA', health='$UserH', kill='kill +1' WHERE username='$NPC'"); $UserA = $UserSkill * .97; mysql_query("UPDATE `users` SET skill='$UserA', health='0' WHERE username='$username'"); exit(); } } } ?> </body> </html>
-
yea all it did was turn my page white
-
so this then
$UserSL = $UserS['location'] $NPCL = $NPC['location'] if($NPCL ==" Home") {echo "User is at thier house! <br><br>"; exit(); } if($UserSL == "Home") {echo "You must be in the city to fight! <br><br>"; exit(); }
-
is this look good? its supposed to stop another script on the same page if both variables dont match
$UserSL = $UserS['location'] $NPCL = $NPC['location'] if($NPCL = Home) {echo "User is at thier house! <br><br>"; exit(); } if($UserSL = Home) {echo "You must be in the city to fight! <br><br>"; exit(); }
-
i have a script that allows users to view other members profiles but im not sure how to create a script that checks if the target profile has there profile variable set to "public" so i need it to check if the target profile's user has there "profile" variable set to "public" and if it is set to public continue to run the script to view the profile but if it he "profile" variable is set to anything but "public" it redirects the user trying to view the profile to another page
-
i was wondering if i could create a file upload script with php that stores the url for a picture and stores the url under a "picture" variable in my database. so my question is there a way i can echo the url that is stored in the database but have it show the picture instead of the url
-
ok how then would i make it so when a player picks another player to fight the scirpt wont run unless the targeted player has the location variable set to "Forest Of Death"
-
i need help editing my script. i tried to do it my self but it didn't work. im trying to make it so my attack player script will only run if the location variable for both players is set to "Forest Of Death"
<?php mysql_connect("localhost", "username", "password") or die(mysql_error()); mysql_select_db("members") or die(mysql_error()); $username = $_COOKIE['ID_my_site']; mysql_query("UPDATE `users` SET `location` = 'Forest Of Death' WHERE username = '$username'") or die(mysql_error()); echo "<center>You have entered the Forest of Death. death lurks around every corner, every tree, every face... " . "</center>"; $playerA = "Forest Of Death"; $playerB = "Forest Of Death"; IF ($playerA == $playerB) { //they can attack } else { //they can't attack } session_start(); if(!isset($_GET['user'])) { echo "You have not selected a user to fight!<br><br>"; $NPCS = mysql_query("SELECT * FROM `users`"); while($Show = mysql_fetch_array($NPCS)) { echo "<a href=\"AttackPlayer.php? Action=Attack&user=" . $Show['username'] . "\">" . $Show['username'] . "</a><br>"; } exit(); } $NPC = mysql_escape_string($_GET['user']); $username = $_COOKIE['ID_my_site']; if($_GET[Action] = Attack) { if($username == $NPC){echo "You cannot fight yourself! <br><br>"; exit();} $UserS = mysql_query("SELECT * FROM `users` WHERE username='$username'"); $UserS = mysql_fetch_array($UserS); $UserH = $UserS['health']; if($UserH == '0'){echo "You have no health you cannot fight! <br><br>"; exit();} $UserA = $UserS['skill']; $UserK = $UserS['kills'] +1; $UserSkill = $UserS['skill']; $UserA *= .1; $NPCS = mysql_query("SELECT * FROM `users` WHERE username='$NPC'"); $NPCS = mysql_fetch_array($NPCS); $NPCH = $NPCS['health']; if($NPCH == '0'){echo "You cannot attack someone that has no health! <br><br>"; exit();} $NPCA = $NPCS['skill']; $NPCSkill = $NPCS['skill']; $NPCA *= .1; $run = 1; While($run > 0){ $NPCH -= $UserA; if($NPCH <= 0) { $xp = $NPCSkill * .035; echo "You win and have gained " . $xp . " skill from " . $NPC . ""; $UserA = $UserSkill + $xp; mysql_query("UPDATE `users` SET skill='$UserA', health='$UserH', kills='$UserK' WHERE username='$username'"); $NPCA = $NPCSkill * .97; mysql_query("UPDATE `users` SET skill='$NPCA', health='0' WHERE username='$NPC'"); exit(); } $UserH -= $NPCA; if($UserH <= 0) { echo "You have lost"; $xp = $UserSkill * .035; $UserA = $NPCSkill + $xp; mysql_query("UPDATE `users` SET skill='$UserA', health='$UserH', kill='kill +1' WHERE username='$NPC'"); $UserA = $UserSkill * .97; mysql_query("UPDATE `users` SET skill='$UserA', health='0' WHERE username='$username'"); exit(); } } } ?> </body> </html>
-
im confused with the script for this can someone please help?
-
yea i want to set every players health to max_health
-
i need help editing my script to make it work with a cron, i need it to update every players variable even if the player is not logged on
function UpdateHealthBar($player){ if($player != ''){ $sql = mysql_query("SELECT `username`,`max_health`, `health`, `last_update` FROM `users` WHERE `username` = '$player'") or die(mysql_error()); $user = mysql_fetch_assoc($sql) or die(mysql_error()); // vars $username = $user['username']; $user_health = $user['health']; $max_health = $user['max_health']; mysql_query("UPDATE `users` SET `health` = '$max_health', `last_update` = '$last_update' WHERE `username` = '$player'") or die(mysql_error()); } } } UpdateHealthBar($player);
-
i need help on how to create a cron i have looked for tutorials but dont really get it. i want to create a cron that updates a varable in my table every hour
-
my script is supposed to be a in game money transfer system. i need help figuring how to do it. if anyone knows of any rpg php script tutorials that would be great
[SOLVED] phpmath help please
in PHP Coding Help
Posted
No rows were returned by the SQL. Username entered was
is what it displayed