Jump to content

ferrin

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ferrin's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. this is probably really basic, but how do i go about adding '1' to each item in a row? for example, i have a cron set to run a page every hour, and every hour it updates a number under the column 'time' for each column with breeding = 'yes'. then after the number reaches 20, breeding is reset to = 'no'. this is my code (what i figured out so far), but it's not doing anything. don't kill me, i'm still a newb. <?php if ($number < 20) { $con = mysql_connect ("gamepets.db.6086537.hostedresource.com","gamepets","----") or die(mysql_error()); mysql_select_db("gamepets")or die("cannot select DB"); // // ------------ GET NUMBER FROM DATABASE -------- $sql=("SELECT time FROM test WHERE breeding = 'yes'"); $number=mysql_query($sql); $number++; // ------------- ADD +1 ($add) to time ---------------- // Connect to server and select database. $con = mysql_connect ("gamepets.db.6086537.hostedresource.com","gamepets","----") or die(mysql_error()); mysql_select_db("gamepets")or die("cannot select DB"); $number = mysql_query("UPDATE test SET time='$number' WHERE breeding='yes'") or die(mysql_error()); } else { $con = mysql_connect ("gamepets.db.6086537.hostedresource.com","gamepets","----") or die(mysql_error()); mysql_select_db("gamepets")or die("cannot select DB"); $number = mysql_query("UPDATE test SET breeding='no' WHERE time='100'") or die(mysql_error()); } ?>
  2. hello, thank you for responding. i actually finally figured it out. now i'm trying to figure out a way to have each breeding timed so that the pets being used can't breed for a certain amount of time. my host doesn't have cron jobs so i'm sort of feeling screwed right now. any ideas?
  3. i'm posting again, sorry. i finally rewrote the entire thing completely, and NOW it works. it updates the database as well as lets you select per gender. only issue left is that instead of saying the names of pets breeding, it shows "resource id 2", no idea why. <?php session_start(); $username= $_SESSION['username']; echo "$username<br>"; // --------------check if form has been filled $con = mysql_connect ("gamelogin.db.6086537.hostedresource.com","gamelogin","-----") or die(mysql_error()); $db = mysql_select_db("gamelogin",$con) or die(mysql_error()); $result4 = mysql_query("SELECT petname FROM user_pets WHERE username = '$username' AND breeding = 'yes'"); echo "<b><u>Pets breeding:</u></b><br>"; echo "$result4<br>"; if ( $_POST['female'] && $_POST['male']) { // $male = $_POST['male']; $female = $_POST['female']; // echo "Breeding Female: $female<br />"; echo "with male : $male<br />"; // ---------------- CONNECT TO DATABASE ---------------------- $con = mysql_connect ("gamelogin.db.6086537.hostedresource.com","gamelogin","----") or die(mysql_error()); $db = mysql_select_db("gamelogin",$con) or die(mysql_error()); // // ------------ UPDATE DATABASE WITH FEMALE BREEDING = YES (USE ID) -------- $result2 = mysql_query("UPDATE user_pets SET breeding='yes' WHERE id='$female'") or die(mysql_error()); // // ------------ UPDATE DATABASE WITH MALE BREEDING = YES (USE ID) ----------- $result3 = mysql_query("UPDATE user_pets SET breeding='yes' WHERE id='$male'") or die(mysql_error()); // } else // ------------form hasn't been filled, so show form // ------------MALE FORM --------- ?><br><br><u>Males:</u><br> <form id="breed" action="test.php" method="post"> <?php $con = mysql_connect ("gamelogin.db.6086537.hostedresource.com","gamelogin","----") or die(mysql_error()); $db = mysql_select_db("gamelogin",$con) or die(mysql_error()); $query="SELECT petname,id FROM user_pets WHERE username = '$username' AND gender = 'male'"; $result = mysql_query ($query); echo "<select name=\"male\" value=\"male\">male</option>"; // printing the list box select command while($nt=mysql_fetch_array($result)){//Array or records stored in $nt echo "<option value=$nt[id]>$nt[petname]</option>"; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box // ------------FEMALE FORM --------- ?> <br><br><br> <u>Females:</u><br> <?php $con = mysql_connect ("gamelogin.db.6086537.hostedresource.com","gamelogin","-------") or die(mysql_error()); $db = mysql_select_db("gamelogin",$con) or die(mysql_error()); $query="SELECT petname,id FROM user_pets WHERE username = '$username' AND gender = 'female'"; $result = mysql_query ($query); echo "<select name='female' value='female'>Female</option>"; // printing the list box select command while($nt=mysql_fetch_array($result)){//Array or records stored in $nt echo "<option value=$nt[id]>$nt[petname]</option>"; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box ?> <br><br><br><input type="submit" value="submit"><br><br><br></form> <u>NOTE:</u><i> Once a pair has begun bonding, you may not use them for fighting or any other task during that time. Bonding processes vary widely in length, so be careful with your decision!</I><br>
  4. i decided to post my code, since i really don't want people to think i'm trying to get freebies. but i realize it sucks... i've only been doing php for about two weeks now. it isn't showing ANYTHING in the female or male form when i try to load it. you can see the test page here: http://fiendfashion.biz/ferrin/test.php on top of it not showing anything, i can't figure out how to make it only save the breeding 'yes' to the selected pet. i was planning to use the pet 'id' but i don't want it to show to the user. <?php session_start(); $username= $_SESSION['username']; // --------------check if form has been filled // echo "$username<br>"; if ( $_POST['male'] && $_POST['female']) { // $male = $_POST['male']; $female = $_POST['female']; $id = $_POST['id']; // echo "Female selected: $female<br />"; echo "Male selected: $male<br />"; echo "id of female: $id<br><br>"; // // $con = mysql_connect("gamelogin.db.6086537.hostedresource.com","gamelogin","-----"); if (!$con) { die('Could not connect: ' . mysql_error()); } // ----- ADD BREEDING FEMALES TO TABLE ---------- mysql_select_db("gamelogin", $con); $query="SELECT petname FROM user_pets where username = '$username' AND gender = 'female' breeding = 'yes' ORDER BY petname"; $result = mysql_query ($query); echo "<select petname=females=''>females</option>"; // if (!$query or mysql_num_rows($query)) { echo "Empty"; } else { // printing the list box select command while($nt=mysql_fetch_array($result)){//Array or records stored in $nt echo "<option value=$nt[id]>$nt[petname]</option>"; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box // // } // ----- ADD BREEDING MALES TO TABLE ---------- $sql="SELECT * FROM user_pets WHERE username like '$username' AND breed like '$breeding' ORDER BY gender"; $result=mysql_query($sql); ?> <table width="300" border="0" cellspacing="1" cellpadding="0"> <tr> <td><table width="400%" border="0" cellpadding="3" cellspacing="1" bgcolor="#000000"> <tr> <td bgcolor="#000000"> </td> <td colspan="4" bgcolor="#000000"><strong>Breeding Pets</strong> </td> </tr> <tr> <td align="center" bgcolor="#000000"><strong>id</strong></td> <td align="center" bgcolor="#000000"><strong>element</strong></td> <td align="center" bgcolor="#000000"><strong>pet species</strong></td> <td align="center" bgcolor="#000000"><strong>age</strong></td> <td align="center" bgcolor="#000000"><strong>age</strong></td> <td align="center" bgcolor="#000000"><strong>gender</strong></td> <td align="center" bgcolor="#000000"><strong>breeding</strong></td> <td align="center" bgcolor="#000000"> </td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <table width="340" border="1" cellspacing="0" cellpadding="3"> <tr> <td width="5%"><?php echo $rows['id']; ?></td> <td width="20%"><?php echo $rows['type']; ?></td> <td width="25%"><?php echo $rows['petname']; ?></td> <td width="10%"><?php echo $rows['age']; ?></td> <td width="10%"><?php echo $rows['gender']; ?></td> <td width="10%"><?php echo $rows['breed']; ?></td> </tr> </table> <?php } // close while loop echo "</div>"; // close connection; mysql_close(); } else // ------------form hasn't been filled, so show form // ------------FEMALE FORM --------- ?><br><br>Females<br><?php $con = mysql_connect ("gamelogin.db.6086537.hostedresource.com","gamelogin","-------") or die(mysql_error()); $db = mysql_select_db("gamelogin",$con) or die(mysql_error()); $query="SELECT petname FROM user_pets where username = '$username' AND gender='female' AND breeding='' ORDER BY petname"; $result = mysql_query ($query); echo "<select name=femalepets=''>females</option>"; // printing the list box select command while($nt=mysql_fetch_array($result)){//Array or records stored in $nt echo "<option value=$nt[id]>$nt[females]</option>"; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box // --------- MALE FORM ---------- ?><br><br>Males<br><?php $con = mysql_connect ("gamelogin.db.6086537.hostedresource.com","gamelogin","-------") or die(mysql_error()); $db = mysql_select_db("gamelogin",$con) or die(mysql_error()); $query="SELECT petname FROM user_pets where username = '$username' AND gender='male' AND breeding='' ORDER BY petname"; $result = mysql_query ($query); echo "<select name=malepets=''>males</option>"; // printing the list box select command while($nt=mysql_fetch_array($result)){//Array or records stored in $nt echo "<option value=$nt[id]>$nt[males]</option>"; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box ?>
  5. i'm making a game with little pets and you can breed the pets using a form. i'd post code, but at this point my code is so packed with errors that i probably need to just completely rewrite it. i have no clue how to go about this and i've tried everything for two days now, including googling to death. this is what i'm trying to do: create a form that shows a list of the females the user owns, and the males the user owns. you must select a female from the females, and a male from the males, using a simple form like so: Select a female: (dropdown menu listing all females user has that are able to breed) Select a male: (dropdown menu listing all males user has that are able to breed) Submit button then the script checks the database to see if the pet is able to breed, meaning that the column 'breed' is not set to 'breeding'. a pet that is currently breeding is unable to breed for a random number of days. if the pet is able to breed, then the value of 'breeding' is added to the 'breed' part of the database. the database looks like this: http://i44.tinypic.com/5ul3tl.jpg below the form is a table showing pets currently breeding. i have tried -everything-. i have so many errors that it's just ridiculous to try and go about posting my code as is. if you -really- want to see it, i'll post it. i'm not really asking someone to just write this up for me, because i know that's lame to do, but i need some serious help here, if anyone would be so kind.
  6. i can't figure out how to edit my last post, so please forgive me for posting twice. but if i use the PRG method, wouldn't it still be possible for say, someone to right-click and open a link in a new tab, then click it again on the main page, thus getting two creatures out of one link? ie, cheating?
  7. oh, okay, i see. so basically, instead of using POST, i send a GET command with a header location redirect from the creature url on explore.php, to the assign.php, which then redirects the user to getpet.php? or in doing this, would i no longer need the inbetween? the assign.php? it would be great if clicking the url of the creature could automatically assign the $petsname variable to the pet name, then direct them to the getpet.php, which would retrieve the variable, assign info accordingly, and then refreshing the page would send them back to explore.php. the current problem is that if a user refreshes the page, they can get the creature again. is PRG secure? that and i have no clue how to write out the above code. if you look at the structure of the creature links, when i tried to add any further commands it gives me a t-string and whitespace error. i appreciate the help, by the way. thank you.
  8. i really need some help, i've tried everything and as someone who hasn't been coding long at all, i'm stumped. issue one: my project is simple and designed to be fun as well as help me learn coding. basically, i'm making a small, text based rpg pet game. think pokemon. you start out at a page where you click to 'walk around' and random pokemon pop up. when you click a pokemon, you're directed to a page that informs you you've caught it, and then saves the information to the database. this is my first remotely big coding thing. i'm really happy with how it's gone so far. i just -cannot- find a way to do one stupid, simple thing. i need to send a session or cookie or basically, find some way of sending one variable (the petsname variable, which of course indicates the name of the creature) to the next page. the next page (assign.php) is designed to take the information in the variable and assign it to a session (session(petsname)), then it automatically redirects to another page. you don't even see the page that assigns the session, so it looks like you go from the first page (explore.php) where you found the pet, to the page where it assigns the attributes and adds to the database, then tells you about your pet (gotpet.php). the reason i need to send the variable is because the gotpet.php page has a switch (multidemensional?) that has the data of all the pokemon stored. depending on the variable sent to it, the information is stored. what i need to do: make so that the user can only get the pokemon once. ie: can't refresh the gotpet.php page or whatever to have the information sent twice. this is why i want to insert a cookie or session or something into the hyperlink associated with the pet. the cookie or session must be destroyed upon having received the pet. it needs to be secure, of course. second issue: if you look at the explore.php page, you'll notice an ugly iframe chat thing. i had originally wanted to put the chat into a div, couldn't figure out how (i was told to use ajax, but ajax is far beyond my current level of code abilities) without it refreshing the entire page vs. the div only, so. yeah. it's ugly and to admit to my utter stupidity, i have no clue how to make the chat smaller/fit/look nice. attached is a zip of the entire chat directory contents. the chat is made from a tutorial, some parts i don't understand, some i do. i would GREATLY appreciate any help from anyone. seriously. i've been stuck on this for days and it's driving me crazy. i've exhaustively googled and asked people on other help sites, but they generally seem to be irritated at me for the fact that i don't have the level of skill for some of this stuff. i am a willing learner, i'm not just asking someone to do this for me. i apologize for the long writing here, but i'm extremely frustrated and this is the last place i've found to try and get some help. thank you in advance. following is the code for the pet pages: explore.php getpet.php assign.php explore.php NOTE: i would like to replace the individual links (charmander.php, etc) with just the assign.php once i have this figured out. right now it defaults to individual creature pages, which are hardly secure and take up too much space. the only one currently working, though, is the charmander.php page. http://fiendfashion.biz/ferrin/explore.php <?php // include "db.php"; ?> <html> <head><link rel="stylesheet" href="style.css"> <title><?php echo $_SESSION['username']; ?>'s Travels in Neverland</title> </head> <body> <iframe src="chat/source/index.php" width="350px" height="270px" style="position:absolute; top:10px; left:5px"> Your browser does not support iframes. Chat may be accessed <a href="chat/source/index.php" target="new">here</a>. </iframe> <?php // random gen function function dodosrandgen() { // set number of links you want to show at once $show_link = 1; // separate the links by, i.e. comma would be ","; $separator = ""; // $links[0][link] = "<table width=\"250\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><a href=\"http://fiendfashion.biz/ferrin/charmander.php\"><img src=\"images/charmander.gif\" border=\"0\" align=\"right\" width=\"50\" height=\"50\" style=\"filter:alpha(opacity=40)\" onMouseover=\"high(this)\" onMouseout=\"low(this)\"></a></td></tr></table>"; $links[0][priority] = 1; $links[1][link] = "<table width=\"250\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><a href=\"http://fiendfashion.biz/ferrin/vulpix.php\"><img src=\"images/vulpix.gif\" border=\"0\" align=\"right\" width=\"50\" height=\"50\" style=\"filter:alpha(opacity=40)\" onMouseover=\"high(this)\" onMouseout=\"low(this)\"></a></td></tr></table>"; $links[1][priority] = 1; $links[2][link] = "<table width=\"250\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><a href=\"http://fiendfashion.biz/ferrin/weedle.php\"><img src=\"images/weedle.gif\" border=\"0\" align=\"right\" width=\"50\" height=\"50\" style=\"filter:alpha(opacity=40)\" onMouseover=\"high(this)\" onMouseout=\"low(this)\"></a></td></tr></table>"; $links[2][priority] = 10; $links[3][link] = "<table width=\"250\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><a href=\"http://fiendfashion.biz/ferrin/caterpie.php\"><img src=\"images/caterpie.gif\" border=\"0\" align=\"right\" width=\"50\" height=\"50\" style=\"filter:alpha(opacity=40)\" onMouseover=\"high(this)\" onMouseout=\"low(this)\"></a></td></tr></table>"; $links[3][priority] = 10; $links[4][link] = "<table width=\"250\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><a href=\"http://fiendfashion.biz/ferrin/rattata.php\"><img src=\"images/rattata.gif\" border=\"0\" align=\"right\" width=\"50\" height=\"50\" style=\"filter:alpha(opacity=40)\" onMouseover=\"high(this)\" onMouseout=\"low(this)\"></a></td></tr></table>"; $links[4][priority] = 10; $links[5][link] = "<table width=\"250\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><a href=\"http://fiendfashion.biz/ferrin/spearow.php\"><img src=\"images/spearow.gif\" border=\"0\" align=\"right\" width=\"50\" height=\"50\" style=\"filter:alpha(opacity=40)\" onMouseover=\"high(this)\" onMouseout=\"low(this)\"></a></td></tr></table>"; $links[5][priority] = 10; $links[6][link] = "<table width=\"250\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><img src=\"images/null.gif\" border=\"0\" align=\"right\" width=\"50\" height=\"50\" style=\"filter:alpha(opacity=40)\" onMouseover=\"high(this)\" onMouseout=\"low(this)\"></td></tr></table>"; $links[6][priority] = 45; $links[7][link] = "<table width=\"250\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><img src=\"images/null.gif\" border=\"0\" align=\"right\" width=\"50\" height=\"50\" style=\"filter:alpha(opacity=40)\" onMouseover=\"high(this)\" onMouseout=\"low(this)\"></td></tr></table>"; $links[7][priority] = 45; $links[8][link] = "<table width=\"250\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><a href=\"http://fiendfashion.biz/ferrin/jigglypuff.php\"><img src=\"images/jigglypuff.gif\" border=\"0\" align=\"right\" width=\"50\" height=\"50\" style=\"filter:alpha(opacity=40)\" onMouseover=\"high(this)\" onMouseout=\"low(this)\"></a></td></tr></table>"; $links[8][priority] = 1; $links[9][link] = "<table width=\"250\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><a href=\"http://fiendfashion.biz/ferrin/oddish.php\"><img src=\"images/oddish.gif\" border=\"0\" align=\"right\" width=\"50\" height=\"50\" style=\"filter:alpha(opacity=40)\" onMouseover=\"high(this)\" onMouseout=\"low(this)\"></a></td></tr></table>"; $links[9][priority] = 9; $links[10][link] = "<table width=\"250\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><a href=\"http://fiendfashion.biz/ferrin/pidgey.php\"><img src=\"images/pidgey.gif\" border=\"0\" align=\"right\" width=\"50\" height=\"50\" style=\"filter:alpha(opacity=40)\" onMouseover=\"high(this)\" onMouseout=\"low(this)\"></a></td></tr></table>"; $links[10][priority] = 9; $links[11][link] = "<table width=\"250\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><a href=\"http://fiendfashion.biz/ferrin/ekans.php\"><img src=\"images/ekans.gif\" border=\"0\" align=\"right\" width=\"50\" height=\"50\" style=\"filter:alpha(opacity=40)\" onMouseover=\"high(this)\" onMouseout=\"low(this)\"></a></td></tr></table>"; $links[11][priority] = 9; $links[12][link] = "<table width=\"250\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><a href=\"http://fiendfashion.biz/ferrin/hoothoot.php\"><img src=\"images/hoothoot.gif\" border=\"0\" align=\"right\" width=\"50\" height=\"50\" style=\"filter:alpha(opacity=40)\" onMouseover=\"high(this)\" onMouseout=\"low(this)\"></a></td></tr></table>"; $links[12][priority] = 9; $links[12][link] = "<table width=\"250\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><a href=\"http://fiendfashion.biz/ferrin/fairy1.php\"><img src=\"images/fairy1.gif\" border=\"0\" align=\"right\" width=\"50\" height=\"60\" style=\"filter:alpha(opacity=40)\" onMouseover=\"high(this)\" onMouseout=\"low(this)\"></a></td></tr></table>"; $links[12][priority] = 5; // HERE COMES THE BODY if($links) { for($i = -1; $i < count($links); $i++) { for($j = 0; $j < $links[$i][priority]; $j++) { $newlinksindex = count($newlinks) + 1; $newlinks[$newlinksindex] = $links[$i][link]; } } } // end of if link exist // debug if($show_link >= count($newlinks)) $show_link = count($newlinks); $showarray[0] = ""; $showindex = 0; // Select a random element from the new array do { $randindex = rand(0, count($newlinks)); if(!in_array($newlinks[$randindex], $showarray) && $newlinks[$randindex] != "") { $showarray[$showindex] = $newlinks[$randindex]; //print_r($showarray); $showindex++; } }while(count($showarray) <= $show_link); // finally print out for($i = 0; $i < $show_link; $i++ ) { if($show_link == 1 || (($i + 1) == $show_link)) print $showarray[$i]; else print $showarray[$i].$separator; } //print_r($ranarray); //print_r($links); //print_r($newlinks); } // end of the dodosrandgen function ?> <div class="divider" id="randomright"> <?php dodosrandgen(); ?> </div> <div class="divider" id="random"><p align="center"> <br><br><u>Walking through Neverland</u><br><br> What a curious place. You can <a href="explore.php">look around</a> some more,<br />or if you see something you want, pick it up.<br /><br /> <br /><a href="inventory">Your Things</a> | <a href="pets">Your Pets</a> | <a href="http://www.fiendfashion.biz/game/home.php">Your Profile</a> | <a href="logout.php">Logout</a></p></div> <div class="divider" id="randomleft"> <?php dodosrandgen(); ?> </body> </html> getpet.php http://fiendfashion.biz/ferrin/test-gotpet.php <?php session_start(); $_SESSION['loggedin'] . '<br />'; $_SESSION['gotpet'] . '<br />'; $_SESSION['petsname'] . '<br />'; $petsname = $_SESSION['petsname']; //include "db.php"; // 'get pet' form echo "<head><link rel=\"stylesheet\" href=\"style.css\"></head> <body> <br><br> <div class=\"divider\" id=\"getthepet\" align=\"center\"> <img src=\"images/charmander.gif\" alt=\"Char! Char!\"> <form action=\"test-gotpet.php\" method=\"post\" /> <input type=\"radio\" name=\"userchoice\" value=\"Getpet\" title=\"userchoice\" /> Get 'Em!<br /><br /> <input type=\"radio\" name=\"userchoice\" value=\"Leave\" title=\"userchoice\" /> Leave<br /><br /> <input type=\"submit\" value=\"submit\" name=\"submit_btn\"></form> </div> </body> \n"; ini_set('display_errors', 1); error_reporting(E_ALL); if ( $_POST && isset($_POST['userchoice']) ) { $userChoice = htmlspecialchars($_POST['userchoice']); switch( $userChoice ) { case 'Getpet': // // now find out which pet was selected // and list info // using a switch function switch ( $petsname ) { case "caterpie": $petinfo = 'A small caterpillar'; $type = 'bug'; $attack1 = 'stringshot'; $attack2 = 'tackle'; break; case "charmander": $petinfo = 'A firey salamandar'; $type = 'fire'; $attack1 = 'growl'; $attack2 = 'scratch'; break; case "ekans": $petinfo = 'a vicious snake'; $type = 'poison'; $attack1 = 'tackle'; $attack2 = 'growl'; break; default: echo "ERROR - unknown creature - please inform admin. "; break; } // change this later- username $username = 'guest'; // add age $age = rand(1, 3); // //get random stats $str = rand(10, 13); $def = rand(8, 11); // // determine hp/mp by def/str - mp first // if($str == '13') // set high mp { $mp = rand(13, 15);} elseif($str == '12') { $mp = rand(11, 13);} // set medium mp else { $mp = rand(9, 11);} // // next determine hp // if($def == '13') // set high mp { $hp = rand(13, 15);} elseif($def == '12') { $hp = rand(11, 13);} // set medium mp else { $hp = rand(9, 11);} // // get gender $gen = rand(1, 2); if($gen == '1'){$gender = 'female';} else {$gender = 'male';} // // save info to database // $con = mysql_connect ("gamelogin.db.6086537.hostedresource.com","gamelogin","-----") or die(mysql_error()); $db = mysql_select_db("gamelogin",$con) or die(mysql_error()); $sql = "INSERT INTO `user_pets` (`type`, `petname`, `username`, `age`, `hp`, `mp`, `str`, `def`, `attack1`, `attack2`) VALUES ('$type', '$petsname', '$username', '$age', '$hp', '$mp', '$str', '$def', '$attack1', '$attack2')"; mysql_query( $sql ) or die ( mysql_error() ); // // tell user pet info // echo "<div class=\"divider\" id=\"gotthepet\" align=\"center\">"; echo "You got a $petsname!<br><br>"; // announces user got the creature echo "{$petinfo}<br><br>"; echo "Your new pet, {$petsname}, is a {$type}-type!<br>"; echo "It is {$age} years old.<br>"; echo "It's abilities are {$attack1} and {$attack2}.<br>"; echo "{$str} is it's strength and {$def} is it's defense.<br>"; echo "It's health is {$hp}, while it has {$mp} move points.<br>"; echo "{$petsname}'s gender is {$gender}.<br><br>"; echo "<a href=\"explore.php\">Leave</a>"; echo "</div>"; // // ^-- end add pet code // //need to add txt file // break; echo "</div>"; case 'Leave': // do something header ('explore.php'); break; } }?> assign.php <?php session_start(); $_SESSION['loggedin'] = "logged"; $_SESSION['gotpet'] = "gotpet"; $_SESSION['petsname'] = "charmander"; header( 'Location: test-gotpet.php' ) ; ?> [attachment deleted by admin]
×
×
  • 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.