Jump to content

Drezard

Members
  • Posts

    244
  • Joined

  • Last visited

    Never

Everything posted by Drezard

  1. Need help with this error: 24. $name = $array_three[0]; 26. $array_four = "SELECT race, level, hp, mindamage, maxdamage, exp, gold FROM game_creatures WHERE name='$name'"; 28. $result_four = mysql_query($query_four) 30. $array_four = mysql_fetch_array($result_four); 32. } ERROR: Thanks, Daniel
  2. .... Okay, That wasn't my exact code.... I was just using that as an example. So theres no way to stop a loop? - Cheers, Daniel
  3. Hello, I have this loop here: while (true) { if (!isset($_POST['submit'])) { echo "<MY FORM>"; } } Now, when i run this code it just displays my form (as in a html form) a couple of hundred times and doesn't stop. What I want it to do is... Run through the loop but when it gets to the echo "<MY FORM>" bit i want it to stop the loop and continue once $_POST['submit'] exists... how do I do this? So basically i want this: while (true) { if (!isset($_POST['submit'])) { echo "<MY FORM>"; // STOP THE LOOP HERE AND WAIT FOR THE USER TO SUBMIT THE FORM } } What would be the code for what i want to do? - Cheers, Daniel
  4. Yea i have a page like that... thats what users.php is...
  5. Hello, my script should be displaying a form when loaded only prob is it doesnt display anything... <?php class class_session { function user_check($username, $password) { $query = "SELECT * FROM user_ids WHERE username='$username' AND password='$password'"; $result = mysql_query($query); $count = mysql_num_rows($result); if ($count == 0) { $this->validate = FALSE; } if ($count == 1) { $this->validate = TRUE; } } function user_loginform() { if (!isset($_POST['submit'])) { echo "<form action='' method='post'> Username: <input name='username' type='text'> <hr> Password: <input name='password' type='password'> <hr> <input type = 'submit' name = 'submit'> </form>"; } if (isset($_POST['submit'])) { if (!isset($_POST['username']) || trim($_POST['username']) == '') { die("Please enter your username"); } if (!isset($_POST['password']) || trim($_POST['password']) == '') { die("Please enter your password"); } $username = $_POST['username']; $password = $_POST['password']; $this->user_check($username, $password); if ($this->validate == FALSE) { die("Username or password incorrect"); } if ($this->validate == TRUE) { $timestamp = date('YmdGi'); $ip = $_SERVER['REMOTE_ADDR']; $query = "UPDATE user_ids SET timestamp='$timestamp', ip='$ip' WHERE username='$username'"; echo "Sucessfully logged in"; } } } } ?> Its running here... www.wintersword.com/users.php - Cheers, Daniel
  6. Yea, just a good layout (im not very good at CSS cause im a PHP programmer)
  7. Hello, Please check this code out for me: What I wanted was a standard 3 column design with a footer. The first column being 150px wide and being called 'left'. The second column being what ever is left in space and being called 'center'. The third column being 100px from the right side and being called 'right'. And then a footer in the middle at the bottom. Now heres my code: Styles.css /* CSS Document */ /* Version: 1.0 Purpose: This contains all the GUI and Sytles information to use in any HTML document a user will see. Created by: Drezard Last edited: Drezard, 5:59pm 14th March 2007 */ body { min-width: 550px; /* LC * 2 + RC */ max-width: 1200px; } #container { padding-left: 200px; padding-right: 150px; } #container .column { position: relative; float: left; } #center { width: 100%; } #left { width: 200px; right: 200px; margin-left: -100%; } #right { width: 150px; margin-right: -150px; } #footer { clear: both; text-align: center; } Template.html: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!-- HTML Document //--> <!-- Version: 1.0 Purpose: This document can be manipulated to be used as a template for any GUI page. Created by: Drezard Last edited: Drezard, 5:59pm 14th March 2007 //--> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <link rel="stylesheet" type="text/css" href="styles.css" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <div id='container'> <div id='center' class='column'> <p> CENTER </p> </div> <div id='left' class='column'> <p> LEFT </p> </div> <div id='right' class='column'> <p> RIGHT </p> </div> </div> <div id='footer'> <p> FOOT ME </p> </div> </body> </html> What have i done wrong? - Cheers, Daniel
  8. Hello, I have a number of scripts (too many to post) but in the other scripts they connect to the database, they also use this class and the functions within. Now... <?php error_reporting(E_ALL); include('core/main.inc.php'); class class_users { function user_signup() { if (!isset($_POST['submit'])) { echo "<form action='' method='post'> Username: <input name='username' type='text' maxvalue='32'> <hr> Password: <input name='password' type='password' maxvalue='32'> <hr> Confirm Password: <input name='password2' type='password' maxvalue='32'> <hr> Email: <input name='email' type='email' maxvalue='128'> <hr> Race: <select name='race'> <option value='human'>Human</option> <option value='vampire'>Vampire</option> <option value='shade'>Shade</option> </select> <hr> Class: <select name='class'> <option value='warrior'>Warrior</option> <option value='defender'>Defender</option> <option value='assasin'>Assasin</option> <option value='mage'>Mage</option> <option value='priest'>Priest</option> </select> <hr> <input type = 'submit' name = 'submit'><hr>"; } if (isset($_POST['submit'])) { if (!isset($_POST['username']) || trim($_POST['username']) == '') { die('Please insert username'); } if (!isset($_POST['password']) || trim($_POST['password']) == '') { die('Please enter a password'); } if (!isset($_POST['password2']) || trim($_POST['password2']) == '') { die('Please confirm your password'); } if (!isset($_POST['email']) || trim($_POST['email']) == '') { die('Please enter your email address'); } if (!isset($_POST['race']) || trim($_POST['race']) == '') { die('Please choose a race'); } if (!isset($_POST['class']) || trim($_POST['class']) == '') { die('Please choose a class'); } if ($_POST['password'] != $_POST['password2']) { die('Passwords do not match'); } $username = $_POST['username']; $password = $_POST['password']; $email = $_POST['email']; $race = $_POST['race']; $class = $_POST['class']; $timestamp = date('YmdGi'); $ip = $_SERVER['REMOTE_ADDR']; $priv = 1; $query = "SELECT * FROM user_ids WHERE username='$username'"; $result = mysql_query($query); $count = mysql_num_rows($result); if ($count == 1) { echo "Username already exists"; } if ($count == 0) { $query = "INSERT INTO user_ids (user, password, priv, timestamp, ip) VALUES ('$username', '$password', '$priv', '$timestamp', '$ip')"; $result = mysql_query($query); $this->user_charcreate($username, $race, $class); echo "Account created"; } } } function user_charcreate($username, $race, $class) { if ($race == 'human') { $strength = 10; $dexerity = 10; $constitution = 10; $intelligence = 10; } if ($race == 'vampire') { $strength = 12; $dexerity = 8; $constitution = 12; $intelligence = 8; } if ($race == 'shade') { $strength = 12; $dexerity = 12; $constitution = 8; $intelligence = 8; } if ($class == 'warrior') { $strength = $strength + 2; $dexerity = $dexerity + 2; $constitution = $constitution - 2; $intelligence = $intelligence - 2; } if ($class == 'defender') { $strength = $strength + 2; $dexerity = $dexerity - 2; $constitution = $constitution + 4; $intelligence = $intelligence - 4; } if ($class == 'assasin') { $strength = $strength + 2; $dexerity = $dexerity + 2; $constitution = $constitution - 2; $intelligence = $intelligence - 2; } if ($class == 'mage') { $strength = $strength - 2; $dexerity = $dexerity + 2; $constitution = $constitution - 4; $intelligence = $intelligence + 4; } if ($class == 'healer') { $strength = $strength - 2; $dexerity = $dexerity - 4; $constitution = $constitution + 2; $intelligence = $intelligence + 4; } $query = "INSERT INTO user_charinfo (username, strength, dexerity, constitution, intelligence) VALUES ('$username', '$strength', ' '$dexerity', '$constitution', '$intelligence')"; $result = mysql_query($query); } } ?> Thats my code... But when I run it, insert stuff into the form and such it says "Account created" but it doesn't insert it into the database. The database just stays blank. What could be wrong? - Cheers, Daniel (This script is running on www.wintersword.com/register)
  9. Hello, what is the shortest code to retrieve variable(s) from a MySQL Database? I have a few variables i need retrieved and each time i do it, it takes up about 8 lines of code... - Cheers, Daniel
  10. Error: } function user_numberonline(); $timestamp = date(YmdGi); $old_timestamp = $timestamp - 5; $query = "SELECT * FROM user_ids WHERE timestamp > '$old_timestamp'"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $count = mysql_num_rows($result); echo "<p>Users online: $count</p>"; } Cheers, Daniel
  11. Hello What does this error mean? Fatal error: Non-abstract method USERS::user_numberonline() must contain body in C:\Program Files\xampp\htdocs\wintersword\includes\users.php on line 310 Cheers, Daniel
  12. What does this error mean? Heres the code... $query = "INSERT INTO user_charinfo (user, level, race, class, money, strength, constitution, dexerity, intelligence, exp_cur, exp_max, hp_cur, hp_max, mp_cur, mp_max) VALUES ('$this->user', '$this->level', '$this->race', '$this->class', '$this->money', '$strength', '$constitution', '$dexerity', '$intelligence', '$this->exp_cur','$this->exp_max', '$this->hp_cur', '$this->hp_max', '$this->mp_cur', '$this-> mp_max')"; Whats wrong? - Cheers, Daniel
  13. Hello, I have a class definition in a file called Class.php: class NEW { function DISPLAY() { echo "<p> Display </p>"; } } And then in a new file called use.php I have this code: <html> <head> <style type="text/css"> p {font-family: courier} </style> </head> <body> <?php include('class.php'); $CLASS = new NEW; $CLASS->DISPLAY(); ?> </body> </html> Okay, So it basically displays the word "Display". But, I wont it to display the word "display" in my style. How do i do it? - Cheers, Daniel
  14. Hello, CSS code to make an element in capitals? - Cheers, Daniel
  15. Hello, What does this error mean? It relates to this line of code: $query ="UPDATE user_currents SET hp_cur='$this->hp_cur', hp_max='$this->hp_max', mp_cur='$this->mp_cur', mp_max='$this->mp_max' exp_cur='$this->exp_cur', exp_max='$this->exp_max' WHERE user='$user'"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); Cheers, Daniel
  16. Hello.... What is the PHP Rounding function? E.G: I have two variables: $1 = 10; $2 = 25; Now, I want to divide these by 10: $3 = $1 / $2; But, I dont want $3 to be a decimal. So.... How would I round $3 to the nearest whole number? (Up, down or using the swiss rounding system i dont care) - Cheers, Daniel
  17. I have... Maybe I shall rewrie the script. Any ideas on a faster way to write it (new SQL syntax i could use, some better code?)... Cheers, Daniel
  18. mmmm, me too. I have no clue what is wrong? - Cheers, Daniel
  19. Parse error: syntax error, unexpected ';', expecting T_FUNCTION in /home/wintersw/public_html/includes/admin.php on line 303 Ill have alook now aswell. <?php class ADMIN { var $priv; function admin_viewpanel() { if (!isset($_SESSION['userinfo'])) { echo "You need to be logged in to view this"; } if (isset($_SESSION['userinfo'])) { $session_array = explode(" ", $_SESSION['userinfo']); $user = $session_array[0]; $query = "SELECT priv FROM user_ids WHERE user='$user'"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); if (mysql_num_rows($result) > 0) { while(list($priv) = mysql_fetch_row($result)) { $this->priv = $priv; } } if ($this->priv != 7) { echo "You don't have the permission to view this"; } if ($this->priv == 7) { echo "<a href='admin_viewusers.php'><img border='0' src='images/admin_viewdatabase.gif' width='49' height='48'> <a> <br>"; echo "<span class='style2'><a href='admin_viewusers.php'>User Edit</a></span>"; } } } function admin_viewusers() { if (!isset($_SESSION['userinfo'])) { echo "You need to be logged in to view this"; } if (isset($_SESSION['userinfo'])) { $session_array = explode(" ", $_SESSION['userinfo']); $user = $session_array[0]; $query = "SELECT priv FROM user_ids WHERE user='$user'"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); if (mysql_num_rows($result) > 0) { while(list($priv) = mysql_fetch_row($result)) { $this->priv = $priv; } } if ($this->priv != 7) { echo "You don't have the permission to view this"; } if ($this->priv == 7) { echo "USER PASS PRIV TIMESTAMP<br> <br>"; $query = "SELECT user, password, priv, timestamp FROM user_ids"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); if (mysql_num_rows($result) > 0) { while($row = mysql_fetch_row($result)) { echo "$row[0] - "; echo "$row[1] - "; echo "$row[2] - "; echo "$row[3] <a href='admin_editusers.php?user=$row[0]'>User Edit</a> <br>"; } } else { echo "No rows found!"; } } } } function admin_edituser() { if (!isset($_SESSION['userinfo'])) { echo "You need to be logged in to view this"; } if (isset($_SESSION['userinfo'])) { $session_array = explode(" ", $_SESSION['userinfo']); $user = $session_array[0]; $query = "SELECT priv FROM user_ids WHERE user='$user'"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); if (mysql_num_rows($result) > 0) { while(list($priv) = mysql_fetch_row($result)) { $this->priv = $priv; } } if ($this->priv != 7) { echo "You don't have the permission to view this"; } if ($this->priv == 7) { if (!isset($_GET['user'])) { echo "<meta http-equiv='refresh' content='0;url=admin_view_users.php'>"; } if (isset($_GET['user'])) { $user = $_GET['user']; if (!isset($_POST['pass'])) { $query = "SELECT password, priv FROM user_ids WHERE user='$user'"; $result_ids = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $query = "SELECT email FROM user_profiles WHERE user='$user'"; $result_profiles = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $query = "SELECT strength, dexerity, constitution, intelligence, level FROM user_charinfo WHERE user='$user'"; $result_stats = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $query = "SELECT exp_cur, exp_max, hp_cur, hp_max, mp_cur, mp_max, skill_1, skill_2, skill_3, skill_4, skill_5, money FROM user_currents WHERE user='$user'"; $result_currents = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); if (mysql_num_rows($result_ids) > 0) { while($row_ids = mysql_fetch_row($result_ids)) { if (mysql_num_rows($result_profiles) > 0) { while($row_profiles = mysql_fetch_row($result_profiles)) { if (mysql_num_rows($result_stats) > 0) { while($row_stats = mysql_fetch_row($result_stats)) { if (mysql_num_rows($result_currents) > 0) { while($row_currents = mysql_fetch_row($result_currents)) { echo "Editing user: $user <br> <br>"; echo "<form action='' method='post'> Password: <input type='text' name='pass' value='$row_ids[0]'><br> Priv: <select name='priv' value='$row_ids[1]'> <option value='1'>User</option> <option value='5'>Coder</option> <option value='6'>Mod</option> <option value='7'>Admin</option> </select><br><br> Email: <input type='text' name='email' value='$row_profiles[0]'><br><br> Strength:<input type='text' name='strength' value='$row_stats[0]'><br> Dexerity:<input type='text' name='dexerity' value='$row_stats[1]'><br> Constitution:<input type='text' name='constitution' value='$row_stats[2]'><br> Intelligence:<input type='text' name='intelligence' value='$row_stats[3]'><br> Level:<input type='text' name='level' value='$row_stats[4]'><br><br> Exprience Current:<input type='text' name='exp_cur' value='$row_currents[0]'><br> Exprience Max:<input type='text' name='exp_max' value='$row_currents[1]'><br> Health Current:<input type='text' name='hp_cur' value='$row_currents[2]'><br> Health Max:<input type='text' name='hp_max' value='$row_currents[3]'><br> Mana Current:<input type='text' name='mp_cur' value='$row_currents[4]'><br> Mana Max:<input type='text' name='mp_max' value='$row_currents[5]'><br> Skill 1:<input type='text' name='skill_1' value='$row_currents[6]'><br> Skill 2:<input type='text' name='skill_2' value='$row_currents[7]'><br> Skill 3:<input type='text' name='skill_3' value='$row_currents[8]'><br> Skill 4:<input type='text' name='skill_4' value='$row_currents[9]'><br> Skill 5:<input type='text' name='skill_5' value='$row_currents[10]'><br> <br> <input type='submit' name='submit'> </form>"; } } } } } } } } if (isset($_POST['pass'])) { $password = $_POST['pass']; $priv = $_POST['priv']; $email = $_POST['email']; $strength = $_POST['strength']; $dexerity = $_POST['dexerity']; $constitution = $_POST['constitution']; $intelligence = $_POST['intelligence']; $level = $_POST['level']; $exp_cur = $_POST['exp_cur']; $exp_max = $_POST['exp_max']; $hp_cur = $_POST['hp_cur']; $hp_max = $_POST['hp_max']; $mp_cur = $_POST['mp_cur']; $mp_max = $_POST['mp_max']; $skill_1 = $_POST['skill_1']; $skill_2 = $_POST['skill_2']; $skill_3 = $_POST['skill_3']; $skill_4 = $_POST['skill_4']; $skill_5 = $_POST['skill_5']; $money = $_POST['money']; $query ="UPDATE user_ids SET password='$password', priv='$priv' WHERE user='$user'"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $query = "UPDATE user_profiles SET email='$email' WHERE user='$user'"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $query = "UPDATE user_charinfo SET strength='$strength', dexerity='$dexerity', constitution='$constitution', intelligence='$intelligence', level='$level' WHERE user='$user'"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $query = "UPDATE users_currents SET exp_cur='$exp_cur', exp_max'$exp_max', hp_cur='$hp_cur', hp_max='hp_max', mp_cur='$mp_cur', mp_max='$mp_max', skill_1='$skill_1', skill_2='$skill_2', skill_3='$skill_3', skill_4='$skill_4', skill_5='$skill_5', money='$money' WHERE user='$user'"; $result_currents = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); echo "User changed"; } } } } } } } ?>
  20. Hello, What does this PHP error mean? - Cheers, Daniel
  21. Still more problems... $timestamp = date(YmdGi); $old_timestamp = $timestamp - 5; $query = "UPDATE user_ids SET online = 0 WHERE timestamp < '$old_timestamp' AND online = 1"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $query = "SELECT * FROM user_ids WHERE online='$online'"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $count = mysql_num_rows($result); echo "Users online: $count"; is that what it should be?
  22. alright heres my code: $online = 1; $query = "SELECT * FROM user_ids WHERE online='$online'"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $count = mysql_num_rows($result); $timestamp = date(YmdGi); $old_timestamp = $timestamp - 5; $query = "SELECT user FROM user_ids WHERE online='$online'"; $result_user = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $query = "SELECT timestamp FROM user_ids WHERE online='$online'"; $result_time = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); for ($i = 0; $i <= $count; $i++) { while ($row_time = mysql_fetch_array($result_time)) { $user_timestamp = $row_time[i]; while ($row_user = mysql_fetch_array($result_user)) { $user = $row_user[i]; if ($old_timestamp >= $user_timestamp) { $online = 0; $query = "UPDATE user_ids SET online='$online' WHERE user='$user'"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); } } } } echo "Users online: $count"; Now, this is my code.... In the database I have something like this: TABLE user_ids: USER TIMESTAMP ONLINE peter 200703071932 0 paul 200703071952 1 john 200703071532 0 Now, I want my script to go through my database (in the other parts of code it connects to the database and all of that... its just the output that i dont like) Its currently 2035 where i live. Now, I want my script to search through the database for all the users that have an online status of 1... then search the database and get the timestamp... if the timestamp is greater then 5 mins old. I want the script to change the users online status to 0 (offline). So, I should get a count of all the users that have a timestamp that is newer then 5 mins. Now, what is wrong with my above script? (The script is currently running on www.wintersword.com/users_online.php if you would like to see the output im getting.) - Cheers, Daniel Please HELP... I dont care if i have to answer a few questions, so what exactly do u want? or such...
  23. Hey I'm wondering with these scripts (http://evolt.org/PHP-Login-System-with-Admin-Features) here how does the Header() function supposed to work? It seems like everyone likes to set cookies and send headers in the middle of there script. Now, did this work in PHP4 or do I need some PERL or Add-on so I can send headers and such. I know u have a FAQ all about this. It just makes no sense about how to fix the problem. Its only a diagnostic. Okay, Please explain... Cheers, Daniel
×
×
  • 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.