List:General Discussion« Previous MessageNext Message »
From:Gerald Clark Date:August 1 2002 5:35pm
Subject:Re: Error in using "source" command with PHP
View as plain text  
That is because "source" is a mysql client command, not as sql command.
It gets executed by  the client 'mysql'.
The 'mysql' client reads it line by line, and passes the lines to the 
server.
The server never sees the scriptfile.sql.
You will have to write a PHP modules that reads the file, and passes it 
lin-by-line to the
server, or have PHP execute the mysql client, passing it all options and 
parameters.

Stephen Wardlaw wrote:

>When in MySQL in a terminal, if I enter the command "source scriptfile.sql", 
>MySQL correctly executes the source file.
>
>However, if using PHP, I execute the following commands in a PHP file:
>
><?php
>	// data base is connected...
>
>$query = "source scriptfile.sql";
>$result = mysql_query($query);
>
>I get a MySQL "Query Error - You have an error in your SQL syntax near 
>'source scriptfile.sql' at line 1".
>
>I have tried numerous combinations of parentheses, single quotes and relative 
>and absolute file paths.
>
>Can someone please tell me what I am doing wrong?
>
>Stephen Wardlaw
>Yale labs
>
>
>---------------------------------------------------------------------
>Before posting, please check:
>   http://www.mysql.com/manual.php   (the manual)
>   http://lists.mysql.com/           (the list archive)
>
>To request this thread, e-mail <mysql-thread116125@stripped>
>To unsubscribe, e-mail
> <mysql-unsubscribe-gerald_clark=suppliersystems.com@stripped>
>Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>


Thread
Error in using "source" command with PHPStephen Wardlaw1 Aug
  • Re: Error in using "source" command with PHPGerald Clark1 Aug