php-general Digest 4 Aug 2001 16:58:11 -0000 Issue 796 Topics (messages 61221 through 61248): Re: PHP MyAdmin Error---weird 61221 by: CW Huang Re: How to add an excel file directly to MySQL database using PHP? 61222 by: Joel Ricker Re: IF ELSEIF ELSE?? 61223 by: Joel Ricker How to destroy a $variable 61224 by: Gerard Samuel 61228 by: Daniel Rezny 61231 by: Jeff Lewis 61240 by: James Tan Re: Linux & PHP Install Problems (was: Oh and one more thing) 61225 by: Joel Ricker Installation error.. 61226 by: Ryan Christensen 61239 by: James Tan 61247 by: Ryan Christensen PHP + GD 2.0.1 problem. 61227 by: speedboy most recent 5 rows 61229 by: Justin French 61230 by: Jeff Lewis 61232 by: Justin French 61233 by: Jeff Lewis 61235 by: Jeff Lewis 61236 by: Justin French php suporrt IMAP in apache 61234 by: Spear Postgresql + Sessions + Large objects. 61237 by: speedboy Re: Need Help Compiling PHP with Apache modules 61238 by: Andreas D. Landmark Re: shtml or php ?? 61241 by: Dave.O Re: weird behavior with a form 61242 by: mike cullerton include path syntax for php.ini under windows 61243 by: Mark Lo file downloads 61244 by: Data Driven Design 61245 by: Rasmus Lerdorf 61248 by: Data Driven Design Re: New lists (was [PHP] Attitude of B van Ouwerkerk) 61246 by: Joel Ricker Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] ----------------------------------------------------------------------
> > > Hello everyone, > > Need some help. I installed phpMyAdmin on this new server and cannot > get it to work. I've installed this tool many times, so i'm pretty > comfortable with the installation process. However, I've never ran into > the errors I am getting today. > > The server is Apache+PHP 4.0.6 > > Error 1) When I first installed phpMyAdmin, I got the following error: > > "... magic_quotes_gpc is not enabled. phpMyAdmin needs this to > work..." > > Action: > I had my ISP turned on Magic Quotes in my PHP.ini file. > Now, phpinfo() shows the following settings: > > magic_quotes_gpc On > magic_quotes_runtime On > magic_quotes_sybase On > > > error 2) > > The above seetings solve the 'error' issues. However, phpMyAdmin now > shows a blank page when I try to access it. > > What can cause this ? > Does it have anything to do with magic_quotes being turned on? > ...that's what it requested in the first place. > > > Am I missing something? > > Please help. > > -John > > > > phpmyadmin also needs "register_globals = On" in php.ini hope this helps...:)
> How can I add an excel file with *.xls extension > directly into MySQL database..is it possible to do or > I need to convert it into *.csv format or *.txt format > first? Yes you will need to save it as a .txt file. Excel will prompt you for how you want to delimit your text. Commas are about the easiest way. Are you using phpMyAdmin? I know it has a built in function to import a comma delimited (or anything-delimited for that matter) text file. I'm sure other MySql managers support it as well. If PHP is your only interface to MySQL let me know and I'll try and provide you with the code you need. Joel
example something you might > want to look at the type of data the person is entering, a little > validation. I hope that helps. Right. And if you'ld like here is something I came up with recently that I kind of liked that you could use if you want. I'd like other peoples opinions as well as to what I'm doing: switch ( [posted form submit name] ) { case ( [posted form submit value] ): if (error check form value) { $Error["aname"] = 1; print [Error in form value]; } if (error check another form value) { $Error["anothername"] = 1; print [Error in another form value]; } if (count($Error) == 0) { process form values do something or show a new page break; } default: Show form [I use the error values to highlight bad form entries like: ] if ($Error["Name"]) { ?><font color=#FF0000>Name</font><? } else { ?>Name<? break; } So basically the result of this is, if the enter a bad form value after submission, it prints out the errors, skips the processing block and since there was no break, it continues through to the default block and reshows the form for resubmission. What do you think? Joel
Ok I have a form with a $PHP_SELF target, and I enter parts of the form when they enter information if something is wrong with their input. Now what I would like to do is destroy all the variables when the form is correct and posted, so that when the page comes back up again, I post a thank you message, and the form is blank. Just a thought. I tried setting strings to empty after data is submitted to the database like so $Age = ""; etc.... at the bottom of the file. Bounce some ideas of me. Thanks
Hello Gerard, Saturday, August 04, 2001, 7:34:06 AM, you wrote: GS> Ok I have a form with a $PHP_SELF target, and I enter parts of the form GS> when they enter information if something is wrong with their input. Now GS> what I would like to do is destroy all the variables when the form is GS> correct and posted, so that when the page comes back up again, I post a GS> thank you message, and the form is blank. Just a thought. GS> I tried setting strings to empty after data is submitted to the database GS> like so $Age = ""; etc.... at the bottom of the file. GS> Bounce some ideas of me. Thanks you can destroy variable with unset function. Manual is on php.net page. Or simple do not send this variable to next page I hope it helps -- Best regards, Daniel mailto:[EMAIL PROTECTED]
Gerard, Try using: unset($Age); Jeff > -----Original Message----- > From: Gerard Samuel [mailto:[EMAIL PROTECTED]] > Sent: Saturday, August 04, 2001 1:34 AM > To: PHP > Subject: [PHP] How to destroy a $variable > > > Ok I have a form with a $PHP_SELF target, and I enter parts of the form > when they enter information if something is wrong with their input. Now > what I would like to do is destroy all the variables when the form is > correct and posted, so that when the page comes back up again, I post a > thank you message, and the form is blank. Just a thought. > I tried setting strings to empty after data is submitted to the database > like so $Age = ""; etc.... at the bottom of the file. > > Bounce some ideas of me. Thanks > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > >
hi gerald, ok.. u could assign values to form input... eg: $myname= ""; <input type=text name=name value=<?=$myname?>> ok.. for the thank you? simply do a if syntax to check if it's been submited... and put in a alert for ur javascript.. eg: <? ... //do your statement to put in the values ?> <html>... <? if($submited) { ?> <script> alert("thank you for your submittion..." ) ; </script> <? } ?> hope it works :) Gerard Samuel wrote: > Ok I have a form with a $PHP_SELF target, and I enter parts of the form > when they enter information if something is wrong with their input. Now > what I would like to do is destroy all the variables when the form is > correct and posted, so that when the page comes back up again, I post a > thank you message, and the form is blank. Just a thought. > I tried setting strings to empty after data is submitted to the database > like so $Age = ""; etc.... at the bottom of the file. > > Bounce some ideas of me. Thanks -- ---PHP Rules--- James Tan Web programmer(php, c/c++, asp) Irc: Unknown007(dalnet) Country: Malaysia Clients List: http://www.ogaya.com http://www.tahbauto.com http://www.aseanvalues.com http://www.e-cpo.com http://your_own_portal?
> > 1) format your harddrive > > 2) take out your motherboard and spraypaint it > > bright orange. Ok I did that. > > 3) dance around the desk three times holding the > > motherboard above your head chanting > > "mail mail, give me mail" > > "date date, give me date" > > "ooooga booga woooga shooga" I felt a little silly but I did that too. > > 4) install linux > > 5) install apache > > 6) install PHP I tried doing that but computer isn't working right. It smokes now when I turn it on and there is a strange smell coming from my computer vents. Did I use the right color orange? Please help.
Quick question.. I'm installing PHP 4.0.6 on a fresh install of Trustix 1.2. It compiles fine (I've even slimmid down the modules I'm compiling it with down to just apxs+mysql), but when I try to restart apache, it gives me the following error: Starting httpd: Syntax error on line 241 of /etc/httpd/conf/httpd.conf: Cannot load /etc/httpd/modules/libphp4.so into server: /usr/lib/libimap.so: undefined symbol: SSL_CTX_set_tmp_rsa_callback Now, it mentions libimap.so, which is odd. after getting this error the first time I tried recompiling (after a "make clean".. which should clear out the previous config, right?) Thoughts? Ryan
hi Ryan, did u make clean on your php 2? i can't recall, u must delete a file config.*** (i can't recall the extension...) b4 u reconfigure... refer in the php install.txt hope it works :) regards, James Ryan Christensen wrote: > Quick question.. > > I'm installing PHP 4.0.6 on a fresh install of Trustix 1.2. It compiles > fine (I've even slimmid down the modules I'm compiling it with down to > just apxs+mysql), but when I try to restart apache, it gives me the > following error: > > Starting httpd: Syntax error on line 241 of /etc/httpd/conf/httpd.conf: > Cannot load /etc/httpd/modules/libphp4.so into server: > /usr/lib/libimap.so: undefined symbol: SSL_CTX_set_tmp_rsa_callback > > Now, it mentions libimap.so, which is odd. after getting this error the > first time I tried recompiling (after a "make clean".. which should > clear out the previous config, right?) > > Thoughts? > > Ryan -- ---PHP Rules--- James Tan Web programmer(php, c/c++, asp) Irc: Unknown007(dalnet) Country: Malaysia Clients List: http://www.ogaya.com http://www.tahbauto.com http://www.aseanvalues.com http://www.e-cpo.com http://your_own_portal?
Yup, I did. I actually later found out that all I had to do was remove the old libphp4.so file, THEN recompile. Thanks anyways, Ryan > -----Original Message----- > From: James Tan [mailto:[EMAIL PROTECTED]] > Sent: Saturday, August 04, 2001 5:35 AM > To: [EMAIL PROTECTED] > Subject: [PHP] Re: Installation error.. > > > hi Ryan, > > did u make clean on your php 2? > > i can't recall, u must delete a file config.*** (i can't recall the > extension...) b4 u reconfigure... > refer in the php install.txt > > hope it works :) > > regards, > > James > > > > Ryan Christensen wrote: > > > Quick question.. > > > > I'm installing PHP 4.0.6 on a fresh install of Trustix 1.2. It > > compiles fine (I've even slimmid down the modules I'm compiling it > > with down to just apxs+mysql), but when I try to restart apache, it > > gives me the following error: > > > > Starting httpd: Syntax error on line 241 of > > /etc/httpd/conf/httpd.conf: Cannot load > /etc/httpd/modules/libphp4.so > > into server: > > /usr/lib/libimap.so: undefined symbol: SSL_CTX_set_tmp_rsa_callback > > > > Now, it mentions libimap.so, which is odd. after getting > this error > > the first time I tried recompiling (after a "make clean".. which > > should clear out the previous config, right?) > > > > Thoughts? > > > > Ryan > > -- > ---PHP Rules--- > James Tan > Web programmer(php, c/c++, asp) > Irc: Unknown007(dalnet) > Country: Malaysia > Clients List: > http://www.ogaya.com > http://www.tahbauto.com > http://www.aseanvalues.com > http://www.e-cpo.com > http://your_own_portal? > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] To contact the list > administrators, e-mail: [EMAIL PROTECTED] > >
Hello I am trying to install PHP 4.0.6 with GD 2+ support and I am receiving an error at `make` time. Can anyone suggest something to try and fix this problem? Thankyou :) I have installed the following with no path changes to the defaults: freetype-2.0.4.tar.gz gd-2.0.1.tar.gz jpegsrc.v6b.tar.gz* libpng-1.0.12.tar.gz pdflib-4.0.1.tar.gz zlib-1.1.3.tar.gz My configure string is: ./configure --with-apache=../apache_1.3.20 --enable-trans-sid --with-jpeg-dir=/usr/local --with-gd=/usr --with-png-dir=../libpng-1.0.12 --with-zlib-dir=../zlib-1.1.3 --with-pdflib --with-pgsql --enable-static-pdflib --enable-ftp --enable-gd-native-ttf --with-freetype-dir=/usr/local/include/freetype2 This is the error at `make` time for PHP: Making all in gd make[2]: Entering directory `/tmp/www/php-4.0.6/ext/gd' make[3]: Entering directory `/tmp/www/php-4.0.6/ext/gd' gcc -I. -I/tmp/www/php-4.0.6/ext/gd -I/tmp/www/php-4.0.6/main -I/tmp/www/php-4.0.6 -I/tmp/www/apache_1.3.20/src/include -I/tmp/www/apache_1.3.20/src/os/unix -I/tmp/www/php-4.0.6/Zend -I/usr/local/include -I/usr/local/include/freetype2/freetype -I/tmp/www/php-4.0.6/ext/mysql/libmysql -I/tmp/www/php-4.0.6/ext/xml/expat/xmltok -I/tmp/www/php-4.0.6/ext/xml/expat/xmlparse -I/tmp/www/php-4.0.6/TSRM -DSUPPORT_UTF8 -DXML_BYTE_ORDER=12 -g -O2 -c gd.c && touch gd.lo gd.c: In function `php_minit_gd': gd.c:296: `gdPie' undeclared (first use in this function) gd.c:296: (Each undeclared identifier is reported only once gd.c:296: for each function it appears in.) gd.c:297: `gdChord' undeclared (first use in this function) gd.c:298: `gdNoFill' undeclared (first use in this function) gd.c:299: `gdEdged' undeclared (first use in this function) gd.c: In function `php_if_imagecreatetruecolor': gd.c:577: warning: assignment makes pointer from integer without a cast make[3]: *** [gd.lo] Error 1 make[3]: Leaving directory `/tmp/www/php-4.0.6/ext/gd' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/tmp/www/php-4.0.6/ext/gd' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/tmp/www/php-4.0.6/ext' make: *** [all-recursive] Error 1
Hi all, I have a table with the column "id", which is a unique number, auto-incremented, so the highest "id" is the most recent. I wish to retrieve the last five rows from the table (there will be hundreds of rows) and print some columns to the screen. I have this table: id,heading,text,user This is what I have, which retrieves ALL rows, in id order, from smallest to greatest: --- $db = mysql_connect("localhost", "root", ""); mysql_select_db("soundpimp",$db); $sql = "SELECT * FROM news"; $sql_result = mysql_query($sql); while ($sql_myrow = mysql_fetch_array($sql_result)) { echo $sql_myrow["id"]."<BR>".$sql_myrow["heading"]."<BR>".$sql_myrow["text"]."<BR>".$sql_myrow["user"]."<BR>---<BR>"; } --- What I'd like to do is ONLY echo the highest 5 id's (the latest 5 rows), in REVERSE ORDER. How do I approch this? Do I find the highest ID, then do 5 SELECTS, counting back? Any code / ideas appreciated. Jsutin French
Try this SQL Justin: $sql = "SELECT * FROM news DESC LIMIT 5"; Jeff > -----Original Message----- > From: Justin French [mailto:[EMAIL PROTECTED]] > Sent: Saturday, August 04, 2001 5:52 AM > To: php > Subject: [PHP] most recent 5 rows > > > Hi all, > > I have a table with the column "id", which is a unique number, > auto-incremented, so the highest "id" is the most recent. > > I wish to retrieve the last five rows from the table (there > will be hundreds of rows) and print some columns to the screen. > > > > I have this table: > id,heading,text,user > > > This is what I have, which retrieves ALL rows, in id order, from > smallest to greatest: > > --- > $db = mysql_connect("localhost", "root", ""); > mysql_select_db("soundpimp",$db); > > $sql = "SELECT * FROM news"; > $sql_result = mysql_query($sql); > > while ($sql_myrow = mysql_fetch_array($sql_result)) > { > echo > $sql_myrow["id"]."<BR>".$sql_myrow["heading"]."<BR>".$sql_myrow["t > ext"]."<BR>".$sql_myrow["user"]."<BR>---<BR>"; > } > --- > > What I'd like to do is ONLY echo the highest 5 id's (the latest 5 rows), > in REVERSE ORDER. > > > How do I approch this? Do I find the highest ID, then do 5 SELECTS, > counting back? > > Any code / ideas appreciated. > > > > Jsutin French > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > >
Jeff Lewis wrote: > Try this SQL Justin: > > $sql = "SELECT * FROM news DESC LIMIT 5"; Hrm, Won't that retrieve the FIRST 5 rows, not the LAST 5? Justin French
It will give you the 5 HIGHEST values in your auto incremented field. If it was returneding the first 5, or the wrong 5, repace the DESC with ASC. Jeff > -----Original Message----- > From: Justin French [mailto:[EMAIL PROTECTED]] > Sent: Saturday, August 04, 2001 6:09 AM > To: [EMAIL PROTECTED] > Cc: php > Subject: Re: [PHP] most recent 5 rows > > > Jeff Lewis wrote: > > > Try this SQL Justin: > > > > $sql = "SELECT * FROM news DESC LIMIT 5"; > > > Hrm, > > Won't that retrieve the FIRST 5 rows, not the LAST 5? > > > Justin French > >
Sorry, forgot the ORDER BY, here is what you're looking for: $sql = "SELECT * FROM news ORDER BY id DESC LIMIT 5"; In a list of numbers up to 10, this would return rows 6,7,8,9, and 10. Jeff www.hyrum.net www.xnull.com > -----Original Message----- > From: Jeff Lewis [mailto:[EMAIL PROTECTED]] > Sent: Saturday, August 04, 2001 7:06 AM > To: [EMAIL PROTECTED] > Cc: php > Subject: RE: [PHP] most recent 5 rows > > > It will give you the 5 HIGHEST values in your auto incremented > field. If it > was returneding the first 5, or the wrong 5, repace the DESC with ASC. > > Jeff > > > -----Original Message----- > > From: Justin French [mailto:[EMAIL PROTECTED]] > > Sent: Saturday, August 04, 2001 6:09 AM > > To: [EMAIL PROTECTED] > > Cc: php > > Subject: Re: [PHP] most recent 5 rows > > > > > > Jeff Lewis wrote: > > > > > Try this SQL Justin: > > > > > > $sql = "SELECT * FROM news DESC LIMIT 5"; > > > > > > Hrm, > > > > Won't that retrieve the FIRST 5 rows, not the LAST 5? > > > > > > Justin French > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > >
Jeff Lewis wrote: > $sql = "SELECT * FROM news ORDER BY id DESC LIMIT 5"; many many many thanks for your (very quick) help!! Justin French
when i make apache activate-module=src/modules/php4/libphp4.a it display this error /usr/src/bs/BUILD/imap-2000/c-client/auth_gss.c:344: undefined reference to `gss _release_buffer' /usr/src/bs/BUILD/imap-2000/c-client/auth_gss.c:349: undefined reference to `gss _release_name' /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libc-client.a(osdep.o): In func tion `ssl_onceonlyinit': /usr/src/bs/BUILD/imap-2000/c-client/auth_ssl.c:166: undefined reference to `RAN D_seed' /usr/src/bs/BUILD/imap-2000/c-client/auth_ssl.c:181: undefined reference to `SSL how to fix it?
I am having trouble with the following function working _with_ sessions. If I turn off my session checking function it enables you to download the file flawlessly, if sessions are turned on then Internet Explorer displays an error: Internet Explorer cannot download ...URL Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later. Is there a way I can download large objects from postgresql _with_ sessions? Thankyou. function retrieve_file($id) { global $dbconn1; $result1 = pg_exec ($dbconn1, "select data, file_name from files where id='$id';"); $image_oid = pg_result($result1 ,0, 'data'); $file_name = pg_result($result1 ,0, 'file_name'); header ("Content-disposition: filename=\"$file_name\""); header("Content-type: application/download"); pg_exec ($dbconn1, "begin transaction;"); $image_handle = pg_loopen ($dbconn1, $image_oid, 'r'); pg_loreadall ($image_handle); pg_loclose ($image_handle); pg_exec ($dbconn1, "commit transaction;"); } }
At 04.08.2001 01:33, Matthew Tyler wrote: >Hey all, > >I have a server with Apache running on it, and it currently uses PHP3 >(installed with the OS). I am trying to upgrade to PHP4, but from the >php.net documentation it appears that I have to reinstall Apache in order to >have access to the PHP4 apache modules, something I would NOT like to do. Is >there any way around this? > >- Matt If you've compiled apache with support for static modules, there aren't any way around it, if you've got support for dynamic modules (DSO) you should be able to compile a new module and make apache load it. However I'd suspect that the OS you didn't disclose probably compiled staticly as it's the easiest way of compiling apache+php, since it's php3 that came by default you might want to upgrade to a newer apache version too. -- Andreas D Landmark / noXtension Real Time, adj.: Here and now, as opposed to fake time, which only occurs there and then.
This brings me back to an original problem I had before, I do have the instruction in my conf file to load php as a module but I get the following error:- [warn] loaded DSO c:/usr/php/sapi/php4apache.dll uses plain apache 1.3 api, this module might crash under EAPI! (please recompile it with -DEAPI) I have downloaded this binary from php.net I have tried 4.0.5 and 4.0.6 and I get this error on both. Any suggestions Dave ----- Original Message ----- From: "Richard Lynch" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, August 03, 2001 4:01 AM Subject: Re: [PHP] shtml or php ?? > > Can anyone help me with this, I am using apache and assume that this > virtual > > command should work, am I best to leave it in shtml or should I change to > > php as I am using php more and more ??? Please can somebody help me > > There's using Apache with PHP as a Module, and there's using Apache with PHP > as a CGI. > > If your httpd.conf file has something like: > AddModule php > LoadModule php > Handler application/x-httpd-php php > (and not with comment character # in front of them) > you are using Module > > Conversely, if you httpd.conf file has stuff like: > Action application/x-httpd-php php > Alias php /path/to/php > in it, you are using CGI. > > Actually, I'm betting <?php phpinfo();?> will tell you if you are using PHP > as Module or CGI. > > If it's CGI, virtual will not work, as Rasmus said. > > -- > WARNING [EMAIL PROTECTED] address is an endangered species -- Use > [EMAIL PROTECTED] > Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm > Volunteer a little time: http://chatmusic.com/volunteer.htm > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] >
on 8/3/01 6:43 PM, Ben Bleything at [EMAIL PROTECTED] wrote: > Whacky. It works now => i seem to remember a thread not that long ago (maybe it was on a different list) similar to this. the conclusion was that netscape and ie (and i'm sure others as well) handle this differently, and one of them (i can't remember which) handles it differently if there is more than one button on the page. i think if the browser is ie and there is only one submit button, hitting enter also returns submit='whatever'. otherwise, no guarantees. it appears that hiddens are the way to go -- mike cullerton
Hi, I would like to know the correct syntax of include_path for php.ini under windows. I have tried to set the include path as "C:\home\main\require" but it doesn't work. Thanks in advance Mark
Why does this code produce a page cannot be displayed error? <?php mysql_connect("localhost","username","password"); mysql_select_db("database"); $query = "SELECT file_path from photos where photos_id=$photos_id"; $result = @mysql_query("$query"); $row = mysql_fetch_row($result); $path = $row[0]; $parts = split("/",$path); $file_name = $parts[count($parts)-1]; header("Content-Type: application/download\n"); header("Content-Disposition: attachment; filename=$file_name"); header("Content-Transfer-Encoding: binary"); $fn=fopen($path , "r"); fpassthru($fn); ?> Data Driven Design 1506 Tuscaloosa Ave Holly Hil, FL 32117 http://www.datadrivendesign.com http://www.rossidesigns.net
> Why does this code produce a page cannot be displayed error? Your query is probably wrong. Comment out the header stuff and add some error checking to your query. > <?php > mysql_connect("localhost","username","password"); > mysql_select_db("database"); > $query = "SELECT file_path from photos where photos_id=$photos_id"; > $result = @mysql_query("$query"); The quotes are useless there. Change the above to: $result = mysql_query($query) or die(mysql_error()); > $row = mysql_fetch_row($result); > $path = $row[0]; > $parts = split("/",$path); Use explode() instead. No sense wasting a regex on a trivial delimiter like that. > $file_name = $parts[count($parts)-1]; uh.. basename() would do the same thing, so you can get rid of this line and also the split/explode actually. > header("Content-Type: application/download\n"); > header("Content-Disposition: attachment; filename=$file_name"); > header("Content-Transfer-Encoding: binary"); > $fn=fopen($path , "r"); > fpassthru($fn); readfile($path); would replace those two lines. -Rasmus
I made the changes you suggested and it's still a no go. I'm sure of the query because print "<img src=\"$path\">"; Will display the image I'm trying to download. This is my environment. PHP Version 3.0.16 Apache/1.3.3 Cobalt safe_mode 1 <?php mysql_connect("localhost","user","pass"); mysql_select_db("db"); $query = "SELECT file_path from photos where photos_id=$photos_id"; $result = @mysql_query($query); $row = mysql_fetch_row($result); $path = $row[0]; $file_name = basename($path); //print "<img src=\"$path\">"; //print "<div align=\"center\">$file_name</div>"; header("Content-Type: application/download\n"); header("Content-Disposition: attachment; filename=$file_name"); header("Content-Transfer-Encoding: binary"); readfile($path); ?> This should work shouldn't it? ----- Original Message ----- From: "Rasmus Lerdorf" <[EMAIL PROTECTED]> To: "Data Driven Design" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Saturday, August 04, 2001 11:57 AM Subject: Re: [PHP] file downloads > > Why does this code produce a page cannot be displayed error? >
> Similarly the FAQ is easy to find, and I do believe the words "support" > suggest where help may be found. Actually my suggestion would be to take a page from way the Python lists are and call it tutor or PHP-tutor. Joel