Jump to content

iStriide

Members
  • Posts

    78
  • Joined

  • Last visited

    Never

Everything posted by iStriide

  1. One of my if statements is that i'm trying to make it where somebody can't buy a duplicate of an item, but for some reason it doesn't work. <?php $find_multiple = "SELECT * FROM `weapons` WHERE `Username` = '$session'"; $dup = mysql_fetch_array(mysql_query($find_multiple)) or trigger_error(mysql_error()); $weapon_name_check = $dup['Weapon_Name']; if($weapon_name_check == $weapon_name){ header("Location: http://www.halobattles.comyr.com/weaponshop.php"); //header expects a full URI. Location must be capitalized, and a space must be after the colon. This will insure that it works across ALL browsers. }elseif($weapon_cost > $player_Credits){ header("Location: http://www.halobattles.comyr.com/weaponshop.php"); //see above. }else{ ?>
  2. It shows this error: Notice: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Range = '20' WHERE Username = 'Tyler'' at line 1 in /home/a5719220/public_html/purchase_link.php on line 65
  3. I have already checked my variables and echoed them and the all work, but my query is not working, so here it is: 2nd query works, but not 1st. <?php $new_player_credits = $player_Credits - $weapon_cost; $new_attack = $weapon_attack + $player_attack; $new_defense = $weapon_defense + $player_defense; $new_strength = $weapon_strength + $player_strength; $new_speed = $weapon_speed + $player_speed; $new_accuracy = $weapon_accuracy + $player_accuracy; $new_range = $weapon_range + $player_range; $new_HBS = $new_attack + $new_defense + $new_strength + $new_speed + $new_accuracy + $new_range * .3; $weapon_upgrade = $weapon_cost * 1.3; $weapon_sell = $weapon_upgrade * .40; mysql_query("UPDATE stats SET HBS = '$new_HBS', Current_Credits = '$new_player_credits', Attack = '$new_attack', Defense = '$new_defense', Strength = '$new_strength', Speed = '$new_speed', Accuracy = '$new_accuracy', Range = '$new_range' WHERE Username = '$session'"); mysql_query("INSERT INTO weapons SET Username = '$session', Weapon_Name = '$weapon_name', Weapon_Image = '$weapon_image', Weapon_Shop_Level = '$weapon_level', Weapon_Level = '$weapon_level', Weapon_Current_Value = '$weapon_upgrade', Weapon_Sell_Value = '$weapon_sell', Weapon_Attack = '$new_attack', Weapon_Defense = '$new_defense', Weapon_Strength = '$new_strength', Weapon_Speed = '$new_speed', Weapon_Accuracy = '$new_accuracy', Weapon_Range = '$new_range'"); header("Location: http://www.halobattles.comyr.com/profile.php?player=$session"); ?>
  4. Now I have this problem, and I'm not sure why its doing it. http://www.halobattles.comyr.com/purchase_link.php?w=1&weapon=Plasma%20Pistol
  5. I really have no idea where I went wrong on this, but after I got all my variables set and added I tried to echo them on the page and they won't show up and I don't know why, so please help. Here's the page. <?php session_start(); ?> <?php if($_SESSION['user']){ include_once('connect.php'); $session = $_SESSION['user']; $w = $_GET['w']; $find = "SELECT * FROM weapon_shop WHERE id = '$w'"; $run = mysql_fetch_array(mysql_query($find)) or die (mysql_error()); $weapon_id = $run['id']; $weapon_name = $run['Weapon_Name']; $weapon_image = $run['Weapon_Image']; $weapon_level = $run['Weapon_Level']; $weapon_cost = $run['Weapon_Cost']; $weapon_sell_value = $run['Weapon_Sell_Value']; $weapon_attack = $run['Weapon_Attack']; $weapon_defense = $run['Weapon_Defense']; $weapon_strength = $run['Weapon_Stength']; $weapon_speed = $run['Weapon_Speed']; $weapon_accuracy = $run['Weapon_Accuracy']; $weapon_range = $run['Weapon_Range']; $find_stats = "SELECT * FROM stats WHERE Username = '$session'"; $stats = mysql_fetch_array(mysql_query($find_stats)) or die (mysql_error()); $player_HBS = $stats['HBS']; $player_Credits = $stats['Current_Credits']; $player_attack = $stats['Attack']; $player_defense = $stats['Defense']; $player_strength = $stats['Strength']; $player_speed = $stats['Speed']; $player_accuracy = $stats['Accuracy']; $player_range = $stats['Range']; $find_duplicate = "SELECT Weapon_Name FROM weapons WHERE Weapon_Name = '$weapon_name'"; $dup = mysql_fetch_array(mysql_query($find_duplicate)) or die (mysql_error()); $weapon_name_check = $dup['Weapon_Name']; if($weapon_name_check == $weapon_name){ header("location:weaponshop.php"); }elseif($weapon_cost > $player_Credits){ header("location:weaponshop.php"); }else{ $new_player_credits = $player_Credits-$weapon_cost; $new_attack = $weapon_attack+$player_attack; $new_defense = $weapon_defense+$player_defense; $new_strength = $weapon_strength+$player_strength; $new_speed = $weapon_speed+$player_speed; $new_accuracy = $weapon_accuracy+$player_accuracy; $new_range = $weapon_range+$player_range; $new_HBS = $new_attack+$new_defense+$new_strength+$new_speed+$new_accuracy+$new_range *.3; echo " <html> <img src='$weapon_image'/><br/> $new_player_credits<br/> $new_attack<br/> $new_defense<br/> $new_strength<br/> $new_speed<br/> $new_accuracy<br/> $new_range<br/> $new_HBS </html> "; } }else{ header("location:index.php"); } ?>
  6. I'm not sure on how to do this so I hope one of you can help me. I'm trying to do a mysql_query(); function in PHP to get certain results. I'm trying to get users from my database where their ID's are between 1 and 100. So what would I have to do for that?
  7. I'm not sure on how to do this so I hope one of you can help me. I'm trying to do a mysql_query(); function in PHP to get certain results. I'm trying to get users from my database where their ID's are between 1 and 100. So what would I have to do for that?
  8. Yea I just tested it out a bit more and it seems that way to. I appreciate the help. This should work for what i'm trying to do.
  9. I just tried that out, and it seems like it just goes in order.
  10. I'm wanting to know if there is a random function in PHP. I am not sure if there is one, but I could I do something where I can make something a have lets say a 25% chance of happening. Example: Can I do anything like this? 25% chance of echoing "Whats Up" or 75% chance of echoing "I hate lag". If there is anything like this any PHP I would appreciate if you guys would tell me how to use it.
  11. Not sure if thats really going to help you at all.
  12. Not sure, but if you just want the images to show on the page you can do this: <html> <body> <?php mysql_connect('localhost', 'user', 'pass'); mysql_select_db('database'); $find = "SELECT * FROM database"; $run = mysql_query("$find"); while($is = mysql_fetch_assoc($run)) { $images = $is['Column_Name']; $image_name = $is['Column_Name']; print "<img src='$images'/><label>$image_name</label>"; } ?> </body> </html>
  13. Can somebody put a code that would show all the people that are online on the website?
  14. I'm going to have a textbox and a submit button, and every time I submit something I want it to post on the page, and stay their when I refresh it.
  15. I want it to the post to the page multiple times, instead of copying over the page. Help me with the code please: It's also a site view counter. <?php $count_my_page = ("practice2.php"); $hits = file($count_my_page); $hits[0] ++; $post = $_POST['message']; $fp = fopen($count_my_page , "w"); fputs($fp , "$hits[0]" . "$post"); fclose($fp); echo $hits[0] . "<br/>" . "$post"; ?>
  16. mysql_connect('', '', ''); mysql_select_db(''); if (isset($_POST['submit'])) { $user = mysql_real_escape_string($_POST['user']); $pass = mysql_real_escape_string($_POST['pass']); $sql = "SELECT id FROM login WHERE username = '$user' && `password` = MD5('$pass')"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { // $user & $pass are valid echo "You Logged In $user"; } else { // $user || $pass invalid echo "Invalid Login"; } } }
  17. i have already made the register page where their info goes into the database, and im not sure about the code that selects values from the database. mysql_connect('', '', ''); mysql_select_db(''); $user = $_POST['user']; $pass = $_POST['pass']; echo "<font color='white'>You Need To Login</font>"; if($user == Username && $pass == Password) echo "Welcome $user"; mysql_query("SELECT ('Username', 'Password') FROM login"); ?>
  18. Somebody please tell me why this wont work. Didnt wont to put my email in their. <?php $user = $_POST['subject']; $email = $_POST['email']; $message = $_POST['message']; //To, Subject, Message mailto(''); mailsubject('$user Sent you a message'); mailfrom('From: ' . $user . ' <' . $email . '>'); ?>
  19. MySQL connection works and it connects to my database but it doesnt insert values into the table that I created. <form action="phplogin2.php" method="post"> Username: <input type="text" name="user" style="color: white; background-color: blue;"/><br/> Password: <input type="password" name="pass" style="color: grey; background-color: black;"/><br/> <button>Login</button> </form> <?php $con = mysql_connect('localhost', 'root', 'eagles1') or die("did not connect"); $dbc = mysql_select_db('mysql') or die("did not connect to database"); $query = mysql_query("INSERT INTO login VALUES('', '$user', '$pass')") or die("query did not work"); $user = $_POST['user']; $pass = $_POST['pass']; if ($con==true){ echo "MySQL Connection Succesful"; } if ($dbc==true){ echo "MySQL Database Connection Succesful"; } if ($query==true){ echo "MySQL Query Succesful"; } ?>
  20. If anybody could give me code for that gets site views, that would be really nice.
  21. I just started javascript, and i was wondering if their was a way that you use the prompt(""); code or document.write or something that will pop with a box like alert but that you can type in a url and click ok and it will take you to that page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.