MySQL_Narb Posted October 26, 2009 Share Posted October 26, 2009 Everytime I try and post as a guest, when guest positing is enabled, It never seems to do anything besides give me a blank page. http://www.commentbb.com/demo/testing/ Why is this? Code: <?php session_start(); ?> <?php require "global_settings.php"; ?> <title><?php echo $sitetitle; ?></title> <center><style type="text/css"> a:link { color:#24374C; text-decoration:bold; } a:visited { color:#24374C; text-decoration:bold; } a:active { outline: none; color:#24374C; text-decoration:bold; } body {background-color:#b0c4de} div.box { width:250px; padding:10px; border:3px double #000000; margin:10px; background-color:#74AFF2; } p { border-top-style:dotted; border-right-style:solid; border-bottom-style:dotted; border-left-style:solid; } div.menu-blue { BORDER-RIGHT: #333366 1px solid; BORDER-LEFT: #6699cc 1px solid; BORDER-TOP: #6699cc 1px solid; BORDER-BOTTOM: #333366 1px solid; FONT-WEIGHT: normal; FONT-SIZE: 2px; COLOR: #ffffff; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; BACKGROUND-COLOR: #23559C; TEXT-DECORATION: none; font-stretch : condensed; } .menu-top { BORDER-RIGHT: 1px solid #333366; BORDER-TOP: 1px solid #6699CC; FONT-WEIGHT: normal; FONT-SIZE: 2px; BORDER-LEFT: 1px solid #6699CC; COLOR: #FFFFFF; BORDER-BOTTOM: 1px solid #333366; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; BACKGROUND-COLOR: #23559C; TEXT-DECORATION: none; font-stretch : condensed } </style> <center> <div class='menu-blue'> <div align="center"> <table width="600" cellspacing="1" cellpadding="5" style="background-color:#23559C"> <tr> <td style="background-color:#FFFFFF"> <div align="center"> <table border="0"> </form> </table> <?php $name = $_SESSION['username']; $message = $_POST['message']; if ($gposting ==0) { if ($_SESSION['username']) { $ip = $_SERVER['REMOTE_ADDR']; //protection $before = array('(', ')', '^', '<', '>', '`', '*', '<script>', '</script>', ';DROP TABLE users;', 'users', 'DROP', 'TABLE'); $after = array('', '', '', '', '', '', '', '', '', '', '', '', ''); $output = str_replace($before, $after, $message); $connect = mysql_connect("$dbhost","$dbuser","$dbpassword") or die("Connection failed!"); mysql_select_db("$db") or die("Database fail!"); //extract $extract = mysql_query("SELECT * FROM users WHERE username='$name'"); $numrows = mysql_num_rows($extract); while ($row = mysql_fetch_assoc($extract)) { $banned = $row[banned]; if ($banned ==1) { echo "Sorry, your account is currently disabled."; } else { if (strlen($message)<=$charlong) { echo "Your message must be longer then $charlong characters."; } else { //connect $connect = mysql_connect("$dbhost","$dbuser","$dbpassword") or die("Connection failed!"); mysql_select_db("$db") or die("Database fail!"); //write $write = mysql_query("INSERT INTO posts VALUES ('','$name','$output', '$ip')") or die(mysql_error()); $postcount = mysql_query("UPDATE users SET post_count = post_count + 1 WHERE username='$name'"); echo "<div class='box'><font face='arial'><b><span style='color:green'>Posted! Your name was:</span> $name</b> - Your message was....<br><br><b>$message - <a href='index.php'>View it!</a></b>"; echo "<br /><br />Your IP $ip has been logged for security reasons. (We track all IP's, your information is safe with us! We track IP's to catch spammers.)"; } } } } else { echo "You must be logged in before posting."; } } else { $name = $_SESSION['username']; $message = $_POST['message']; $ip = $_SERVER['REMOTE_ADDR']; if ($name =="") { $name = "Guest"; } //protection $before = array('(', ')', '^', '<', '>', '`', '*', '<script>', '</script>', ';DROP TABLE users;', 'users', 'DROP', 'TABLE'); $after = array('', '', '', '', '', '', '', '', '', '', '', '', ''); $output = str_replace($before, $after, $message); $connect = mysql_connect("$dbhost","$dbuser","$dbpassword") or die("Connection failed!"); mysql_select_db("$db") or die("Database fail!"); //extract $extract = mysql_query("SELECT * FROM users WHERE username='$name'"); $numrows = mysql_num_rows($extract); while ($row = mysql_fetch_assoc($extract)) { $banned = $row[banned]; if ($banned ==1) { echo "Sorry, your account is currently disabled."; } else { if (strlen($message)<=$charlong) { echo "Your message must be longer then $charlong characters."; } else { //connect $connect = mysql_connect("$dbhost","$dbuser","$dbpassword") or die("Connection failed!"); mysql_select_db("$db") or die("Database fail!"); //write $write = mysql_query("INSERT INTO posts VALUES ('','$name','$output', '$ip')") or die(mysql_error()); $postcount = mysql_query("UPDATE users SET post_count = post_count + 1 WHERE username='$name'"); echo "<div class='box'><font face='arial'><b><span style='color:green'>Posted! Your name was:</span> $name</b> - Your message was....<br><br><b>$message - <a href='index.php'>View it!</a></b>"; echo "<br /><br />Your IP $ip has been logged for security reasons. (We track all IP's, your information is safe with us! We track IP's to catch spammers.)"; } } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/179126-why-doesnt-this-code-work/ Share on other sites More sharing options...
MySQL_Narb Posted October 27, 2009 Author Share Posted October 27, 2009 Anyone?...I have to go soon.... Quote Link to comment https://forums.phpfreaks.com/topic/179126-why-doesnt-this-code-work/#findComment-945076 Share on other sites More sharing options...
MySQL_Narb Posted October 27, 2009 Author Share Posted October 27, 2009 Is it seriously that hard?.... Quote Link to comment https://forums.phpfreaks.com/topic/179126-why-doesnt-this-code-work/#findComment-945083 Share on other sites More sharing options...
MySQL_Narb Posted October 27, 2009 Author Share Posted October 27, 2009 ANYONE!?!?!?!?!?!?!?!?!?!?! :wtf: :wtf: :confused: :confused: Quote Link to comment https://forums.phpfreaks.com/topic/179126-why-doesnt-this-code-work/#findComment-945701 Share on other sites More sharing options...
mikesta707 Posted October 27, 2009 Share Posted October 27, 2009 post the relevant code. im not (and apparently no one else) wants to wade through lines and lines of code to find one problem. Quote Link to comment https://forums.phpfreaks.com/topic/179126-why-doesnt-this-code-work/#findComment-945709 Share on other sites More sharing options...
mrMarcus Posted October 27, 2009 Share Posted October 27, 2009 i agree. showing all your CSS, etc., is gonna lose me every time. does seem that you have several parts of your script written multiple times in there. i can see your $before and $after arrays are defined twice. look deeply into indenting your code. will get you many more responses since this is not paid help, and the majority of people don't have hours upon hours of time to scour through roughly written code for you. Quote Link to comment https://forums.phpfreaks.com/topic/179126-why-doesnt-this-code-work/#findComment-945712 Share on other sites More sharing options...
MySQL_Narb Posted October 27, 2009 Author Share Posted October 27, 2009 Fixed what you've stated above <?php require "global_navigation.php"; ?> <?php $name = $_SESSION['username']; $message = $_POST['message']; if ($gposting ==0) { if ($_SESSION['username']) { $ip = $_SERVER['REMOTE_ADDR']; //protection $before = array('(', ')', '^', '<', '>', '`', '*', '<script>', '</script>', ';DROP TABLE users;', 'users', 'DROP', 'TABLE'); $after = array('', '', '', '', '', '', '', '', '', '', '', '', ''); $output = str_replace($before, $after, $message); $connect = mysql_connect("$dbhost","$dbuser","$dbpassword") or die("Connection failed!"); mysql_select_db("$db") or die("Database fail!"); //extract $extract = mysql_query("SELECT * FROM users WHERE username='$name'"); $numrows = mysql_num_rows($extract); while ($row = mysql_fetch_assoc($extract)) { $banned = $row[banned]; if ($banned ==1) { echo "Sorry, your account is currently disabled."; } else { if (strlen($message)<=$charlong) { echo "Your message must be longer then $charlong characters."; } else { //connect $connect = mysql_connect("$dbhost","$dbuser","$dbpassword") or die("Connection failed!"); mysql_select_db("$db") or die("Database fail!"); //write $write = mysql_query("INSERT INTO posts VALUES ('','$name','$output', '$ip')") or die(mysql_error()); $postcount = mysql_query("UPDATE users SET post_count = post_count + 1 WHERE username='$name'"); echo "<div class='box'><font face='arial'><b><span style='color:green'>Posted! Your name was:</span> $name</b> - Your message was....<br><br><b>$message - <a href='index.php'>View it!</a></b>"; echo "<br /><br />Your IP $ip has been logged for security reasons. (We track all IP's, your information is safe with us! We track IP's to catch spammers.)"; } } } } else { echo "You must be logged in before posting."; } } else { $name = $_SESSION['username']; $message = $_POST['message']; $ip = $_SERVER['REMOTE_ADDR']; if ($name =="") { $name = "Guest"; } //protection $before2 = array('(', ')', '^', '<', '>', '`', '*', '<script>', '</script>', ';DROP TABLE users;', 'users', 'DROP', 'TABLE'); $after2 = array('', '', '', '', '', '', '', '', '', '', '', '', ''); $output = str_replace($before2, $after2, $message); $connect = mysql_connect("$dbhost","$dbuser","$dbpassword") or die("Connection failed!"); mysql_select_db("$db") or die("Database fail!"); //extract $extract = mysql_query("SELECT * FROM users WHERE username='$name'"); $numrows = mysql_num_rows($extract); while ($row = mysql_fetch_assoc($extract)) { $banned = $row[banned]; if ($banned ==1) { echo "Sorry, your account is currently disabled."; } else { if (strlen($message)<=$charlong) { echo "Your message must be longer then $charlong characters."; } else { //connect $connect = mysql_connect("$dbhost","$dbuser","$dbpassword") or die("Connection failed!"); mysql_select_db("$db") or die("Database fail!"); //write $write = mysql_query("INSERT INTO posts VALUES ('','$name','$output', '$ip')") or die(mysql_error()); $postcount = mysql_query("UPDATE users SET post_count = post_count + 1 WHERE username='$name'"); echo "<div class='box'><font face='arial'><b><span style='color:green'>Posted! Your name was:</span> $name</b> - Your message was....<br><br><b>$output - <a href='index.php'>View it!</a></b>"; echo "<br /><br />Your IP $ip has been logged for security reasons. (We track all IP's, your information is safe with us! We track IP's to catch spammers.)"; } } } } ?></font></td> </tr> </tbody> </table></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center> <table class="tborder" cellpadding="4" cellspacing="1" width="67%"> <tbody> <tr> <td class="thead"><font face="Trebuchet MS"><strong> Copyright</strong></font></td> </tr> <tr> <td class="trow1"> <table border="0" cellpadding="4" width="100%"> <tbody> <tr> <td class="trow1"> <p align="center"> <span class="smalltext" style="display: inline; visibility: visible; font-family: Trebuchet MS; font-weight: 700"> <a title="Simple Machines Forum" target="_blank" class="new_win" href="http://commentbb.com"> <font size="2">Powered by CommentBB 1.0 BETA</font></a><font size="2"> | </font><a href="http://commentbb.com"><font size="2">CBB is © 2009, CommentBB INC</font></a></span></td> </tr> </tbody> </table></td> </tr> </tbody> </table> </div> <font face="Trebuchet MS"> <!-- end: footer --> <!-- end: portal --></font></body></html> Quote Link to comment https://forums.phpfreaks.com/topic/179126-why-doesnt-this-code-work/#findComment-945837 Share on other sites More sharing options...
MySQL_Narb Posted October 28, 2009 Author Share Posted October 28, 2009 Wow, is the code this freaking hard? Quote Link to comment https://forums.phpfreaks.com/topic/179126-why-doesnt-this-code-work/#findComment-945888 Share on other sites More sharing options...
DavidAM Posted October 28, 2009 Share Posted October 28, 2009 Put "error_reporting(E_ALL);" at the beginning of all of your scripts. You may have errors that are not being reported. If you get errors, post those and we can be more helpful. Here are a couple of issues with that code. I do not think any of these is causing the problem, but without the error messages, there's not much more we can say. You are connecting to the database all over the place. Do it only one, at the top of the script, before you even test if posting is allowed. You only need one connection. You do not need that while loop for users. You should be getting only one user back, right? If you get more than one, you will be posting the message more than once. Your HTML does not look right. You have no HEAD or BODY statements. TITLE belongs in the HEAD, so does the style sheet (I think) but the rest should be in the BODY (why is the STYLE sheet CENTERed?): <HTML> <HEAD> <TITLE>My Name</TITLE> ... other HEAD stuff here too <STYLE>...</STYLE> </HEAD> <BODY> ... a while bunch of stuff here ... </BODY> </HTML> Clean up the code a little, run it with error checking and post the results. Also, when you get a blank page, use the "View Source" capability of your browser. That will show you what the PHP script actually sent to the browser which may have an indication of why you don't see anything. Above all else, be patient! This is not the FREEK SQUAD Help Desk . We are responding in our spare time. Quote Link to comment https://forums.phpfreaks.com/topic/179126-why-doesnt-this-code-work/#findComment-945909 Share on other sites More sharing options...
MySQL_Narb Posted October 29, 2009 Author Share Posted October 29, 2009 Still not working dude. Quote Link to comment https://forums.phpfreaks.com/topic/179126-why-doesnt-this-code-work/#findComment-947383 Share on other sites More sharing options...
Daniel0 Posted October 29, 2009 Share Posted October 29, 2009 Still not working dude. Then you probably need to work harder on fixing it... dude. Quote Link to comment https://forums.phpfreaks.com/topic/179126-why-doesnt-this-code-work/#findComment-947403 Share on other sites More sharing options...
keldorn Posted October 29, 2009 Share Posted October 29, 2009 This reminds me of this quote. “Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are–by definition–not smart enough to debug it.” (Brian Kernighan) This means if you use 100% of your IQ/Skill to write a script and it has a bug, You will need 100% more Skill and IQ which you don't have to debug it. Your are now requiring the expertize of someone smarter then you. xD Quote Link to comment https://forums.phpfreaks.com/topic/179126-why-doesnt-this-code-work/#findComment-947414 Share on other sites More sharing options...
MadTechie Posted October 29, 2009 Share Posted October 29, 2009 Still not working dude. Dude, Learn to debug your code instead of demanding other do it for you. The problem isn't that hard, PS learn how to create functions and debug your SQL queries Quote Link to comment https://forums.phpfreaks.com/topic/179126-why-doesnt-this-code-work/#findComment-947443 Share on other sites More sharing options...
DavidAM Posted October 30, 2009 Share Posted October 30, 2009 Still not working dude. I don't know what to say. Usually, my psychic powers of fixing code I can't see to remove errors I haven't been told about are perfect. Did you read what I said in my last post? Clean up the code a little, run it with error checking and post the results. Quote Link to comment https://forums.phpfreaks.com/topic/179126-why-doesnt-this-code-work/#findComment-947602 Share on other sites More sharing options...
Gayner Posted October 30, 2009 Share Posted October 30, 2009 We don't wnat to see ur css or anything just php code, we could careless how the site looks. Quote Link to comment https://forums.phpfreaks.com/topic/179126-why-doesnt-this-code-work/#findComment-947604 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.