NameSilo

MySQL Timeout

Spaceship Spaceship
Watch

Barrucadu

Established Member
Impact
64
When I try to put all the data in my database in a table on my site it gets about 25 and a third records complete but then it runs out of time, my host has a 30 second SQL timeout, is there any way to re-open the connection and continue from the last complete record, heres the php:

PHP:
	$username="--not gonna post--";
	$password="--not gonna post--";
	$database="myfile";
	$host="mysql5.streamline.net";
	
	mysql_connect($host,$username,$password);
	@mysql_select_db($database);
	$query="SELECT * FROM myfile_visitors";
	$result=mysql_query($query);
	
	$num=mysql_numrows($result);
	
	$nonetscapes = 0;
	$nomsies = 0;
	$nolynxs = 0;
	$nooperas = 0;
	$nowebtvs = 0;
	$nokonqerors = 0;
	$nobots = 0;
	$noothers = 0;
	$nopeople = 0;
	$percentnetscapes = 0;
	$percentmsies = 0;
	$percentlynxs = 0;
	$percentoperas = 0;
	$percentwebtvs = 0;
	$percentkonqerors = 0;
	$percentbots = 0;
	$percentothers = 0;
	$visitors = mysql_numrows($result);
	
	echo "<b><center>Database Output</center></b><br><br>";
	echo "<p>  </p><p>   </p><p class = style7><b><u>Individual Statistics</u></b>";
	
	mysql_close();
	
	echo "<div align=\"center\"><table width=\"200\" border=\"2\">
    <tr>";	
	$i=0;
	while ($i < $num) {
	
	$ip=mysql_result($result,$i,"ip");
	$agent=mysql_result($result,$i,"agent");
	$referer=mysql_result($result,$i,"referrer");
	
	if($referer == ""){ $referer = " - - none - - "; }
	if($agent == "Netscape"){ $nonetscapes ++; }
	if($agent == "MSIE"){ $nomsies ++; }
	if($agent == "Lynx"){ $nolynxs ++; }
	if($agent == "Opera"){ $nooperas ++; }
	if($agent == "WebTV"){ $nowebtvs ++; }
	if($agent == "Konqueror"){ $nokonqerors ++; }
	if($agent == "Bot"){ $nobots ++; }
	if($agent == "Other"){ $noothers ++; }
	
	echo "<td>".$ip."</td>";
	echo "<td>".$agent."</td>";
	echo "<td>".$referer."</td>";
	echo "<td> <a href = \"http://www.myfileminder.com/Admin/AdminStats2a.php?uname=Admin&pword=Sysop&field01=".$ip."&field02=".$agent."&field03=".$referer."\">Update</a></td>";
	echo "</tr>
  <tr>";
	$i++;
	}
	echo "</tr>
  </table>
</div>";
$percentnetscapes = $nonetscapes / $visitors * 100;
$percentmsies = $nomsies / $visitors * 100;
$percentlynxs = $nolynxs / $visitors * 100;
$percentoperas = $nooperas / $visitors * 100;
$percentwebtvs = $nowebtvs / $visitors * 100;
$percentkonqerers = $nokonqerors / $visitors * 100;
$percentbots = $nobots / $visitors * 100;
$percentothers = $noothers / $visitors * 100;

echo "<p class = style7><b><u>Overall Statistics</u></b>";
echo "<p class = style7>Total Visitors: " . $visitors;
echo "<p class = style7><br>--------------------";
echo "<p class = style7>Netscape Users: " . $nonetscapes;
echo "<br>MSIE Users: " . $nomsies;
echo "<br>Lynx Users: " . $nolynxs;
echo "<br>Opera Users: " . $nooperas;
echo "<br>WebTV Users: " . $nowebtvs;
echo "<br>Konqueror Users: " . $nokonqerors;
echo "<br>Automated Bots: " . $nobots;
echo "<br>Other: " . $noothers;
echo "<p class = style7><br>--------------------";
echo "<p class = style7>Percentage of Netscape Users: " . $percentnetscapes;
echo "<br>Percentage of MSIE Users: " . $percentmsies;
echo "<br>Percentage of Lynx Users: " . $percentlynxs;
echo "<br>Percentage of Opera Users: " . $percentoperas;
echo "<br>Percentage of WebTV Users: " . $percentwebtvs;
echo "<br>Percentage of Konqueror Users: " . $percentkonqerors;
echo "<br>Percentage of Automated Bots: " . $percentbots;
echo "<br>Percentage of Others: " . $percentothers;



when it runs out of time is there a way to re-open the connection and continue the script?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
How many results do you have with this query ? I can't believe your query takes +30 seconds to be executed...
 
0
•••
On phpmyadmin it takes 0.0017 seconds for the same query.. 55 rows, my server must just be incredibly slow then...

i'll contact them
 
0
•••
phpmyadmin is just a php script like yours. Maybe a php problem rather... Try to remove the mysql_close or put it at the end, or try to remove some php code and just display the rows number to check if query is correctly executed.
 
0
•••
PHP:
	$username="--not gonna post--";
	$password="--not gonna post--";
	$database="myfile";
	$host="mysql5.streamline.net";
	
	$nonetscapes = 0;
	$nomsies = 0;
	$nolynxs = 0;
	$nooperas = 0;
	$nowebtvs = 0;
	$nokonqerors = 0;
	$nobots = 0;
	$noothers = 0;
	$nopeople = 0;
	$percentnetscapes = 0;
	$percentmsies = 0;
	$percentlynxs = 0;
	$percentoperas = 0;
	$percentwebtvs = 0;
	$percentkonqerors = 0;
	$percentbots = 0;
	$percentothers = 0;
	
	echo "<b><center>Database Output</center></b><br><br>";
	echo "<p>  </p><p>   </p><p class = style7><b><u>Individual Statistics</u></b>";

	mysql_connect($host,$username,$password);
	@mysql_select_db($database);
	$query="SELECT * FROM myfile_visitors";
	$result=mysql_query($query);
	$num=mysql_numrows($result);
	$visitors = $num;
	mysql_close();
	
	echo "<div align=\"center\"><table width=\"200\" border=\"2\">
    <tr>";	
	$i=0;
	while ($i < $num) {
	
	$ip=mysql_result($result,$i,"ip");
	$agent=mysql_result($result,$i,"agent");
	$referer=mysql_result($result,$i,"referrer");
	
	if($referer == ""){ $referer = " - - none - - "; }
	if($agent == "Netscape"){ $nonetscapes ++; }
	if($agent == "MSIE"){ $nomsies ++; }
	if($agent == "Lynx"){ $nolynxs ++; }
	if($agent == "Opera"){ $nooperas ++; }
	if($agent == "WebTV"){ $nowebtvs ++; }
	if($agent == "Konqueror"){ $nokonqerors ++; }
	if($agent == "Bot"){ $nobots ++; }
	if($agent == "Other"){ $noothers ++; }
	
	echo "<td>".$ip."</td>";
	echo "<td>".$agent."</td>";
	echo "<td>".$referer."</td>";
	echo "<td> <a href = \"http://www.myfileminder.com/Admin/AdminStats2a.php?uname=Admin&pword=Sysop&field01=".$ip."&field02=".$agent."&field03=".$referer."\">Update</a></td>";
	echo "</tr>
  <tr>";
	$i++;
	}
	echo "</tr>
  </table>
</div>";
$percentnetscapes = $nonetscapes / $visitors * 100;
$percentmsies = $nomsies / $visitors * 100;
$percentlynxs = $nolynxs / $visitors * 100;
$percentoperas = $nooperas / $visitors * 100;
$percentwebtvs = $nowebtvs / $visitors * 100;
$percentkonqerers = $nokonqerors / $visitors * 100;
$percentbots = $nobots / $visitors * 100;
$percentothers = $noothers / $visitors * 100;

echo "<p class = style7><b><u>Overall Statistics</u></b>";
echo "<p class = style7>Total Visitors: " . $visitors;
echo "<p class = style7><br>--------------------";
echo "<p class = style7>Netscape Users: " . $nonetscapes;
echo "<br>MSIE Users: " . $nomsies;
echo "<br>Lynx Users: " . $nolynxs;
echo "<br>Opera Users: " . $nooperas;
echo "<br>WebTV Users: " . $nowebtvs;
echo "<br>Konqueror Users: " . $nokonqerors;
echo "<br>Automated Bots: " . $nobots;
echo "<br>Other: " . $noothers;
echo "<p class = style7><br>--------------------";
echo "<p class = style7>Percentage of Netscape Users: " . $percentnetscapes;
echo "<br>Percentage of MSIE Users: " . $percentmsies;
echo "<br>Percentage of Lynx Users: " . $percentlynxs;
echo "<br>Percentage of Opera Users: " . $percentoperas;
echo "<br>Percentage of WebTV Users: " . $percentwebtvs;
echo "<br>Percentage of Konqueror Users: " . $percentkonqerors;
echo "<br>Percentage of Automated Bots: " . $percentbots;
echo "<br>Percentage of Others: " . $percentothers;

all I had to do was re-arrange the script..
 
0
•••
Dynadot โ€” .com Registration $8.99Dynadot โ€” .com Registration $8.99
Unstoppable Domains
Domain Recover
DomainEasy โ€” Live Options
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back