sonny Posted July 23, 2009 Share Posted July 23, 2009 I have a small php script that uses a Msql database with entry count of around 1000 (rows max) worst case. My db table is named "visits" and the fields are as follows: id, ip, refer, ua, page, flag, country, region, city, time, vcode Couple of questions Is it really hard to convert this to a simnple text file instead? My Sql database is down more then up, causing page errors galore. Insertion code is: $refer=$_SERVER['HTTP_REFERER']; $ua=$_SERVER['HTTP_USER_AGENT']; $page=substr($_SERVER['PHP_SELF'],1); $now=time(); $queryup="UPDATE visits SET vcode='0' WHERE ip='$ip' && page='$page'"; $resultup=mysql_query($queryup) or die(mysql_error()); $query="INSERT INTO visits VALUES('NULL', '$ip', '$refer', '$ua', '$page', '$flag', '$country', '$region', '$city', '$now', '1')"; $result=mysql_query($query) or die(mysql_error()); I would like to write this data to a simple file instead? Thanks Sonny Quote Link to comment https://forums.phpfreaks.com/topic/167179-covert-a-small-mysql-database-to-file-format/ Share on other sites More sharing options...
ldougherty Posted July 23, 2009 Share Posted July 23, 2009 Use: SELECT ... INTO OUTFILE 'file_name' See http://dev.mysql.com/doc/refman/5.0/en/select.html for more information. I wouldn't suggest this though, a flat file is not a great resource for querying and you'll likely end up with greater issues using a flat file. Quote Link to comment https://forums.phpfreaks.com/topic/167179-covert-a-small-mysql-database-to-file-format/#findComment-881478 Share on other sites More sharing options...
sonny Posted July 23, 2009 Author Share Posted July 23, 2009 I have a small number of rows, I am trying to covert this code to write to a simple txt file instead I also run another perl script that writes 10's of 1000s of rows to a txt file and it has worked for years with no problems. I like Msql personally but this is small job and would be really faster and error free since it will be on the same server reading from a file Do you know how I can convert this over? Thanks Sonny Quote Link to comment https://forums.phpfreaks.com/topic/167179-covert-a-small-mysql-database-to-file-format/#findComment-881485 Share on other sites More sharing options...
sonny Posted July 23, 2009 Author Share Posted July 23, 2009 Use: SELECT ... INTO OUTFILE 'file_name' See http://dev.mysql.com/doc/refman/5.0/en/select.html for more information. I wouldn't suggest this though, a flat file is not a great resource for querying and you'll likely end up with greater issues using a flat file. I agree when your Msql database happends to be on the same server, but when its outside it only doubles your chances of being down Temporarily, until I can convert this particular script code to a flat file, I disabled php error display which will kill the error messages at least. maybe I posted in the wrong section here Sonny Quote Link to comment https://forums.phpfreaks.com/topic/167179-covert-a-small-mysql-database-to-file-format/#findComment-881556 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.