Hi Rob:

At 1:09 PM -0400 8/16/10, Rob Marscher wrote:
If you don't have server access, then long story short, you can't use SELECT ... INTO OUTFILE. It's a server side operation -- from http://dev.mysql.com/doc/refman/5.1/en/select.html, "the file is created on the server host." Plus from reading the other posts, you don't have permission to do it anyway.

That's what I thought, but my host (who is generally more knowledgeable than me) was telling me that the reported error was a logon problem -- however -- I *knew* it wasn't. There was something else going on.

-------------

Is php running on a unix server? As someone else mentioned, you could at least try using the backtick operator to execute mysqldump on the command line:

$hostname = 'mysqlHostname'; // maybe not needed if it's on locahost via socket
$username = 'mysqlusername';
$password = 'your-password';
$db = 'theDbName';
$pathToFTPHome = '/home/accountusername';
$output = `mysqldump -h{$hostname} -u{$username} -p{$password} {$db} | gzip > {$pathToFTPHome}/dbdump.sql.gz`;

Then you can check via ftp if the mysqldump was successful after running the script.

You could also try it like this:
echo `mysqldump -h{$hostname} -u{$username} -p{$password} {$db}`;

I tried that (and several versions) via an exec() where it does create a file, but nothing is in the file. I'm not sure as to what is happening -- another investigation to tilt. :-)

-------------

If those options don't work, then just do your select statements in php to get the data you want, iterate through each row, and output the data. fputcvs is handy if you want to write the data as a csv file: http://php.net/fputcsv

That's my current method, but I was investigating the syntax of "SELECT ... INTO OUTFILE" which appeared much cleaner and less code. This quest wasn't to solve a problem but rather to investigate a possible alternative solution.

-------------

Most shared hosting providers let you do backups through a control panel interface or do it automatically for you every night. Might want to double check that it's not already being done.

Not that you said otherwise, but I know that. My client, in this case, wants a backup to automagically appear on their desktop via click of a button. I can do that easy enough, but my investigation here was limited to "SELECT ... INTO OUTFILE" where I received mixed advice on the PHP list.

At least here, you were able to tell me definitively that I could not do it and that's sufficient "end of investigation" for me.

Thanks very much for your time and expertise.

Cheers,

tedd

--
-------
http://sperling.com/
_______________________________________________
New York PHP Community MySQL SIG
http://lists.nyphp.org/mailman/listinfo/mysql

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to