Jump to content

Covert a small Mysql database to file format


sonny

Recommended Posts

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

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 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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.