Whoops -- the fclose() statement refers to $result when it should refer to $handle. My bad for not at least spot checking the message before hitting send! -- Peter Ellis - pellis@xxxxxxxxxxxxxxx Web Design and Development Consultant naturalaxis | http://www.naturalaxis.com/ On Mon, 2004-08-09 at 20:34 -0700, Peter Ellis wrote: > It has been my experience that you sometimes need to do backquotes (`) > in MySQL queries when cutting/pasting into PHP -- it's the same key as > the tilde (~) on my keyboard. Try: > > $result = mysql_query("SELECT e_mail FROM subscriptionsdatabase WHERE > `discipleship_mailing_list_e_mail_subscription` LIKE 'on'"); > > That should work. I've always used the equal sign instead of LIKE, but > that seems to be a matter of preference. > > Regarding the second part, with the fopen() and fwrite() commands, > that's certainly doable. For example, you could do something like: > > $handle = fopen("/home/blah/blah.txt", "w"); > > $result = mysql_query(...); > > if($result) { > while($somevar = <do mysql fetch from $result>) { > fwrite($handle, $somevar); > } > > ... > } > > fclose($result); > > Now, I realize that code is sort of a hack, but since I'm doing it > mostly on the fly, you'll forgive me my coding errors. Take a look at > the Filesystem section of the PHP manual for information on the > fopen/fwrite() commands, and the MySQL section for more information on > MySQL commands in PHP. > > Hope this helps a little more in solving the puzzle. > -- > Peter Ellis - pellis@xxxxxxxxxxxxxxx > Web Design and Development Consultant > naturalaxis | http://www.naturalaxis.com/ > > On Mon, 2004-08-09 at 22:44 -0400, Ron Piggott wrote: > > It is a problem having write access to the file. This is what the online > > mySQL manual says ... > > > > 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. The file cannot already exist, which > > among other things prevents files such as `/etc/passwd' and database tables > > from being destroyed. The SELECT ... INTO OUTFILE statement is intended > > primarily to let you very quickly dump a table on the server machine. If you > > want to create the resulting file on some client host other than the server > > host, you can't use SELECT ... INTO OUTFILE. In that case, you should > > instead use some command like mysql -e "SELECT ..." > file_name on the > > client host to generate the file. > > > > I need to go with another option. > > > > Another person wrote me and suggested using the fopen(), fwrite() and > > fclose() commands. I haven't investigated this option yet. You know when > > you first learn to walk you do so by example ... I am still needing to know > > which commands to look up and try to apply to my situation. I have got some > > PHP code to work ... I am far from done the project I am working on. > > > > I was able to get the command: > > > > SELECT e_mail > > FROM subscriptionsdatabase > > WHERE discipleship_mailing_list_e_mail_subscription > > LIKE 'on' > > > > to work in the mySQL command prompt but when I put it into a .PHP file I get > > a parse error. I get that parse error by simply coping and pasting the > > command into the PHP file. > > > > In more detail what I am trying to do and why I e-mailed out the question is > > to wipe clean a mailing list data file and re-create the e-mail > > subscriptions data file based on which people joined the list during the > > week. > > > > I am still learning mySQL ... The things you wrote helped me "play" ... I > > didn't get too far in creating code, but I am learning at the same time. > > > > Thanks for the advice. > > > > Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php