Jump to content

3raser

Members
  • Posts

    815
  • Joined

  • Last visited

Everything posted by 3raser

  1. I didn't get any errors.... :/
  2. Bump...
  3. I didn't get any errors. :/
  4. Is there something wrong with this query? elseif($_POST["titlee"] && $_POST["contente"]) { $titlee = $_POST['titlee']; $contente = $_POST['contente']; $to = $_POST['edit']; mysql_query("UPDATE custom_pages SET title='$titlee' AND content='$contente' WHERE id='$to'"); echo '<div class="post"> <div class="postheader"><h1>Updated</h1></div> <div class="postcontent"> <p>Your custom page has been updated.</p> </div> <div class="postfooter"></div> </div> '; }
  5. edit: Oh wait, you are saying all of them besides the first one: It's because you have that mysql_fetch_assoc before the while loop. Remove that. Each time you call it, it moves the internal pointer of the result source var up one, so when you start your while loop, it's already been bumped once. $row = mysql_fetch_assoc($query_get); while($row) { echo '<table border="0"> <tr><th><p>Title</p></th><td>'. $row['title'] .'</td></tr> <tr><th><p>Position</p></th><td>'. $row['position'] .'</td></tr> <tr><th><p>Action</p></th><td><a href="index.php?pages=1&delete='. $row['id'] .'">Delete</a> or <a href="index.php?pages=1&edit='. $row['id'] .'">Edit</a></td></tr> </table> '; } Not to sure on what you mean. But I tried doing it like you said, and I just got a run-on loop. How am I suppose to do it AFTER the while loop?
  6. Alright, the problem has been fixed. But now, all the results show up besides the very first one. Why is this? $query_get = mysql_query("SELECT id,position,content,title FROM custom_pages"); $result = mysql_fetch_assoc($query_get); echo '<div class="post"> <div class="postheader"><h1>Custom Pages</h1></div> <div class="postcontent"> <p>Welcome to the custom pages section. You can delete, edit, and add custom pages here. To add a custom page, click <a href="index.php?pages=1&add_page=1">here</a>.</p> '; while($row = mysql_fetch_assoc($query_get)) { echo '<table border="0"> <tr><th><p>Title</p></th><td>'. $row['title'] .'</td></tr> <tr><th><p>Position</p></th><td>'. $row['position'] .'</td></tr> <tr><th><p>Action</p></th><td><a href="index.php?pages=1&delete='. $row['id'] .'">Delete</a> or <a href="index.php?pages=1&edit='. $row['id'] .'">Edit</a></td></tr> </table> '; } echo ' <p></p> </div> <div class="postfooter"></div> </div> ';
  7. Yes, but how will that work?.....I'm trying to grab data and see if it exists at the same time....not possible with mysql_num_rows is it?
  8. My data: -- -- Table structure for table `custom_pages` -- CREATE TABLE `custom_pages` ( `id` int(11) NOT NULL auto_increment, `position` int(11) NOT NULL, `content` text collate latin1_general_ci NOT NULL, `title` varchar(30) collate latin1_general_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=4 ; -- -- Dumping data for table `custom_pages` -- INSERT INTO `custom_pages` VALUES(1, 0, 'Awesome.', '0'); INSERT INTO `custom_pages` VALUES(2, 1, 'Awesome.', 'Awesome.'); INSERT INTO `custom_pages` VALUES(3, 0, 'A', 'A');
  9. If you tested it and it works, why wouldn't mine work.....
  10. I fixed that, but it stills does it.
  11. This code is suppose to echo out ALL the custom pages that are in the database, but it's only show ONE. Why is this? $query_get = mysql_query("SELECT COUNT(id),id,position,content,title FROM custom_pages ORDER BY id"); while($row = mysql_fetch_assoc($query_get)) { echo '<table border="0"> <tr><th><p>Title</p><td>'. $row['title'] .'</td></tr> <tr><th><p>Position</p><td>'. $row['position'] .'</td></tr> <tr><th><p>Action</p><td><a href="index.php?pages=1&delete='. $row['id'] .'">Delete</a> or <a href="index.php?pages=1&edit='. $row['id'] .'">Edit</a></td></tr> </table> '; }
  12. It doesn't work. $status["status"][0] = "Waiting for support..."; $status["status"][1] = "Waiting for user..."; $status["status"][2] = "Ticket Closed..."; $status["status"][3] = "Ticket Opened..."; Get rid of ["status"] If I get rid of status, it wont know what I'm trying to grab from the database... <?php session_start(); include("../includes/mysql.php"); include("../includes/config.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="../style.css" rel="stylesheet" type="text/css" /> <title><?php echo $title; ?></title> </head> <body> <div id="container"> <div id="content"> <div id="left"> <div class="menu"> <?php include("../includes/navigation.php"); ?> <div class="menufooter"></div> </div> <?php include("../includes/menu.php"); ?> </div> <div id="middle"> <?php if(!$_POST['existing']) { $existing = $_GET['existing']; } else { $existing = $_POST['existing']; } $reply = $_POST['answer']; $ip = $_SERVER['REMOTE_ADDR']; $username = $_SESSION['user']; $query_user = mysql_query("SELECT position FROM users WHERE username='$username'"); $get_position = mysql_fetch_assoc($query_user); $query = mysql_query("SELECT COUNT(id),id,status,date,question,title,username FROM tickets WHERE id='$existing'"); $get = mysql_fetch_assoc($query); if(!$existing) { echo ' <div class="post"> <div class="postheader"><h1>Error</h1></div> <div class="postcontent"> <p>You have not enetered in a ticket ID. Please go back and do so.</p> </div> <div class="postfooter"></div> </div> '; } elseif($get['COUNT(id)'] < 1) { echo ' <div class="post"> <div class="postheader"><h1>Error</h1></div> <div class="postcontent"> <p>The ticket ID you are trying to use doesnt exist. Please go back or submit another ticket.</p> </div> <div class="postfooter"></div> </div> '; } elseif($get['ip']==$ip || $get_position['position'] >= 1) { $get["status"][0] = "Waiting for support..."; $get["status"][1] = "Waiting for user..."; $get["status"][2] = "Ticket Closed..."; $get["status"][3] = "Ticket Opened..."; if($username==$get["username"]) { $message = "<p><a href='view.php?close=". $get['id'] ."&existing=". $get['id'] ."'>[CLOSE]</a></p>"; } echo ' <div class="post"> <div class="postheader"><h1>View Ticket Status - ID '. $get["id"] .'</h1></div> <div class="postcontent"> '. $message .' <p>Title: '. $get["title"] .'<br/>Posted on: '. $get["date"] .'<br/>Posted by: '. $get["username"] .'</p> <p>Ticket Status: '. $get["status"]['. $get["status"] .'] .'</p> <p>Question: '. nl2br($get["question"]) .'</p> </div> <div class="postfooter"></div> </div> '; if(!$reply) { if(!$_GET['reply']) { echo ' <div class="post"> <div class="postheader"><h1>Replies</h1></div> <div class="postcontent"> <p><a href="view.php?reply='. $get["id"] .'&existing='. $existing .'">Reply</a></p> '; $replies = mysql_query("SELECT username,date,message FROM replies WHERE tid='{$get["id"]}'"); while ($row = mysql_fetch_assoc($replies)) { echo '<p>Username: '. $row["username"] .' Post Date: '. $row["date"] .'<br/> '. nl2br($row["message"]) .' </p>'; } echo ' <p><a href="view.php?reply='. $existing .'&existing='. $existing .'">Reply</a></p> </div> <div class="postfooter"></div> </div> '; } else { echo ' <div class="post"> <div class="postheader"><h1>Post a reply</h1></div> <div class="postcontent"> <p>Replying to Ticket ID '. $get["id"]. '...</p> <center><form action="view.php" method="POST"><table border="0"> <input type="hidden" name="existing" value="'. $existing .'"> <tr><th>Reply/Answer</th><td><textarea name="answer" rows="10" cols="25" maxlength="1000"></textarea></td></tr> <tr><th></th><td><input type="submit" value="Submit"></td></tr> </center></table></form> </div> <div class="postfooter"></div> </div> '; } } else { $date = date("m-d-y"); mysql_query("INSERT INTO replies VALUES ('', '$existing', '$date', '$reply', '$username')"); echo ' <div class="post"> <div class="postheader"><h1>Posted</h1></div> <div class="postcontent"> <p>Your reply has been added! <a href="view.php?existing='. $existing .'">Return to Ticket</a></p> </div> <div class="postfooter"></div> </div> '; } } else { echo ' <div class="post"> <div class="postheader"><h1>Error</h1></div> <div class="postcontent"> <p>This is not your ticket. You only have permission to view your tickets. Please go back.</p> </div> <div class="postfooter"></div> </div> '; } ?> </div> </div> </div> </body> </html>
  13. Delete.
  14. Bump
  15. It doesn't work. $status["status"][0] = "Waiting for support..."; $status["status"][1] = "Waiting for user..."; $status["status"][2] = "Ticket Closed..."; $status["status"][3] = "Ticket Opened...";
  16. Because I need to check if and see if the users position (rank) is higher than 1, or equal to it. And I wanted to use it all in one query.
  17. Yeah, thats what I have.
  18. $query = mysql_query("SELECT COUNT(tickets.id),tickets.id,tickets.status,tickets.date,tickets.question,tickets.title,users.position FROM tickets,users WHERE tickets.id='$existing' users.username='$username'"); How do I get it so it selects data from the table tickets where id='$existing', but I also want to get a user's (who is viewing the ID) position (rank). $username is a session. So, any thoughts on how I would do so? My updated code: <?php session_start(); include("../includes/mysql.php"); include("../includes/config.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="../style.css" rel="stylesheet" type="text/css" /> <title><?php echo $title; ?></title> </head> <body> <div id="container"> <div id="content"> <div id="left"> <div class="menu"> <?php include("../includes/navigation.php"); ?> <div class="menufooter"></div> </div> <?php include("../includes/menu.php"); ?> </div> <div id="middle"> <?php $existing = $_POST['existing']; $ip = $_SERVER['REMOTE_ADDR']; $username = $_SESSION['user']; $query = mysql_query("SELECT COUNT(tickets.id),tickets.id,tickets.status,tickets.date,tickets.question,tickets.title,users.position FROM tickets,users WHERE tickets.id='$existing' OR users.username='$username'"); $get = mysql_fetch_assoc($query); if(!$existing) { echo ' <div class="post"> <div class="postheader"><h1>Error</h1></div> <div class="postcontent"> <p>You have not enetered in a ticket ID. Please go back and do so.</p> </div> <div class="postfooter"></div> </div> '; } elseif($get['COUNT(id)'] < 1) { echo ' <div class="post"> <div class="postheader"><h1>Error</h1></div> <div class="postcontent"> <p>The ticket ID you are trying to use doesnt exist. Please go back or submit another ticket.</p> </div> <div class="postfooter"></div> </div> '; } elseif($get['tickets.ip']==$ip || $get['user.position'] >= 1) { $status["tickets.status"]["0"] = "Waiting for support..."; $status["tickets.status"]["1"] = "Waiting for user..."; $status["tickets.status"]["2"] = "Ticket Closed..."; $status["tickets.status"]["3"] = "Ticket Opened..."; echo ' <div class="post"> <div class="postheader"><h1>View Ticket Status - ID '. $get["id"] .'</h1></div> <div class="postcontent"> <p>Title: '. $get["tickets.title"] .' - Posted on: '. $get["tickets.date"] .'</p> <p>Ticket Status: '. $status[$get["tickets.status"]] .'</p> <p>Question: '. nl2br($get["tickets.question"]) .'</p> </div> <div class="postfooter"></div> </div> '; } else { echo ' <div class="post"> <div class="postheader"><h1>Error</h1></div> <div class="postcontent"> <p>This is not your ticket. You only have permission to view your tickets. Please go back.</p> </div> <div class="postfooter"></div> </div> '; } ?> </div> </div> </div> </body> </html>
  19. Thank you guys! And one more question, since I don't need to create a new topic: $query = mysql_query("SELECT COUNT(tickets.id),tickets.id,tickets.status,tickets.date,tickets.question,tickets.title,users.position FROM tickets,users WHERE tickets.id='$existing' users.username='$username'"); How do I get it so it selects data from the table tickets where id='$existing', but I also want to get a user's (who is viewing the ID) position (rank). $username is a session. So, any thoughts on how I would do so? My updated code: <?php session_start(); include("../includes/mysql.php"); include("../includes/config.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="../style.css" rel="stylesheet" type="text/css" /> <title><?php echo $title; ?></title> </head> <body> <div id="container"> <div id="content"> <div id="left"> <div class="menu"> <?php include("../includes/navigation.php"); ?> <div class="menufooter"></div> </div> <?php include("../includes/menu.php"); ?> </div> <div id="middle"> <?php $existing = $_POST['existing']; $ip = $_SERVER['REMOTE_ADDR']; $username = $_SESSION['user']; $query = mysql_query("SELECT COUNT(tickets.id),tickets.id,tickets.status,tickets.date,tickets.question,tickets.title,users.position FROM tickets,users WHERE tickets.id='$existing' OR users.username='$username'"); $get = mysql_fetch_assoc($query); if(!$existing) { echo ' <div class="post"> <div class="postheader"><h1>Error</h1></div> <div class="postcontent"> <p>You have not enetered in a ticket ID. Please go back and do so.</p> </div> <div class="postfooter"></div> </div> '; } elseif($get['COUNT(id)'] < 1) { echo ' <div class="post"> <div class="postheader"><h1>Error</h1></div> <div class="postcontent"> <p>The ticket ID you are trying to use doesnt exist. Please go back or submit another ticket.</p> </div> <div class="postfooter"></div> </div> '; } elseif($get['tickets.ip']==$ip || $get['user.position'] >= 1) { $status["tickets.status"]["0"] = "Waiting for support..."; $status["tickets.status"]["1"] = "Waiting for user..."; $status["tickets.status"]["2"] = "Ticket Closed..."; $status["tickets.status"]["3"] = "Ticket Opened..."; echo ' <div class="post"> <div class="postheader"><h1>View Ticket Status - ID '. $get["id"] .'</h1></div> <div class="postcontent"> <p>Title: '. $get["tickets.title"] .' - Posted on: '. $get["tickets.date"] .'</p> <p>Ticket Status: '. $status[$get["tickets.status"]] .'</p> <p>Question: '. nl2br($get["tickets.question"]) .'</p> </div> <div class="postfooter"></div> </div> '; } else { echo ' <div class="post"> <div class="postheader"><h1>Error</h1></div> <div class="postcontent"> <p>This is not your ticket. You only have permission to view your tickets. Please go back.</p> </div> <div class="postfooter"></div> </div> '; } ?> </div> </div> </div> </body> </html>
  20. Problem: I'm trying to make it so the array responds to the integer of status in the database. So, to check if it's one, I try this: $get["status"]["1"] = "Message here..."; But, on my result, I'm just getting WWTT - And the value in the database for the ticket is 0. I'm not sure if I'm using the array correctly. My full code: <?php session_start(); include("../includes/mysql.php"); include("../includes/config.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="../style.css" rel="stylesheet" type="text/css" /> <title><?php echo $title; ?></title> </head> <body> <div id="container"> <div id="content"> <div id="left"> <div class="menu"> <?php include("../includes/navigation.php"); ?> <div class="menufooter"></div> </div> <?php include("../includes/menu.php"); ?> </div> <div id="middle"> <?php $existing = $_POST['existing']; $query = mysql_query("SELECT COUNT(id),id,status,date,question,title FROM tickets WHERE id='$existing'"); $get = mysql_fetch_assoc($query); if(!$existing) { echo ' <div class="post"> <div class="postheader"><h1>Error</h1></div> <div class="postcontent"> <p>You have not enetered in a ticket ID. Please go back and do so.</p> </div> <div class="postfooter"></div> </div> '; } elseif($get['COUNT(id)'] < 1) { echo ' <div class="post"> <div class="postheader"><h1>Error</h1></div> <div class="postcontent"> <p>The ticket ID you are trying to use doesnt exist. Please go back or submit another ticket.</p> </div> <div class="postfooter"></div> </div> '; } else { $get["status"]["0"] = "Waiting for support..."; $get["status"]["1"] = "Waiting for user..."; $get["status"]["2"] = "Ticket Closed..."; $get["status"]["3"] = "Ticket Opened..."; echo ' <div class="post"> <div class="postheader"><h1>View Ticket Status - ID '. $get["id"] .'</h1></div> <div class="postcontent"> <p>Title: '. $get["title"] .' - Posted on: '. $get["date"] .'</p> <p>Ticket Status: '. $get["status"] .'</p> <p>Question: '. nl2br($get["question"]) .'</p> </div> <div class="postfooter"></div> </div> '; } ?> </div> </div> </div> </body> </html>
  21. Your the one meant to be describing your problems. Post too many stupid threads and people will simply ignore them after a while. Thank you mjdamato, I'll try that out. Edit: Still didn't fix the MD5 problem. - Is it the incorrect way to MD5 with my first post? And why is it wrong to check the lengths of their input?
  22. If you all just ASK, I'd be happy to post my code. At first I thought it was just a probably with my if statement, so I didn't bother posting any other part of the code.
  23. What else would it mean? Code to login: <?php include("includes/mysql.php"); include("includes/config.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="style.css" rel="stylesheet" type="text/css" /> <title><?php echo $title; ?></title> </head> <body> <div id="container"> <div id="content"> <div id="left"> <div class="menu"> <div class="menuheader"><h3>Menu</h3></div> <?php include("includes/navigation.php"); ?> <div class="menufooter"></div> </div> <?php include("includes/menu.php"); ?> </div> <?php $username = $_POST['username']; $password = $_POST['password']; $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); if(!$password || !$username) { echo ' <div id="middle"> <div class="post"> <div class="postheader"><h1>Login</h1></div> <div class="postcontent"> <center><p><form action="login.php" method="POST"> <table border="0"> <tr><th>Username:</th> <td><input type="text" name="username"><br/></td></tr> <tr><th>Password:</th> <td><input type="password" name="password"></td></tr> <br/><input type="submit" value="Login"> </table></form></p></center> </div> <div class="postfooter"></div> </div> </div> '; } else { $query = mysql_query("SELECT COUNT(username),password FROM users WHERE username='$username'"); $check = mysql_fetch_assoc($query); $db_password = $check['password']; if(strlen($username) > 20) { echo ' <div id="middle"> <div class="post"> <div class="postheader"><h1>Error</h1></div> <div class="postcontent"> <p>Sorry, the username can NOT be greater than 20 characters long. Please go back by pressing the back button on your browser.</p> </div> <div class="postfooter"></div> </div> </div> '; } elseif(strlen($password) > 20) { echo ' <div id="middle"> <div class="post"> <div class="postheader"><h1>Error</h1></div> <div class="postcontent"> <p>Sorry, the password can NOT be greater than 20 characters long. Please go back by pressing the back button on your browser.</p> </div> <div class="postfooter"></div> </div> </div> '; } elseif($check['COUNT(username)'] < 1) { echo ' <div id="middle"> <div class="post"> <div class="postheader"><h1>Error</h1></div> <div class="postcontent"> <p>No account exists with this username. Please go back.</p> </div> <div class="postfooter"></div> </div> </div> '; } elseif($db_password==md5($password)) { echo ' <div id="middle"> <div class="post"> <div class="postheader"><h1>Login Successful</h1></div> <div class="postcontent"> <p>You have successfully logged in! Return home.</p> </div> <div class="postfooter"></div> </div> </div> '; $_SESSION['user']=$username; } else { echo ' <div id="middle"> <div class="post"> <div class="postheader"><h1>Error</h1></div> <div class="postcontent"> <p>The password you have enetered in is incorrect. Please go back. '. $db_password .' '. $password .'</p> </div> <div class="postfooter"></div> </div> </div> '; } } ?> </div> </div> </body> </html> Where to test: http://coolscripts.webatu.com/login.php Account details Username: Justin Password: doesn't matter
  24. I have echoed out the variable, and it doesn't MD5. It basically just keeps the password the same as it was from $_POST['password'] - All passwords in the database are MD5'ed - So thats why I'm trying to MD5 password, then check if they are equal. @thorpe, My post basically states why wont $password change to MD5.
×
×
  • 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.