Jump to content

dannerz

Members
  • Posts

    29
  • Joined

  • Last visited

dannerz's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'll start copy pasting and editing (thanks)
  2. echo "you bought 1 archer"; $data = mysql_query("SELECT Vals FROM vals2 WHERE ValsN = 'archers'"); if ($data == false) exit("This has failed"); $msg = mysql_fetch_assoc($data); echo "<br />"; echo $msg;//this just says that it is an array echo "<br />"; echo $data; echo "<br />"; $msg2 = mysql_num_fields($data); echo $msg2; echo "<br />"; $msg3 = mysql_fetch_row($data);//this is not shown for some reason echo $msg3; This is the code. I'd like to get a number out of the db, and convert the resource into just a number value or string, then alter the number in PHP (i know how to do that part) then put the number back into the db (I think I can do that also) I just don't know how to convert a resource ("$data") into a variable to use in the PHP code. Hopefully you know what I mean. (the output of the above code is) Shop choice method. you bought 1 archer Array Resource id #4 1
  3. Thanks. Maybe I'll try to figure out how to buy a book from amazon or something similar.
  4. What would the first steps to learning how be?
  5. Hello. I would like to know how to make a user account. I want to make a game someday, and the plan is to make the game using php, MySQL and maybe also java script. I know a small amount of things, but now I want to learn how to make user accounts.
  6. I signed in, then it said i was banned. I don't know what to do about the ban.
  7. Hello. I am wondering if anyone would like to talk with me on skype. I want to make a PHP game. At this point I don't think the manuals can tell me enough, even though I understood some of it. So anyways, if you would like to give a guy a little bit of help, please do. PM me if you are interested. Also if you cannot chat with me about it, maybe show me where I can find a good PHP irc chat room.
  8. I figured this out on my own. It requires simply that I put <select name="unit2" size="1"> So, the mods can lock this thread if they want. I'm glad I learned it.
  9. <html> <head> <title> Intro Room </title> </head> <body> Welcome to the shop. <br /> To the left is how many of this you want to buy. <br /> To the right is what you want to buy. <br /> <br /> <form action="shop1b.php" method="post"> Amount of this you want to buy: <input type="text" <input name="unit"> What you want to buy: <select> <option value="archer">archer</option> <option value="immortal_archer">immortal_archer</option> <option value="shield_infantry">shield_infantry</option> <option value="immortal_shield_infantry">immortal_shield_infantry</option> </select> <input type="submit"> </form> Archers : 1 hp, 1 attack, 0 defense, 100$ each. <br /> Immortal archers same status but can't be destroyed. 1000$ each. <br /> Shield_Infantry 1 hp, 0 attack, 2 defense, 100$ each. <br /> Immortal shield infantry same status but can't be destroyed. 800$ each. <br /> </body> </html> This is the code^. I was hoping that which ever option you select, it would give that string to $_POST somehow. But I don't know how to do it yet.
  10. ok buddy i will try that out right away. edit: ok it works, thanks allot. This helps be allot.
  11. <form action="shop1b.php" method="post"> Option number placed here: <input type="text" <input name="unit"> <input type="submit"> </form> This is what I've got so far. I can send 1 variable to the next page, which is "shop1b.php", but I don't know how to send more than one variable to the next page, and if I did send 2 variables, how would I use each of them in php?
  12. I just cut and pasted something out of the manual. It seems that it works now.
  13. ok, I just made a little bit of progress. $con = mysql_connect("localhost", 'root', ''); if (!$con) { die('Could not connect: ' . mysql_error()); } if (!mysql_select_db("test")) { echo "Failure" . mysql_error(); exit; } $buy = $_POST["unit"]; if ($buy == "1") { echo "you bought 1 archer"; // FROM not FORM. $data = mysql_query("SELECT Vals FROM vals2 WHERE ValsN = 'archers'"); if ($data == false) exit("This has failed"); $msg = mysql_fetch_assoc($data); echo "<br />"; echo $msg; echo "<br />"; echo $data; } ^That is my code. It echos something that says "Array Resource id #4". I'm wondering what do I do next to turn the resource into an integer or a string?
  14. it is returning a false. the error said it was a boolean value. this is as far as i got: $data = mysql_query("SELECT `test`.`vals2` FROM `vals2` WHERE `ValsN` = 'archers'"); if ($data == false) exit("This has failed"); $msg = mysql_fetch_assoc($data); echo $msg; echo $data; I'm sure I got the query wrong. In my screen shot i showed which part of the database I wanted to access.
  15. I noticed that and fixed it but i can't edit my first post it seems. What is the query returning anyways? When I try to echo it i get nothing.
×
×
  • 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.