views:

25

answers:

2

Hello, I have an issue with the MySQL SOURCE command. I am getting the following error:

1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SOURCE /var/www/apps/modx_install.sql' at line 1

The query I am executing is as follows:

mysql_query('SOURCE /var/www/apps/modx_install.sql;')

I was wondering what I was doing wrong here as I have read from several sources that this is the correct syntax.

Thanks

+1  A: 
mysql_query("SOURCE '/var/www/apps/modx_install.sql'")
Alexander.Plutov
That's my guess to, since ';' won't be in the actual filename.
Ben Fransen
Still no luck, getting the same error: Check syntax, etc.. 'SOURCE '/var/www/apps/autoinstall/modx_install.sql''
seacode
+2  A: 

Hi seacode,

it seems your MySQL-Server doesn't know the source command.

If you have shell access you could use

mysql --user=$user --password=$password $database < $file

You can try the same from within PHP

shell( "mysql --user=$user --password=$password $database < $file" );

Cheers.
haggi

haggi
+1 `SOURCE` is not a native mySQL command (just checked the docs), but one specific to the command line client.
Pekka
Nice work mate, that got it!
seacode