|
Posted by no on 07/26/06 16:31
On 26 Jul 2006 08:18:17 -0700, himilecyclist@yahoo.com wrote:
>I am trying to use the SQL "SELECT INTO" to create a copy of a MySQL
>database.
>
>My PHP code looks like this:
>
><?php
>
>//Connect to server and database
>
>include ("Connections/ovrs.inc");
>
>if (isset($_POST['cmdBackup']))
>{
> $sql = "SELECT * INTO edenbackup FROM edenmaster";
>
>
> $result = mysql_query($sql) or die
>(ErrorCall(mysql_error(),"frmBackup.php","1"));
>
> echo "The Backup is Complete";
>}
>
>?>
>
>I get an SQL error when running this. If I change the SQL Statement to
>be "SELECT * FROM edenmaster" it works fine, so I know the connection
>is OK.
>
>What is the correct syntax for "SELECT * INTO" for MySQL?
Not sure which version of MySQL you are running but see
http://dev.mysql.com/doc/refman/4.1/en/select.html
In particular: "The SELECT ... INTO OUTFILE 'file_name' form of SELECT
writes the selected rows to a file. The file is created on the server
host, so you must have the FILE privilege to use this syntax."
So, the argument specifies a file name, not another database AND you
need to have write permission on the server wherever you are going ot
put the file.
Chris R.
Navigation:
[Reply to this message]
|