Jump to content

Demont

Members
  • Posts

    50
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Demont's Achievements

Member

Member (2/5)

0

Reputation

  1. Hmm, that didn't seem to work, it just re-ordered one of the monsters.
  2. I'm working on a project, a game, and right now my main issue, though minor is annoying none the less. Users have a list of monsters to choose from, in a drop down box which is populated by the database and ordered by monster level. print "<form action=\"killmonster.php\" method=\"post\">"; print "<select name=\"monstername\" length=\"20\">"; $command3 = "SELECT * from ext_monsters order by lvl asc"; $query3 = mysql_query($command3) or die($db_error); while ($monster = mysql_fetch_array($query3)) { if ($_POST['monstername'] == $monster['name']) { print "<option value=\"".$monster['name']."\" selected=\"selected\">".$monster['name']."</option>"; } else { print "<option value=\"".$monster['name']."\">".$monster['name']."</option>"; } } This is my form for selecting a monster. Now my question is, how do I get the form to hold onto the last option(Monster) that the user chose, so that they don't have to go back to the drop down and find the monster again? What I have now, should work, but it doesn't. The if() statement is just bypassed, and I can't figure out why. Resulting PHP after submit: <center><table width="512" cellpadding="5px" align="center" border="1" style="border-style:dashed; border-width:thin; border-collapse:collapse;" cellspacing="0px"> <tr><td> <center></td> </center><td>Inventory</tr><tr><td> <center>Select the monster you would like to attack:<br /><br> <form action="killmonster.php" method="post"><select name="monstername" length="20"> <option value="Rabbit">Rabbit</option> <option value="Stone Rabbit">Stone Rabbit</option> <option value="Snake">Snake</option> <option value="Cat">Cat</option> <option value="Kobold">Kobold</option> <option value="Brekek">Brekek</option> <option value="Wollo">Wollo</option> <option value="Fae">Fae</option> <option value="Mad Hatter">Mad Hatter</option> <option value="Phoenix">Phoenix</option> <option value="Ho-Ho">Ho-Ho</option> <option value="Fairy Guard">Fairy Guard</option> <option value="Fairy Captain">Fairy Captain</option> <option value="Tree Spirit">Tree Spirit</option> <option value="Tree Spirit Lord">Tree Spirit Lord</option> <option value="Daiku">Daiku</option> <option value="Banshee">Banshee</option> <option value="Medusa Soldier">Medusa Soldier</option> <option value="Medusa">Medusa</option></select> <br><br /> <input type="hidden" name="monsterhp" value="0" /> <input type="submit" name="submit" value="Attack Monster!"><br /><br /> <select name="spell" length="20"> <option value="0">(Select Skill To Cast)</option> <input type="submit" name="cast" value="Cast Spell!"></form></td> <center><td><select name="gemname" width="20" length="20"></select></center></td></tr><br /> </table> </center>
  3. What I mean is, I have a custom script for a MUD(Multi-User Dungeon) to add rooms in the 'world', which is this: <?php require("sessions.php"); include("connect.php"); include("userinfo.php"); $result = mysql_query("select * from rooms where room='$roomin' order by room"); while($row = mysql_fetch_array($result)){ $roomname=$row['roomname']; $roomdesc=$row['roomdesc']; $room=$row['room']; $north=$row['north']; $south=$row['south']; $east=$row['east']; $west=$row['west']; $up=$row['up']; $down=$row['down']; } //This code runs if the form has been submitted if (isset($_POST['submit'])) { //This makes sure they did not leave any fields blank if (!$_POST['roomname'] | !$_POST['roomdesc'] ) { die('You did not complete all of the required fields'); } // now we insert it into the database mysql_query("UPDATE rooms SET roomname='".$_POST['roomname']."', roomdesc='".$_POST['roomdesc']."', north='".$_POST['north']."', south='".$_POST['south']."', east='".$_POST['east']."', west='".$_POST['west']."', up='".$_POST['up']."', down='".$_POST['down']."', mnorth='".$_POST['mnorth']."', msouth='".$_POST['msouth']."', meast='".$_POST['meast']."', mwest='".$_POST['mwest']."', mup='".$_POST['mup']."', mdown='".$_POST['mdown']."' WHERE room='$roomin'") or die(mysql_error()); ?> <title>The Roman Empire</title> <body bgcolor="grey"> <table width="800" border="1" cellpadding="0" align="center" bgColor="CC0000"> <!-- Row 1 --> <tr> <td width="800" align="center" valign="middle"> <font size="5"><font color="gold">The Roman Empire</font></font> <br> <a href="http://www.tregame.com" border="0"><img src="/img/spqr.jpg"></a> <br> </td> </tr> <tr> <td width="800" align="center" valign="middle"> <center><h1>Edited/Created</h1> <p>Room Edited/Created, go <a href="addroom.php">Back</a>.</p></center> </td> </tr> <?php } else { ?> <body bgcolor="grey"> <table width="800" border="1" cellpadding="0" align="center" bgColor="CC0000"> <!-- Row 1 --> <tr> <td width="800" align="center" valign="middle"> <font size="5"><font color="gold">The Roman Empire</font></font> <br> <a href="http://www.tregame.com" border="0"><img src="/img/spqr.jpg"></a> <br> <?php Print "You are editing $roomname <b>(Room Number): $roomin</b><br><br> It is connected to North: $north<br>South: $south<br>East: $east<br>West: $west<br>Up: $up<br>Down: $down"; ?> </td> </tr> <form action="addroom.php" method="post"> <table width="800" border="1" cellpadding="0" align="center" bgColor="CC0000"> <tr> <td width="400" align="center" valign="middle"> Room Name: </td> <td width="400" align="center" valign="middle"> <INPUT TYPE="text" NAME="roomname" SIZE="30" value="<?php Print $roomname; ?>"> </td> </tr> <tr> <td width="400" align="center" valign="middle"> Room Description: </td> <td width="400" align="center" valign="middle"> <TEXTAREA NAME="roomdesc" ROWS=6 COLS=40><?php Print $roomdesc; ?> </TEXTAREA> </td> </tr> <tr> <td width="400" align="center" valign="middle"> Connect North To(Click checkbox too): </td> <td width="400" align="center" valign="middle"> <?php print "<select name='north' length='20'>"; $room1="SELECT * from rooms order by room"; $room2=mysql_query($room1) or die("Could not select Room"); while ($room3=mysql_fetch_array($room2)) { print "<option>$room3[room]</option>"; } print "</select><br>"; ?> <INPUT TYPE="checkbox" NAME="mnorth" VALUE="1"> </td> </tr> <tr> <td width="400" align="center" valign="middle"> Connect South To(Click checkbox too if able to move south): </td> <td width="400" align="center" valign="middle"> <?php print "<select name='south' length='20'>"; $room1="SELECT * from rooms order by room"; $room2=mysql_query($room1) or die("Could not select Room"); while ($room3=mysql_fetch_array($room2)) { print "<option>$room3[room]</option>"; } print "</select><br>"; ?> <INPUT TYPE="checkbox" NAME="msouth" VALUE="1"> </td> </tr> <tr> <td width="400" align="center" valign="middle"> Connect East To(Click checkbox too if able to move east): </td> <td width="400" align="center" valign="middle"> <?php print "<select name='east' length='20'>"; $room1="SELECT * from rooms order by room"; $room2=mysql_query($room1) or die("Could not select Room"); while ($room3=mysql_fetch_array($room2)) { print "<option>$room3[room]</option>"; } print "</select><br>"; ?> <INPUT TYPE="checkbox" NAME="meast" VALUE="1"> </td> </tr> <tr> <td width="400" align="center" valign="middle"> Connect West To(Click checkbox too if able to move west): </td> <td width="400" align="center" valign="middle"> <?php print "<select name='west' length='20'>"; $room1="SELECT * from rooms order by room"; $room2=mysql_query($room1) or die("Could not select Room"); while ($room3=mysql_fetch_array($room2)) { print "<option>$room3[room]</option>"; } print "</select><br>"; ?> <INPUT TYPE="checkbox" NAME="mwest" VALUE="1"> </td> </tr> <tr> <td width="400" align="center" valign="middle"> Connect Up To(Click checkbox too if able to move up): </td> <td width="400" align="center" valign="middle"> <?php print "<select name='up' length='20'>"; $room1="SELECT * from rooms order by room"; $room2=mysql_query($room1) or die("Could not select Room"); while ($room3=mysql_fetch_array($room2)) { print "<option>$room3[room]</option>"; } print "</select><br>"; ?> <INPUT TYPE="checkbox" NAME="mup" VALUE="1"> </td> </tr> <tr> <td width="400" align="center" valign="middle"> Connect Down To(Click checkbox too if able to move down): </td> <td width="400" align="center" valign="middle"> <?php print "<select name='down' length='20'>"; $room1="SELECT * from rooms order by room"; $room2=mysql_query($room1) or die("Could not select Room"); while ($room3=mysql_fetch_array($room2)) { print "<option>$room3[room]</option>"; } print "</select><br>"; ?> <INPUT TYPE="checkbox" NAME="mdown" VALUE="1"> </td> </tr> <tr><th colspan=2><input type="submit" name="submit" value="Add Room"></th></tr> </table> </form> <table width="800" border="1" cellpadding="0" align="center" bgColor="CC0000"> <!-- Row 1 --> <tr> <td width="800" align="center" valign="middle"> <center><b><p>IMPORTANT:If you want the room to be able to connect to another, you have to click the check box. Also, if you reedit a room, you need to make sure that the previous connections are put back in place!</b></p></center> </td> </tr> </table> <?php } ?> Now, when I edit a room, I have manually put in the direction of the previous room. Say, I want to add a room to the west, and I check the checkbox to enable movement to the west. What I don't know how to do, or go about doing, is making it so that the room to the west automatically updates to know that a room was added, and enable movement from the east back to the west. Add room to the west: Move west, have to remember room number of West and add it into the East room via drop down box. Now, another question: Each time I reedit a room, the values become reset and do not retain the values I previously set. How do I make it so that the values are automatically set to what they previously were, like the room numbers? Room 1 connects to room 123, for instance. How would I go about making so that each time I wanted to re-edit a room that the dropdown would be on room 123, and not back to 1?
  4. Invalid query: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
  5. I have a script I wrote to display information from the database into drop down menus, but NONE of the information from the database is being displayed... addroom.php <?php // Connects to your Database include("connect.php"); include("userinfo.php"); $result = mysql_query("SELECT * FROM rooms WHERE room='$roomin'"); while($row = mysql_fetch_array($result)){ $roomnumber=$row['room']; $roomname=$row['roomname']; $roomdesc=$row['roomdesc']; $north=$row['north']; $south=$row['south']; $east=$row['east']; $west=$row['west']; $up=$row['up']; $down=$row['down']; $mnorth=$row['mnorth']; $msouth=$row['msouth']; $meast=$row['meast']; $mwest=$row['mwest']; $mup=$row['mup']; $mdown=$row['mdown']; } //This code runs if the form has been submitted if (isset($_POST['submit'])) { //This makes sure they did not leave any fields blank if (!$_POST['roomname'] | !$_POST['roomdesc'] ) { die('You did not complete all of the required fields'); } // now we insert it into the database $insert = "INSERT INTO rooms (roomname,roomdesc,north,south,east,west,up,down,mnorth,msouth,meast,mwest,mup,mdown) VALUES ('".$_POST['roomname']."','".$_POST['desc']."','".$_POST['north']."','".$_POST['south']."','".$_POST['east']."','".$_POST['west']."','".$_POST['up']."', '".$_POST['down']."','".$_POST['mnorth']."','".$_POST['msouth']."','".$_POST['meast']."','".$_POST['mwest']."','".$_POST['mup']."', '".$_POST['mdown']."')"; $add_member = mysql_query($insert); ?> <title>The Roman Empire</title> <body bgcolor="grey"> <table width="800" border="1" cellpadding="0" align="center" bgColor="CC0000"> <!-- Row 1 --> <tr> <td width="800" align="center" valign="middle"> <font size="5"><font color="gold">The Roman Empire</font></font> <br> <a href="http://www.tregame.com" border="0"><img src="/img/spqr.jpg"></a> <br> </td> </tr> <tr> <td width="800" align="center" valign="middle"> <center><h1>Added/Created</h1> <p>Room Added/Created, go <a href="addroom.php">Back</a>.</p></center> </td> </tr> <?php } else { ?> <body bgcolor="grey"> <table width="800" border="1" cellpadding="0" align="center" bgColor="CC0000"> <!-- Row 1 --> <tr> <td width="800" align="center" valign="middle"> <font size="5"><font color="gold">The Roman Empire</font></font> <br> <a href="http://www.tregame.com" border="0"><img src="/img/spqr.jpg"></a> <br> You are editing <? Print $roomname; ?> </td> </tr> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table width="800" border="1" cellpadding="0" align="center" bgColor="CC0000"> <tr> <td width="400" align="center" valign="middle"> Room Name: </td> <td width="400" align="center" valign="middle"> <INPUT TYPE="text" NAME="roomname" SIZE="30" value="<? Print $roomname; ?>"> </td> </tr> <tr> <td width="400" align="center" valign="middle"> Room Description: </td> <td width="400" align="center" valign="middle"> <TEXTAREA NAME="roomdesc" ROWS=6 COLS=40 value="<? Print $roomdesc; ?>"> </TEXTAREA> </td> </tr> <tr> <td width="400" align="center" valign="middle"> Connect North To(Click checkbox too): </td> <td width="400" align="center" valign="middle"> <SELECT NAME="north" SIZE="1"> <option selected><? Print $roomnumber; ?> </SELECT> <INPUT TYPE="checkbox" NAME="mnorth" VALUE="1"> </td> </tr> <tr> <td width="400" align="center" valign="middle"> Connect South To(Click checkbox too if able to move south): </td> <td width="400" align="center" valign="middle"> <SELECT NAME="south" SIZE="1"> <option selected><? Print $roomnumber; ?> </SELECT> <INPUT TYPE="checkbox" NAME="msouth" VALUE="1"> </td> </tr> <tr> <td width="400" align="center" valign="middle"> Connect East To(Click checkbox too if able to move east): </td> <td width="400" align="center" valign="middle"> <SELECT NAME="east" SIZE="1"> <option selected><? Print $roomnumber; ?> </SELECT> <INPUT TYPE="checkbox" NAME="meast" VALUE="1"> </td> </tr> <tr> <td width="400" align="center" valign="middle"> Connect West To(Click checkbox too if able to move west): </td> <td width="400" align="center" valign="middle"> <SELECT NAME="west" SIZE="1"> <option selected><? Print $roomnumber; ?> </SELECT> <INPUT TYPE="checkbox" NAME="mwest" VALUE="1"> </td> </tr> <tr> <td width="400" align="center" valign="middle"> Connect Up To(Click checkbox too if able to move up): </td> <td width="400" align="center" valign="middle"> <SELECT NAME="up" SIZE="1"> <option selected><? Print $roomnumber; ?> </SELECT> <INPUT TYPE="checkbox" NAME="mup" VALUE="1"> </td> </tr> <tr> <td width="400" align="center" valign="middle"> Connect Down To(Click checkbox too if able to move down): </td> <td width="400" align="center" valign="middle"> <SELECT NAME="down" SIZE="1"> <option selected><? Print $roomnumber; ?> </SELECT> <INPUT TYPE="checkbox" NAME="mdown" VALUE="1"> </td> </tr> <tr><th colspan=2><input type="submit" name="submit" value="Add Room"></th></tr> </table> </form> <table width="800" border="1" cellpadding="0" align="center" bgColor="CC0000"> <!-- Row 1 --> <tr> <td width="800" align="center" valign="middle"> <center><b><p>If you want the room to be able to connect to another, you have to click the check box.</b></p></center> </td> </tr> </table> <?php } ?>
  6. I have a M.U.D. I am working on. Brower and PHP based. One thing I am having major trouble with is devising a way to add rooms, so that players can move around within the game world. I don't have any code for it, only the database tables. I table is called rooms, and stored the rooms(name, description, room number, and North,south,east,west,up, and down directions.) The only code I have relevant to that table in the database is the movementimage script. <? include("connect.php"); include("userinfo.php"); $result = mysql_query("SELECT * FROM rooms WHERE room='$roomin'"); while($row = mysql_fetch_array($result)){ $north=$row['north']; $east=$row['east']; $south=$row['south']; $west=$row['west']; $up=$row['up']; $down=$row['down']; } Print "<table width='135' height='135' border='.5' bgColor='CC0000' align='center'>"; Print "<tr>"; Print "<td> </td>"; Print "<td>"; if($north==1){ Print "<a href='movement.php?d=north'><img src='/system/img/north-active.gif' border='0'></a>"; } else { Print "<img src='/system/img/north-inactive.gif' border='0'>"; } Print "</td>"; Print "<td>"; if($up==1){ Print "<a href='movement.php?d=up'><img src='/system/img/up-active.gif' border='0'></a>"; } else { Print "<img src='/system/img/up-inactive.gif' border='0'>"; } Print "</td>"; Print "</tr>"; Print "<tr>"; Print "<td>"; if($west==1){ Print "<a href='movement.php?d=west'><img src='/system/img/west-active.gif' border='0'></a>"; } else { Print "<img src='/system/img/west-inactive.gif' border='0'>"; } Print "</td>"; Print "<td> </td>"; Print "<td>"; if($east==1){ Print "<a href='movement.php?d=east'><img src='/system/img/east-active.gif' border='0'></a>"; } else { Print "<img src='/system/img/east-inactive.gif' border='0'>"; } Print "</td>"; Print "</tr>"; Print "<tr>"; Print "<td> </td>"; Print "<td>"; if($south==1){ Print "<a href='movement.php?d=south'><img src='/system/img/south-active.gif' border='0'></a>"; } else { Print "<img src='/system/img/south-inactive.gif' border='0'>"; } Print "</td>"; Print "<td>"; if($down==1){ Print "<a href='movement.php?d=down'><img src='/system/img/down-active.gif' border='0'></a>"; } else { Print "<img src='/system/img/down-inactive.gif' border='0'>"; } Print "</td>"; Print "</tr>"; Print "</table>"; ?> And this: <? include("connect.php"); require("sessions.php"); include("userinfo.php"); include("functions.php"); $movewhere=$_GET[d]; move($movewhere); die(header('Location: room.php')); ?> What I need is help in adding the rooms to the database, and having the columns update(which is easy), but so that say I add a room to the north of a room already in existence, I need the room in the south to know that "hey, a room to the north was added, better update!". For the rooms table, the north,south,east and etc directions are a 1 or 0 value, to determine if a user should be allowed to go north, south and such. I have another table called roomdirections, which hold the directions, such as: ------- room: North: South: East: West: Up: Down ------- 1 : 2 : 0: 0: 3: 4: 0 ------- Basic, like that. Room one is connected to room 2 though the North, no exit south, or east, and connects to room 3 to the west, and goes Up, to room 4, and no exit down. I hope this isn't too confusing, and would appreciate any help anyone could give me. Thank you. If you need clarification, just ask.
  7. I have an RPG I've started programming, a MUD. My question, is how would I go about adding into the database, the age of the user's character based on my custom calendar system I have. Here is the code I have for the custom date. <?php $RealTimeDiff = date("U") - date("U",strtotime("Jan 01, 2008")); $GameTimeDiff = $RealTimeDiff * 4; $GameDate = strtotime("Jan 01, 1980") + $GameTimeDiff; $GameMonth = date("F", $GameDate); $GameYear =abs(date("Y", $GameDate) - 1980 - 450); $BirthYear =abs(date("Y", $GameDate) - 1980 - 433); $Age = $GameYear - $BirthYear; ?> With that, to display the date, I merely have to include the date.php, and print $GameMonth, $GameYear B.C. (as my game is based on The Roman Empire in 450 B.C.) I have, as you can see, the calculation to determine the age, based on the year, but I don't think it would work for every individual who would sign up, as the age would simply calculate the years, based on the current year, and not when that person actually registered. I figured, adding a timestamp of when the person registered, and include the same basic calculation would work, but I'm not sure how to do it. I had someone help me with this simple calculation, as my math skills are atrocious. Any help would be appreciated, and if it helps, here is the code I was going to use for the registration date. $c_hour = date("H"); //Current Hour $c_min = date("i"); //Current Minute $c_sec = date("s"); //Current Second $c_mon = date("m"); //Current Month $c_day = date("d"); //Current Day $c_year = date("Y"); //Current Year $c_timestamp = mktime($c_hour,$c_min,$c_sec,$c_mon,$c_day,$c_year); ... ... $insert = "INSERT INTO users (username,charname,regdate,etc...) VALUES ('".$_POST['username']."','".$_POST['fname']." ".$_POST['lname']."','$c_timestamp')"; $add_member = mysql_query($insert);
  8. I was having the problem Zepo was having. Nothing showing up, and now for some reason, users can't log in, and it has me stumped.
×
×
  • 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.