Hypersource Posted October 26, 2013 Share Posted October 26, 2013 (edited) Read title. Code: <?php //error_reporting(-1); //this will show all errors //ini_set('memory_limit', '256M'); //ini_set('max_execution_time', 3000); include 'c.php'; // connects to database $id = $_GET['id']; // get forum id $sid = $id; // ... $text = $_POST['chatext']; // chat text $name2 = $_POST['participant']; // chat username $sname2 = $name2; // .. $ip = $_SERVER['REMOTE_ADDR']; // get users ip for logging $result = ''; //if this is a postback, send data to server. if($_POST['postback'] == 'TRUE') { //everything needs to be sanitized before going into a SQL query $sql = "INSERT INTO posts (ip,text,name,forumid) VALUES ($ip,$text,$sname2,$sid)"; mysqli_query($con,$sql) or die(mysql_error()); $result = 'chat submitted'; // easy error message showing } ?> <center> <b color='red'><?php echo $result; ?></b> <h1>Chat Box</h1> <form method='POST' action='chatbox.php?id=<?php echo $id; ?>'> <input name="participant" placeholder='Your Nickname' value="<?php echo $name2; ?>"><br><br> <textarea name="chatext" placeholder='Chat Here' rows='4' cols='30'></textarea><br><br> <input type='hidden' name='postback' value='TRUE'> <input type='submit' value ='Submit'> </form> </center> c.php: <?php $host = "*"; $database = "*"; $duser = "*"; $dpassword = "*"; $con=mysqli_connect($host,$duser,$dpassword,$database); // Check connection if (mysqli_connect_errno($con)) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } ?> Thanks! Edited October 26, 2013 by Hypersource Quote Link to comment Share on other sites More sharing options...
mentalist Posted October 26, 2013 Share Posted October 26, 2013 Probably need to see inside c.php... But generally that statement indicates that your script was taking too long and timed out... (I think!) Quote Link to comment Share on other sites More sharing options...
Hypersource Posted October 26, 2013 Author Share Posted October 26, 2013 Added. Its just a simple connect script.. Quote Link to comment Share on other sites More sharing options...
mentalist Posted October 26, 2013 Share Posted October 26, 2013 (edited) All looks ok to me (had a drink or two though), another thread mentions php safe mode, which you can check with this: echo $phpinfo['PHP Core']['safe_mode'][0] Edited October 26, 2013 by mentalist Quote Link to comment Share on other sites More sharing options...
Hypersource Posted October 26, 2013 Author Share Posted October 26, 2013 (edited) @mentalist no matter WHAT data I submit it says connection reset.. I even tried a bare-bones forum. (just a submit button nothing else not even php code) [e] it works completly O.K for GET though?!?! Edited October 26, 2013 by Hypersource Quote Link to comment Share on other sites More sharing options...
Solution mentalist Posted October 26, 2013 Solution Share Posted October 26, 2013 no matter WHAT data I submit it says connection reset.. I even tried a bare-bones forum. (just a submit button nothing else not even php code) it works completly O.K for GET though?!?! What server software is it, are you saying you definately have PHP working, are you sure the database is working? er, should the variables being inserted be wrapped in quotes? (I was ignoring validation issues) Quote Link to comment Share on other sites More sharing options...
Barand Posted October 26, 2013 Share Posted October 26, 2013 instead of or die(mysql_error()); you should be using or die(mysqli_error($con)); Then you might see some Quote Link to comment Share on other sites More sharing options...
Hypersource Posted October 27, 2013 Author Share Posted October 27, 2013 ITs a problem with my host. But I worked around it. Thanks guys : ) Quote Link to comment 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.