p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

  Return to Index  

beginning_php thread: Problem feeding query.sql to mysql>

Message #1 by "Art Stoller" <phphelp@w...> on Wed, 2 Oct 2002 20:06:09
Created a file called  query.sql  using notepad as per page 410 in 
beginning PHP
Saved it to c:/program files/easyphp/mysql/bin/query.sql

When I go back to mysql>
and type 

I get
? you have an error in line 1?

Same thing happens if I save query.sql in 
c:/prgram files/easyphp/www/query.sql

What am I doing wrong?
I want to have this file to save retyping several lines of code

Message #2 by "Nikolai Devereaux" <yomama@u...> on Wed, 2 Oct 2002 12:08:41 -0700
Well, you're not exactly telling mysql that it's to read in SQL commands from a
file.  the mysql> prompt is a command prompt; just like your shell prompt.
Your shell prompt expects commands that it recognizes.

Put it this way; if you were at your shell prompt and you wanted to see the
contents of your sql file, do you type "cat query.sql" or "query.sql"?

Typing "help" at the mysql prompt yields:

mysql> help

MySQL commands:
Note that all text commands must be first on line and end with ';'
help    (\h)    Display this help.
?       (\?)    Synonym for `help'.
clear   (\c)    Clear command.
connect (\r)    Reconnect to the server. Optional arguments are db and host.
ego     (\G)    Send command to mysql server, display result vertically.
exit    (\q)    Exit mysql. Same as quit.
go      (\g)    Send command to mysql server.
notee   (\t)    Don't write into outfile.
print   (\p)    Print current command.
quit    (\q)    Quit mysql.
rehash  (\#)    Rebuild completion hash.
source  (\.)    Execute a SQL script file. Takes a file name as an argument.
status  (\s)    Get status information from the server.
tee     (\T)    Set outfile [to_outfile]. Append everything into given outfile.
use     (\u)    Use another database. Takes database name as argument.

Connection id: 1  (Can be used with mysqladmin kill)

Does anything there look like it will execute an SQL file?  Yes.  "source".

mysql> source query.sql;


  Return to Index