RE: [PHP] Delete File Contents?
Just open the file in mode w. $fp = fopen(your_file, w); There is also the the function fseek(), which will allow you to move the file pointer around to any place in the file. Mode w will suffice for your needs. fopen() - http://www.php.net/manual/en/function.fopen.php fseek() - http://www.php.net/manual/en/function.fseek.php Thanks Jeremy Allen -Original Message- From: Chris [mailto:[EMAIL PROTECTED]] Sent: Monday, December 17, 2001 3:57 PM To: [EMAIL PROTECTED] Subject: [PHP] Delete File Contents? I've created a program that runs a process then stores the results to a file on the server. I would like the file to contain only the most recent update, but it seems I can only append to my using fopen. Is there a way to open the file and overwrite the data in that file? I've considered deleting the file and creating a new one but that seems like a lot to do. It would be nice if there were a way to set a pointer to the top of the file and overwrite. Thanks, Chris -- 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] _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- 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]
RE: [PHP] Session storage and the --with-mm option
Sessions by default will use the file system to store session data. Using the file system on a site that utilizes sessions moderately can be negative as far as performance goes. Using shared memory simply means that session data is now stored in shared memory. Shared memory is a bit more efficient than using the file system. Where session data is stored is supposed to be sort of black box and transparent to the actual use of sessions. You can also define a group of custom session handling functions to use any device your mind can imagine for session storage. Anything PHP can easily connect to (Java, RDBMS, ...) the sky is the limit. Take a look at session_set_save_handler (for custom session handling routines). Once you get your session save handler working it is transparent to the use of sessions. If your having performance troubles with sessions using the file system, shared memory may be the best way to go. Take a look at this page http://www.php.net/manual/en/ref.session.php To actually use shared memory you must modify the option session.save_handler in the php.ini file. Thanks Jeremy Allen -Original Message- From: Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, December 14, 2001 10:38 AM To: [EMAIL PROTECTED] Subject: [PHP] Session storage and the --with-mm option I'm trying to cut down on the amount of memory that my apache proceeses use, I've noticed that when I have the --with-mm option set when I configure and compile PHP that the apache process goes up by about 40MB or more on the process table: USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 23102 0.0 2.5 54588 12972 ? SDec11 0:13 /usr/sbin/httpd nobody 11242 0.0 2.7 55040 14408 ? SDec13 0:16 /usr/sbin/httpd nobody 11244 0.0 2.7 55076 14216 ? SDec13 0:16 /usr/sbin/httpd I understand that not each process is using up that much ram, but I'd still like to cut down the usage since without having --with-mm enabled makes the processes more like this: USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 29415 0.0 0.7 13988 5844 ?SDec13 0:02 /usr/sbin/httpd nobody 31719 0.0 0.7 14140 6096 ?S04:02 0:00 /usr/sbin/httpd nobody 31720 0.0 0.7 14140 6096 ?S04:02 0:00 /usr/sbin/httpd So my question is this. What is the --with-mm option for? The only real documentation I can find about it anywhere is on the PHP site where they have a complete list of configuration options: -- --with-mm[=DIR] PHP 3: Option not available in PHP 3 PHP 4: Include mm support for session storage -- Well, that's not really helpful. Does this option affect how sessions work under PHP? I think some of the users on my system have been using sessions successfully without this option. Also, since this gets compiled in the ext/sessions directory, would I be able to compile it as a module that could be loaded into PHP at run time? Any help would be appretiated. Thanks, -- mark.krenz [EMAIL PROTECTED] ___ Their snazzy page and friendly installation process don't make up for damn trickery. -- 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] _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- 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]
[PHP] PHP 4.1.0 Comments
I would like to take a few bytes text to give a little thanks to the PHP team. I have been writing a book on PHP for the last 8 months. I thought I knew PHP inside and out, having done quite a bit of work with PHP. I have even had the pleasure of adding on a few libraries for a customized version of PHP in one project, it required a few libraries developed internally to have native PHP function calls. (It was either modify PHP source or make COM wrappers and use ASP. PHP saved the day) I have gained a true appreciation for the legible and easy to follow source of PHP. Whenever I have had a question I could look at the source, the source is never wrong :) Spending the last 8 months married to my book and PHP I have learned more than I thought there was for me to learn about programming in general and PHP specifically. The result is that I have come to like PHP more and more. I have developed largish applications in ColdFusion, ASP, JSP, and PHP. PHP still wins hands down for most of my needs. So, Thanks to anyone who has ever contributed a single line of code to PHP publicly. Your contributions have made such a wonderful web application development platform possible. Thanks Jeremy Allen [EMAIL PROTECTED] _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- 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]
RE: [PHP] PEAR DB Results
Based on the snippet you have sent us you need to at least start by enclosing your column names in your accesses to the associative array containing your results. Each line just use print_r or var_dump: while($row = $result-fetchRow(DB_FETCHMODE_ASSOC)) { print_r($row); } This will show you exactly what is going on. Verify that your results are actually there as well. As a final note the actual problem appears to be that you are not accessing the associative array elements with quotes: echo $row[wwwpages.name]; Instead of: echo $row[wwwpages.name]; This should show you what is going on and help you easier determine what is going wrong, it is possible you are not returning any data with your query as well. Thanks Jeremy Allen -Original Message- From: Ralph Guzman [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 31, 2001 5:07 AM To: PHP General Mailing List Subject: [PHP] PEAR DB Results I am trying to do a joined query using PEAR DB? My code looks something like this: $sql = SELECT wwwpages.pid,wwwpages.name,media.pid,media.name FROM wwwpages, media WHERE wwwpages.pid = '$pid'; if(DB::isError($result = $db-query($sql))){ echo ERROR: . DB::errorMessage($result); } else { while($row = $result-fetchRow(DB_FETCHMODE_ASSOC)){ echo $row[wwwpages.name]; echo $row[media.name] } } When I specify '$row[wwwpages.name]' I get a blank result, and if I try '$row[name]', I am obviously not specifying a table therefore it results in name for wwwpages table. How do I go about displaying both? _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- 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]