netpumber Posted June 18, 2010 Share Posted June 18, 2010 Hallo ! I have 2 files one called admin.php and the other edit.php So.. in admin file i have this html code : <a href="edit.php" id="hmtext" class="nav">Home Text</a> and in edit.php this code : <?php ini_set ('display_errors',1); error_reporting (E_ALL); include 'dbConf.php'; $connect = mysql_connect($host,$username,$password) or die("Error connecting to Database! " . mysql_error()); mysql_select_db($database , $connect) or die("Cannot select database! " . mysql_error()); $query = "SELECT title,text FROM fronttext"; $q = mysql_query($query); $row = mysql_fetch_array($q); print " <div id=\"frontTexForm\"> <form method= \"post\" action=\"homeTextForm.php\"> <label><font color=\"#99FF00\" >HOME TEXT</font></label> <br /><br /><br /> <label><font color=\"#99FF00\" >Title : </font></label> <br /> <input type=\"text\" size=\"70\" maxlength=\"100\" name=\"title\" value=\"".htmlentities($row['title'])."\" /> <br /><br /> <label><font color=\"#99FF00\" >Text : </font></label> <br /> <textarea cols=\"53\" rows=\"15\" name=\"text\">".htmlentities($row['text'])."</textarea> <br/><br/> <input type=\"submit\" value=\"Αποθήκευση\" name=\"save\"> </form> </div> "; mysql_close(); ?> So i click the link from admin.php and then the browser returns to me this error : The connection was reset The connection to the server was reset while the page was loading. * The site could be temporarily unavailable or too busy. Try again in a few moments. * If you are unable to load any pages, check your computer's network connection. * If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web. Why this happens ? Have you any idea ? The query was executed but i can't print out the results... Thanks a lot! Link to comment https://forums.phpfreaks.com/topic/205169-the-connection-was-reset-problem/ Share on other sites More sharing options...
netpumber Posted June 18, 2010 Author Share Posted June 18, 2010 Hmm if i delete the mysql_close(); then it works ...:s Why this happens ? Link to comment https://forums.phpfreaks.com/topic/205169-the-connection-was-reset-problem/#findComment-1073942 Share on other sites More sharing options...
Partyz Posted June 18, 2010 Share Posted June 18, 2010 As I remember from php tutorial to connect from a PHP script, just put this in your file: <? mysql_connect("DBSERVER", "DBUSERNAME", "DBPASSWORD"); mysql_select_db("DBNAME"); ?> using the following substitutions for the bold terms as above, plus substituting DBPASSWORD with your own mysql password: * Replace DBSERVER with the correct database servername for your site. * Replace DBUSERNAME with your own mysql username. * Replace DBNAME with your own mysql databasename. The connection will be closed automatically when the script ends. To close the connection before, use the mysql_close() function: <?php $con = mysql_connect("localhost","peter","abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } // some code mysql_close($con); ?> Link to comment https://forums.phpfreaks.com/topic/205169-the-connection-was-reset-problem/#findComment-1074014 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.