[PHP-DEV] open word with mysql and php
Hi, I have uploaded some files to my database and I want to retrieve the files again. No problem. The next step is to open word if the file is a word document and have the extension .doc and so on. I can create a new word document but I can't open word with the file I got in my database. My script is like this:' ?php // getdata.php3 - by Florian Dittmer [EMAIL PROTECTED] // Example php script to demonstrate the direct passing of binary data // to the user. More infos at http://www.phpbuilder.com // Syntax: getdata.php3?id=id if($id) { // you may have to modify login information for your database server: @MYSQL_CONNECT(myserver,think, secret); @mysql_select_db(binary_data); $query = select bin_data,filetype from binary_data where id=$id; $result = @MYSQL_QUERY($query); $data = @MYSQL_RESULT($result,0,bin_data); $type = @MYSQL_RESULT($result,0,filetype); Header( Content-type: $type); $word = new COM(word.application) or die(Unable to instanciate Word); print Loaded Word, version {$word-Version}\n; //bring it to front $word-Visible = 1; //echo $data; }; ? Regards and thanks' Allan -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] CVS Account Request: tudul
I want to give a pleasure to korean who studying php. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] [PATCH] for proc_close() Bug #17538
Do a cvs diff -u and post the patch to the list with [PATCH] in the subject; CC me directly. I'll try and apply it over the weekend, unless someone else here applies it for you in the meantime. That would be great :) Thanks for your extensive testing of proc_open/proc_close :-) No problems. Something gives me the impression that I'm the first person to use the functions to any great extent, but it's been fun learning and playing with the PHP source. The patch is somewhat more developed than what I posted before, I commented what's actually happening (once I figured out what was actually happening), and it checks that the process exited normally now (it didn't before, which would have returned spurious exit codes in some cases). I am moderately confident that it should be fairy reliable, as opposed to what I posted before, which was more of a one-off this works for me, someone please make it work for everyone. Thanks, KimS ? proc_close_patch Index: ext/standard/exec.c === RCS file: /repository/php4/ext/standard/exec.c,v retrieving revision 1.76 diff -u -r1.76 exec.c --- ext/standard/exec.c 23 May 2002 10:17:07 - 1.76 +++ ext/standard/exec.c 13 Jun 2002 00:03:21 - -559,23 +559,33 GetExitCodeProcess(child, wstatus); FG(pclose_ret) = wstatus; #else -# if HAVE_SYS_WAIT +#if HAVE_SYS_WAIT_H int wstatus; pid_t child, wait_pid; child = (pid_t)rsrc-ptr; do { + /* fetch status of child process */ wait_pid = waitpid(child, wstatus, 0); - } while (wait_pid == -1 errno = EINTR); + + /* if wait_pid == 1 and errno == EINTR, then waitpid() is just +* alerting of a signal that's been caught - so keep looping +* until wait_pid != -1 (the child process has exited) or +* errno != EINTR (there was a real error, not just a caught +* signal) +*/ + } while (wait_pid == -1 errno == EINTR); - if (wait_pid == -1) - FG(pclose_ret) = -1; - else - FG(pclose_ret) = wstatus; -# else + /* if the child process exited normally, set pclose_ret to the exit +* status of the child process, otherwise set it to -1 (this might +* happen if there's no child process, or it didn't exit normally) +*/ + FG(pclose_ret) = wait_pid 0 WIFEXITED(wstatus) ? + WEXITSTATUS(wstatus) : -1; +#else FG(pclose_ret) = -1; -# endif +#endif #endif } -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] CVS Account Request: netholic
I want to translate docs into Korean. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Bug #17538 proc_close() doesn't return exit value of process
Hi, I logged Bug #17538 proc_close() doesn't return exit value of process a little while a ago, full details are at http://bugs.php.net/bug.php?id=17538 obviously, but the short summary is that proc_close() doesn't return the exit value of the process, like it's meant to. The bug I logged has an example script and stuff. Anyway, I needed a fix soon, so I've had a poke around in the PHP source myself, and I have basically got pretty close to a fix. I deliberated for a little bit about whether I should try and make a patch, or log more info on the bug, but I decided that posting to the list was best, because I don't have a magic wand fix, rather some *very* relevant info that a PHP developer will be able to use to create a proper fix. Ok, so, all the problems I found are in ext/standard/exec.c (CVS version of course). This is the offending code: # if HAVE_SYS_WAIT int wstatus; pid_t child, wait_pid; child = (pid_t)rsrc-ptr; do { wait_pid = waitpid(child, wstatus, 0); } while (wait_pid == -1 errno = EINTR); if (wait_pid == -1) FG(pclose_ret) = -1; else FG(pclose_ret) = wstatus; # else FG(pclose_ret) = -1; # endif Firstly, the gdb was showing me that code inside here wasn't getting executed (waitpid() wasn't getting run). It turns out that there is no HAVE_SYS_WAIT in php_config.h, but there is a HAVE_SYS_WAIT_H. I imagine that perhaps it should be HAVE_SYS_WAIT_H? Anyway, that was what was causing the code not to be run. So, for the purposes of my experimentation, I just deleted the # if # else and # endif lines (and the FG() line between else and endif) so that the code could run, since clearly this is the code that sets pclose_ret, which is in turn the number returned by proc_close(). That was the first problem. I'm sure someone more knowledgeable about the PHP source will know if it's actually meant to be HAVE_SYS_WAIT_H, or something else. So, with that removed, I tried to compile, and the } while (wait_pid == -1 errno = EINTR); line gave me an invalid lvalue in assignment compiler error. Changing to errno == EINTR fixed that, but I'm not sure if it's meant to be == or not, or what's meant to be happening. But, I took a punt at ==, and it compiled. Then, I tried running some programs through proc_open() and proc_close(), but php was mangling the return values. The line: FG(pclose_ret) = wstatus; should be FG(pclose_ret) = WEXITSTATUS(wstatus); see man waitpid for details, basically wstatus contains more than just the exit code, and WEXITSTATUS() returns the relevant exit status number. So, I compiled again, and it worked! I ended up with: int wstatus; pid_t child, wait_pid; child = (pid_t)rsrc-ptr; do { wait_pid = waitpid(child, wstatus, 0); } while (wait_pid == -1 errno == EINTR); if (wait_pid == -1) FG(pclose_ret) = -1; else FG(pclose_ret) = WEXITSTATUS(wstatus); Now, it would be great if a PHP developer could apply this, or something along these lines, to the source tree to make proc_close() work (and close my bug!). As I say, I'm no PHP developer, nor even a particularly good C programmer, so there may well be other things to consider when applying a fix that I've missed, but this worked for me :) Thanks, KimS -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Bidirectional Pipe
Hi All, I'm writing something in PHP at the moment, and I *really* need bi-directional pipe support, a la IPC::Open2 in Perl. IPC::Open2 works by returning two filehandles to the command to be run, one which can be written to and it goes to the STDIN of the command that gets run, and one that can be read from to get the output of the command. As far as I can tell, this cannot be done in PHP. passthru() doesn't allow writing to STDIN, apparently this has worked with popen() at some point according to a user comment in the manual, but it doesn't work for me using Linux and Apache. This is a very useful thing to be able to do, as there are many commands under *n?x that you can write to the STDIN of and read processed data from STDOUT, like tar, image processing utilities, tr, etc. I'd like to see this in PHP, and, if it's not there, I'm not opposed to writing to code to do it, since I know how to do this in C. I guess I'm asking: * am I correct that there isn't a way to do this in PHP at the moment? * do people agree that this would be a good thing to have? * if I were to write it, is someone interested in adding it to PHP, and perhaps helping me out with PHP-specific issues? Thanks, KimS -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Bug #10983: php can't select database in mysql, so mysql is not working at all.
From: [EMAIL PROTECTED] Operating system: WINNT 4.0 PHP version: 4.0.5 PHP Bug Type: MySQL related Bug description: php can't select database in mysql, so mysql is not working at all. -- Edit Bug report at: http://bugs.php.net/?id=10983edit=1 -- PHP Development 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]
[PHP-DEV] Bug #10983 Updated: php can't select database in mysql, so mysql is not working at all.
ID: 10983 User Update by: [EMAIL PROTECTED] Status: Closed Bug Type: MySQL related Operating system: WINNT 4.0 PHP Version: 4.0.5 Description: php can't select database in mysql, so mysql is not working at all. sorry, but i was too mad to notice. let me rephrase the whole thing. After i upgrade php from 4.04p1 to 4.05 at WinNT machine, i couldn't get mysql query working at all. Technically, they all work, just i don't get any result back. example: ? echo DATABASE: HealthyBR; $query=select * from MEMBER; $ident = mysql_connect(Kim,root,) or die(Bad query: .mysql_error()); mysql_select_db(healthy); $restult=mysql_db_query(healthy,$query); while ($row=mysql_fetch_array($result)) echo $row[serial]; ? and the result i got is: DATABASE: Healthy Warning: Supplied argument is not a valid MySQL result resource in d:\www\test\php\db.php on line 13 i can assure you that the member table is not empty. i have tried re-install php and apache, but they still don't work as they should. Previous Comments: --- [2001-05-21 06:02:59] [EMAIL PROTECTED] Please read the bug submission guidelines. http://www.php.net/bugs-dos-and-donts.php This report lacks any details, especially an example script or error message. It's probably an issue with your script. Reopen the report with an example script and error messages, or ask one of the support mailing lists for assistance. http://www.php.net/support.php --- [2001-05-21 05:16:49] [EMAIL PROTECTED] --- Full Bug description available at: http://bugs.php.net/?id=10983 -- PHP Development 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]