Fuzzley Posted March 10, 2011 Share Posted March 10, 2011 PHP version 5.2.6 MySQL version 5.0.51a I have this little PHP script to save visitor information: $dbh = mysql_connect($hostname, $username, $password); @mysql_select_db($datab); $time=date("'Y','m','d','l','h','i','s'"); $query = "INSERT INTO $sitename VALUES ('','$ip','$ref','$user_id',$time,'no','no','$proxy','$forp','$via')"; mysql_query($query); mysql_close($dbh); The script works fine for regular users. The problem is that it is too slow for bots (search engine crawlers). I'm guessing the bots wait until the page finishes loading. But because the script is slowish (opens database, writes to it, closes it every time) the bots give up. The page that implements the script has even fallen off google's listing. Is there any way to speed up the opening/closing process? Or is there a way to check if the visitor is a bot? Thanks for any help. Quote Link to comment https://forums.phpfreaks.com/topic/230167-php-and-mysql-inefficient/ Share on other sites More sharing options...
fenway Posted March 10, 2011 Share Posted March 10, 2011 Are you telling me that you don't use the DB for anything else on the page? If you don't care about accuracy, use INSERT DELAYED. Quote Link to comment https://forums.phpfreaks.com/topic/230167-php-and-mysql-inefficient/#findComment-1185337 Share on other sites More sharing options...
Fuzzley Posted March 10, 2011 Author Share Posted March 10, 2011 Thanks, I'll try it. And no, I don't use the database for anything else on that page. Quote Link to comment https://forums.phpfreaks.com/topic/230167-php-and-mysql-inefficient/#findComment-1185390 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.