Re: [PHP] Any difference between these 2 forms of syntax?
Addressed to: Richard Davey [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from Richard Davey [EMAIL PROTECTED] Sat, 11 May 2002 01:54:43 +0100 Hi, I am wondering if there is any tangible difference between the following two commands: $x = $foo[status]; $x = $foo['status']; $foo['status']; should be marginaly faster as PHP doesn't have to look for $ in the value that need to be converted to their values. Rick Rick Widmer Internet Marketing Specialists http://www.developersdesk.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] apps that need register globals 'on' and others require
Addressed to: Philip Olson [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from Philip Olson [EMAIL PROTECTED] Tue, 30 Apr 2002 22:45:49 + (GMT) Btw, I can't think of a reason why a script designed with register_globals = off would not work with it on. Which is why assuming register_globals = off will make your scripts more portable. I can. Sessions. I believe that if register globals is on PHP looks at the global variables to write registered variables else it looks to $_SESSION. I did not track down the exact reason I can't use $_SESSION with register_globals = on, I just dropped back to using session_register(), but I did have a problem. Rick Rick Widmer Internet Marketing Specialists http://www.developersdesk.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Producing images in different sizes
Addressed to: Miguel Cruz [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from Miguel Cruz [EMAIL PROTECTED] Sat, 27 Apr 2002 19:11:46 -0500 (CDT) I'm guessing the issue is that it complicates the process of adding new images, because someone has to create and upload two corresponding files. This way, they get the benefit of rapid page generation combined with a simpler administration process. miguel Who said anything about UPLOADING two images? My understanding of the question was that he wanted to: store only one copy of each image - full size. and resize it down to the thumbnail size before sending it, IMnsHO, that's crazy, unless you have a very large number of images with very few repeat visits to their thumbnail pages. I agree, it is just as crazy to expect the user to do the thumbnail creation. ImageMagick does a great job of this, but it should be done when the file is uploaded, not every time an image needs to appear on a thumbnail page. It might not be that bad with 400X400 initial files, but resize time on my server for a mega-pixel JPEG from my digital camera is about 10-40 seconds which you might get a photo uploader to sit thru, but way too long for a visitor to your site. Rick On Sat, 27 Apr 2002 [EMAIL PROTECTED] wrote: I think he already has the best solution. Store two images. How many thumbnails are there on a page? At 1-2 seconds per image to resize how long will you make every visitor wait to see the thumbnails? Disk space is cheap. If you have to buy another drive - no big deal. I don't know about you, but for me if a web page doesn't load in about 10-15 seconds I'm outa here! Rick ** Reply to note from Miguel Cruz [EMAIL PROTECTED] Sat, 27 Apr 2002 11:36:54 -0500 (CDT) On Sat, 27 Apr 2002, Ray Paseur 703.346.0600 wrote: I am storing several detailed images at about 400x400 pixels (inventory for an art gallery). I show a page with thumbnails of the images. When a site visitor clicks on a thumbnail, I open a separate window to display the detailed image. Presently I am storing two copies of each image - full size and thumb. My objective is to store only one copy of each image - full size. (The rationale behind this is a complicated story involving old gallery owners, digital cameras, rudimentary image editing skills, etc.) I want the server to read the full size image, but resize it down to the thumbnail size before sending it, thus saving transmission time. Are there any server-side applications that can handle this? You could use ImageMagick (particularly, the 'convert' program) to do this but decent results are not fast (not that it'll take several seconds or anything, but it does take a certain amount of time, and everything adds up). If you want to do this on the fly, I'd suggest having it save the thumbnails when they're generated so that the next time someone comes, it doesn't have to go through the process again. miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Rick Widmer Internet Marketing Specialists http://www.developersdesk.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Rick Widmer Internet Marketing Specialists http://www.developersdesk.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Producing images in different sizes
I think he already has the best solution. Store two images. How many thumbnails are there on a page? At 1-2 seconds per image to resize how long will you make every visitor wait to see the thumbnails? Disk space is cheap. If you have to buy another drive - no big deal. I don't know about you, but for me if a web page doesn't load in about 10-15 seconds I'm outa here! Rick ** Reply to note from Miguel Cruz [EMAIL PROTECTED] Sat, 27 Apr 2002 11:36:54 -0500 (CDT) On Sat, 27 Apr 2002, Ray Paseur 703.346.0600 wrote: I am storing several detailed images at about 400x400 pixels (inventory for an art gallery). I show a page with thumbnails of the images. When a site visitor clicks on a thumbnail, I open a separate window to display the detailed image. Presently I am storing two copies of each image - full size and thumb. My objective is to store only one copy of each image - full size. (The rationale behind this is a complicated story involving old gallery owners, digital cameras, rudimentary image editing skills, etc.) I want the server to read the full size image, but resize it down to the thumbnail size before sending it, thus saving transmission time. Are there any server-side applications that can handle this? You could use ImageMagick (particularly, the 'convert' program) to do this but decent results are not fast (not that it'll take several seconds or anything, but it does take a certain amount of time, and everything adds up). If you want to do this on the fly, I'd suggest having it save the thumbnails when they're generated so that the next time someone comes, it doesn't have to go through the process again. miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Rick Widmer Internet Marketing Specialists http://www.developersdesk.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Combine SQL query OT
Addressed to: Richard Baskett [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from Richard Baskett [EMAIL PROTECTED] Fri, 26 Apr 2002 01:47:17 -0700 Is there a way I can combine these queries? $result = queryDB(SELECT count(ResumeID) FROM Resumes WHERE typeEmploy='1'); $numEmp = mysql_result($result,0); $result = queryDB(SELECT count(ResumeID) FROM Resumes WHERE typeContract='1'); $numCon = mysql_result($result,0); $result = queryDB(SELECT count(ResumeID) FROM Resumes WHERE typeTemp='1'); $numTem = mysql_result($result,0); Try: SELECT SUM( IF( typeEmploy = 1, 1, 0 )) AS Employ, SUM( IF( typeContract = 1, 1, 0 )) AS Contract, SUM( IF( typeTemp = 1, 1, 0 )) AS Temp FROM Resumes If type* is always either 1 or 0 you can lose the if: SUM( typeEmploy ) AS Employ ... Rick Rick Widmer Internet Marketing Specialists http://www.developersdesk.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] draw image graph with uptime command
Addressed to: Daniel Masur [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from Daniel Masur [EMAIL PROTECTED] Fri, 4 Jan 2002 08:54:00 +0100 anybody can help? ps, i never worked with images in php before... Take a look at: http://www.aditus.nu/jpgraph/ Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Re: User-friendly URI's
Addressed to: Mike Eheler [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from Mike Eheler [EMAIL PROTECTED] Thu, 03 Jan 2002 16:26:53 -0800 That's the whole point of this thread.. that's what I want to avoid. I want to have a URI that is easier to remember, and less ugly, and also provides a sense of security (even if it is only a faint sense) through obscurity. The .htaccess/httpd.conf solution is: Location /news ForceType application/X-httpd-php /Location Now the file news in your DocumentRoot directory will be executed as a php program, and anything that appears as directory and file names after it will appear in $PATH_INFO. (I think that's where it appears anyway. Check phpinfo() to be sure.) It works very well. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] php unpack function
Addressed to: [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from Chris Mattmann [EMAIL PROTECTED] Wed, 23 May 2001 13:28:36 -0700 For instance, my file is basically just thousands of temperature values, taken 4 times a day, over a period of 20 years. Let's say I wanted to get a year's worth of temperatures, from the 10th year into the file (so I would need the 4x365x10) th temperature value from the file. I don't quite understand what you are doing, but this might be close. If not, give me more information on the source data, how you want to select which days to inspect, and what you want to do with the output. This code reads from a file that contains thousands of temp records back to back, with no separators and displays all the temps, one day per line for each day within a range of day numbers. Display is to a web page and not very well formatted. # Set these to fit your situation $TempSize = x; # Length of temperature value in bytes. $TempFormat = '???'; # Unpack format string for a single day. $FileName = 'tempfile.data'; $StartDate = 365 * 10; # Start of tenth year $EndDate = 365 * 11; # Start of eleventh year. # End date is not displayed $BlockSize = 20; # Set for good performance/memory use # Here goes... $F = fopen( $FileName, 'rb' ); $DayLength = 4 * $TempSize; for( $I = $StartDate; $I $EndDate; $I += $BlockSize ) { $SeekPos = $I * $TempSize; if( ( $I + $BlockSize ) $EndDate ) $BlockSize = $EndDate - $I; fseek( $F, $SeekPos, SEEK_SET ); $Data = fread( $F, $BlockSize * $TempSize ); for( $J = 0; $J $BlockSize; $J ++ ) { $DayPos = $J * 4 * $TempSize; $DayData = substr( $Data, $DayPos, $DayPos + DayLength ); $DayTemps = unpack( $TempFormat, $DayData ); echo Day: , $I + $J, - , $DayTemps[ 1 ], , $DayTemps[ 2 ], , $DayTemps[ 3 ], , $DayTemps[ 4 ], BR\n; } } This is not tested, but should be pretty close. You may have to add or subtract one from some of the control conditions in the ifs or the places where I setup values. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] php unpack function
Addressed to: Chris Mattmann [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from Chris Mattmann [EMAIL PROTECTED] Wed, 23 May 2001 18:05:27 -0700 (PDT) Thanks for your help Rick. The problem I was having was basically as you understood, except for the fact that I don't really have access to file at the time that I need to unpack the data from it. The file is stored in terms of Oracle bFile pointers, so basically I have some code that does like: //do query to get bfile pointer ... $bindata = $bfileptr-load(); Now I have a string representation of the binary file. At this time is where I having the difficulties. I need a way without the use of fseek(since I don't have a file, I only have a string representation of it) to select a particular subset of the data. Any advice you have would be greatly appreciated, and thanks for replying to my original post. You should be able to use substr() to get any part of the returned $bindata you want. Just use the byte position equations from my last post to determine where in the data you want to return. I think your dba may be crazy to store that much data that way. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Validation Email in PHP programs
Addressed to: "Steve Werby" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Steve Werby" [EMAIL PROTECTED] Tue, 3 Apr 2001 15:24:29 -0400 I should have said there's no *reliable* way to check whether an email address on an external server is valid. There is one _reliable_ way to verify the email address is valid. Generate a random password then send it to the email address they give you. Then pop up a page that tells them to check their email for the password. I include the user name and a link to the site in the email I generate. No email address - no password - no access. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] function knows where call came from?
Addressed to: "Reuben D Budiardja" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Reuben D Budiardja" [EMAIL PROTECTED] Wed, 28 Mar 2001 12:44:55 -0500 Yes, that would be really cool. I my self has tried to find a way to do this, and throw this question to the list sometimes ago... no repond. What would be great, if we can do this, is that we can somehow create a pseudo-private method for classes (since php OO does not have that), and limit only a certain file/page can call that pseudo-private method, by checking which page call that method. Please let me know if you find any further information on this. Thanks in advance Having a function able to identify where it was called from has been discussed on the developers list several times. The result is that it would slow down every function too much, even when the feature was not used. You will not be seeing this feature in PHP, I am afraid. Execution speed is very important to the developers. (And I agree!) Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] email an ms-word attachment (please)
Addressed to: Jen Hall [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from Jen Hall [EMAIL PROTECTED] Tue, 20 Mar 2001 19:59:26 -0500 Hi there I am trying to build an application where a user can use an HTML form, fill out some fields, select a file from their hard drive, and have it emailed as an attachment with the contents of the form. (essentially, fill in your name and address, use my module to attach ms-word file of your resume, send email of all). I am able to make it work with an image as the attachment, but when I select an MS-WORD document, which is the goal of this application, it still thinks it's an image, and doesn't work properly. Emailing a .doc file is a VERY BAD idea. VB for applications which is embedded in word is very powerful. What happens when some hacker decides to use your page to send a vba script like the naked wife virus thru your program? Oh, here is a resume... lets take a look. Open the attachemnt. A burst of network activity while the vb script sends a copy of itself to everyone in the victim's address book. Then the hard drive light comes on as the program deletes a bunch of important files from the \windows\system directory. Finally the computer crashes because windows can't run without the missing files. Even though the machine won't boot, the computer forensics people recover the email, and trace it back to you. The victim's lawyers come knocking on your door asking for damages because you let some hacker release a virus thru your program that wiped out several computers at the victim's company, some of their customers, as well as several of his friends. You are forced out of business because the damages are more than the value of your entire company. Not good. Don't believe me? How about one of them: http://www.gcn.com/state/vol5_no11/enterprise/491-1.html http://members.door.net/kls/virusinfo.htm http://venus.soci.niu.edu/~cudigest/CUDS11/cud1120.html http://www.jwolsen.com/wtip035.htm Want more? - search for 'macro virus' on your favorite search engine. NEVER send .doc, .exe, .com, .bat or .vbs files as attachments, and never - ever open them if one is sent to you. Not even from someone you trust. Melissa, Anna and Naked Wife all depend on the fact that the virus often comes from a trusted individual as part of their tactics, and it works! Are you sure your anti-virus software is up to date? Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] String indexing with braces
Addressed to: Toby Butzon [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from Toby Butzon [EMAIL PROTECTED] Wed, 07 Mar 2001 18:07:29 -0500 Greetings, I know there's been some discussion of adding support for string indexing (that would be exclusive to strings [because it wouldn't apply to arrays] and therefore more efficient) using curly braces ($someStr{0}, $someStr{1}, etc.). Has this been implemented, and, if so, in what version did this first appear? Yes. I am using 4.0.2 and it is supported. I am not sure how long it has been available. Currently $SomeStr[0] and $SomeStr{0} are the same thing, but someday the [] notation will go away. Maybe php 5. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] mysql_connect() with timeout
Addressed to: [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from [EMAIL PROTECTED] Tue, 6 Mar 2001 01:29:52 -0500 Frankly, I don't know how people would otherwise handle connections to MySQL since the attempts could, potentially, block forever. I guess because the entire system is so reliable for most people. I've been doing dynamic sites for over a year now, and I've never had a problem. The only downtime MySQL has is when I shut it down for a few minutes once a week to back up the database files. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Newbie: Can't find function error.
Addressed to: Darren Ward [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from Darren Ward [EMAIL PROTECTED] Tue, 6 Mar 2001 18:17:11 +1100 Hi Guys, Newbie to the list and the world of PHP. I'm having a LOT of trouble getting PHP to work. The PHP and Apache installs have gone well as evidenced by: # ./httpd -l Compiled-in modules: http_core.c mod_env.c mod_log_config.c mod_mime.c mod_negotiation.c mod_status.c mod_info.c mod_include.c mod_autoindex.c mod_dir.c mod_cgi.c mod_asis.c mod_imap.c mod_actions.c mod_userdir.c mod_alias.c mod_access.c mod_auth.c mod_so.c mod_setenvif.c mod_ssl.c mod_php4.c mod_perl.c And httpd.conf has the handlers for php3 and php but whenever I browse to a test php3 file it says: Fatal error: Call to undefined function: php_info() in test.php3 on line 1 The file looks like: ?php php_info() ? Try: ?php phpinfo() ? Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] removing characters
Addressed to: Rick St Jean [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from Rick St Jean [EMAIL PROTECTED] Tue, 06 Mar 2001 01:47:05 -0500 A good way to do what you are asking is a combination of the last two suggestions... if( count( $Area )) {# Don't do anything if there are no entries reset( $Area ); # Handle the first one, with no 'or' list( , $Value ) = each( $Area ); $String = "(Area='$Value')"; # Handle the rest with a leading 'or' while( list( , $Value ) = each( $Area )) { $String .= " or (Area='$Value')"; } } I have just started with php a few days ago but in the book that I am reading it uses a foreach loop that is specifically for arrays. foreach($Area as $key=$value) { your concatination string here } Rick At 04:45 PM 3/6/01 +1030, you wrote: On Tue, 6 Mar 2001 15:50, [EMAIL PROTECTED] wrote: A problem of inexperience... I am trying to store an array in mysql. I obtain the array like so-- $partcount = count($Area); reset($Area); for ($i = 0; $i $partcount; $i++){ $key = key($Area); $val = $Area[$key]; $string1 .= $val . "\') or (Area=\'"; next($Area); } This results, with a bit of coaxing, in an array like this one -- +-+ | Area| +-+ | (Area='1') or (Area='2') or (Area='3') or (Area='') | +-+ Everything is falling into place, *except* these last thirteen characters -- or (Area='') And that's what I'd like to eradicate. Tips, suggestions, especially outright code greatly appreciate. Thanks, Robert p.s.-- I have ordered the Friedl book on Regular Expressions. Hoping it will enlighten me for the future My suggestion would be to not create the empty reference in the firast place :-) Before starting your loop (but after checking there is something to work with) use the first element of the arra to create the (Area='1') then you can loop through the rest of the array, starting with $i = 1 and create or (Area='$val') Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] get current events from mysql query by date?
Addressed to: [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from [EMAIL PROTECTED] Mon, 5 Mar 2001 14:10:28 -0600 This is just a guess but wanted to take a shot at it. Something like SELECT EventID, EventName, EventDescription, EventStartDate, EventEndDate WHERE EventStartDate CURRENT_DATE ORDER BY EventStartDate ASC LIMIT 5; How did I do? Close, very close. I belive CURRENT_DATE is a MySQL function. MySQL functions are identified by not having a space between the function name and the required ( that makes it a function. If CURRENT_DATE is actually a function (I use NOW() because it is shorter) then you need to change the WHERE clause to: WHERE EventStartDate CURRENT_DATE() If CURRENT_DATE() is not a valid function change it to: WHERE EventStartDate NOW() Both assume that EventStartDate is a MySQL DATE, DATETIME or TIMESTAMP value. If they are something else, this will not work. It should be one of these types though!!! Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] HREFs that can't be
Addressed to: "Boget, Chris" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Boget, Chris" [EMAIL PROTECTED] Mon, 5 Mar 2001 08:25:25 -0600 This is pretty much acceptable to search engines. Even better add: Location /program ForceType application/x-httpd-php /Location to httpd.conf. Then the following url will work: http://www.somedomain.com/program/value1/value2/command.php program _is_ the program. $PATH_INFO containls: '/value1/value2/command.php' I've tried setting this up, but for the life of me, I could not get it to work. I've never had a problem with it. I place it inside the VirtualHost block for the host I want to affect. I've got some domains with over half a dozen different programs that use this trick. It needs to match the AddType value you use to enable .php, .php3, .phtml, etc to run php. It may only work for Apache modules. Of course, you also have to reload the web server config files after you add it. apachectrl graceful, or apachectl restart at least. I've just settled with including the ".php" after the program name and that works just as well... http://www.somedomain.com/program.php/value1/value2/command.php --^^ That works, but doesn't look as cool. Why do you want to eliminate all get params and cookies? That might have a lot of control as to what the best approach will be. GET because they can be modified and So can these URL based param passing schemes. Even POST params are not all that secure from a determined hacker. All it takes is a little work with a program to fake POST values. The only advantage they have is taking a little more work. Yes, I know. But that little extra work is enough. Plus, we are going to try a few things (including encrypting; not one way) the hidden variables. That and trying to make sure that the form submission request originated from our server. To make sure hidden fields stay unchanged, contat all the values together into a long string, pass the string to md5, and store the result as a checksum. When you get data back from the browser concat it again, not including the md5 string, and compare it with the checksum from the hidden values. If they are different someone has changed the data. You should to add something somewhat random, that only the server knows, into the md5 input, so even an ex-employee who knows the algorithm can not fake a checksum. The md5 checksum with a local secret is a good way to make sure that the original md5 checksum was computed by one of your machines. A hacker would need to know that to create a valid checksum for modified data. I'm still trying to find the answer as to when HTTP_REFERER is available and when it isn't... still haven't heard anything back on that one... It depends on the browser. Some never send it. The ones that do usually only send it when a link is clicked on a page. URLS entered by clicking on a link in an email, selected from bookmarks or typed in by hand never have a referer. Cookies because not all users will have them turned on. Good reason. If you don't care about serach engines, you can just use PHP4 sessions, and append the session ID, or compile with --enable-trans-sid and let php use cookies when available or place the session ID in the URN if they are not. As I've mentioned in another post, this is *not* working. We have that directive turned on/compiled in and it still does not append the session ID to URLs if the user's browser does not accept cookies. I submitted a few code samples last week that I set up to demonstrated this. Everything looks ok in the php.ini and everything that needed to be was turned on when PHP4 (we are using 4.0.3pl1) was compiled, but still the session ID is not being appended to the URL. I wish I knew what was wrong. If you are creating the links dynamicly how about adding this near the end of the process: if( empty( $HTTP_COOKIE_VARS[ 'phpsessid' ] )) echo '?phpsessid=', session_id(); Crude, but it should be effective. There was a php bug that messed up enable-trans-sid when I first started using sessions, so I wrote a function to create a link: function anchor( $Title, $Href, $Params='', Anchor='', Target='' ) { } It kind of outputs something like: A href="$Href?$Params#$Anchor" target="$Target"$Title/A except that it only includes the target= part if $Target is not empty, and only includes $Params if it is not empty. If( session_id() 0 AND empty( $HTTP_COOKIE_VARS[ 'phpsessid' ] ) it adds 'phpsessid=' . session_id() to $Params, with ? in front of it if $Parms was empty or if it had a value. I still use it in most of my php pages. Most of my links look like: ? anchor( 'Home', "http://$SERVER_NAME/" ) ? That might be the quickest thing to do. Chris Rick Widmer Internet Marketi
Re: [PHP] config question
Addressed to: [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from [EMAIL PROTECTED] Mon, 5 Mar 2001 20:00:47 EST My server admin is being stupid... magic_quotes_gpc have been turned off unexpectadly so phpMyAdmin aint working, as well as half my scripts. He says nothing has been changed so it must be my fault, is there a command in php to displays the PHP config options so i can show this mofo that they are off ? phpinfo() ? Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] help gurus: multi-dimensional array problem.
Addressed to: andrew [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from andrew [EMAIL PROTECTED] Sat, 03 Mar 2001 14:26:30 -0500 help! :) I'm trying to return a list of links under associated categories from a database table that has the fields: "linkID, category, name, url". I'm selecting the fields and then trying to construct a multi-dimensional array so that the correct items get put into it (and then printed out): Why build an array, and store ANOTHER copy of all the data in memory while the script runs? That is just a waste of memory... SELECT Category, Name, URL FROM Links ORDER BY Category, Name; To display them: $OldCategory = ''; while( list( $Category, $Name, $URL ) = mysql_fetch_row( $Result )) { if( $OldCategory != $Category ) { print "Category Header $CategoryBR\n"; $OldCategory = $Category; } print "A href=\"$URL\"$Name/aBR\n"; } Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Connection error
Addressed to: [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from [EMAIL PROTECTED] Fri, 2 Mar 2001 15:59:55 -0500 Hi, When I run the code: ?php mysql_connect ("LOCALHOST","webmaster2","hironsc0"); ? I got error message: Fatal error: Call to unsupported or undefined function mysql_connect() in English translation: You have not compiled MySQL support into PHP. You will need to re-compile, or find a different RPM. If you compile it yourself, be sure to add with-mysql to the ./configure command. If this is on a Windows host, look in php.ini and uncomment the line that loads the MySQL DLL. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] linking to specific spot on map?
Addressed to: Floyd Baker [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from Floyd Baker [EMAIL PROTECTED] Thu, 01 Mar 2001 16:39:23 -0500 Hi.. We have a city map using co-ordinates to link to specific info on various buildings, etc. The links bring up an information page with data and photos for each building locations on the map. My question is, when this information page is accessed from another direction, say a menu, can there be a link that operates in 'reverse', back to the map and the building in question? We still want people to see the map, relating to a specific building, whether they start there or end up there. I thought the map could perhaps position itself so that the point of interest is always in the center, or that it blinks, or has a arrow pointing to it. It doesn't matter what the final display looks like, just that is shows a particular location clearly. If you have a small number of locations 100 or so, and you only want to show one at a time, I'd seriously consider just making 100 maps with markers on them, and sending the right one when needed. This will be much faster to serve as there is no graphic processing involved. If you want to be able to have multiple random selections where more than one location is shown on a map, you are stuck generating them on the fiy. I would start with a stock map and use GD to draw a marker over the top of it for each location you want to hilite. In each of your database records you would record the x and y coordinates of the point on the map where the building is located. If you want to build maps with various center points and scales, and be able to plot buildings on it, you will want to store the lat and lon of the building, and store everything else using lat/lon. If you are going to do this, look for someone very good with geometry to design the math. It can get tricky trying to show a section of a sphere on a flat screen. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] PHP image browser
Addressed to: "Timothy Wright" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Timothy Wright" [EMAIL PROTECTED] Thu, 1 Mar 2001 14:40:16 -0500 Can PHP GD-lib create an index with thumbnail images of all graphics in a directory? Has anyone done this? Specifically, I would like to create small (maybe 1/8 or 1/16 size) thumbnails on-the-fly and place them in an index.php page with links to the larger images. It can be done, but it is not fast enough to do in real time. The way I create thumbnails is ImageMagick. I keep my thumbnails in a hidden directory (.s) and create them like this: mkdir( "imagedir/.s" 0700 ); system( 'cp imagedir/*.jpg imagedir/.s' ); system( '/usr/local/bin/mogrify -geometry 150X150 imagedir/.s/*' ); The last command will take an image of any size and aspect ratio, maintain the aspect ratio and resize it so the largest dimension is 150 pixels. There are MANY other commands available. Your thunbmails have the same names as the full size files, but are stored in imagedir/.s/. Image Magick: http://www.imagemagick.org/ Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Munging hidden/form variables
Addressed to: "Boget, Chris" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Boget, Chris" [EMAIL PROTECTED] Thu, 1 Mar 2001 14:26:16 -0600 --_=_NextPart_001_01C0A28D.E2F45248 Content-Type: text/plain; charset="iso-8859-1" It is possible (I've done it) to find out all the variables that make up a form on a particular site, generate a similar form on your site with that form's action being the CGI/PHP script that the particular site uses to process the form once submitted, modify the values for the form variables to be anything you want and submit the form that resides on your site. This will basically submit totally fabricated data to the foriegn site and possibly screw them up somehow and/or in some way. Is there any way to defend against this? Is there any way to ensure that when a form is submitted that the submission request originated from your site/domain and not somewhere else? No. There is no way to tell a clever programmer from a live human on the other end of an Internet connection. You may be able to make it harder, say making sure your form page is hit before the results are returned, but that is easy to defeat. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Munging hidden/form variables
Addressed to: Kelly Corkill [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from Kelly Corkill [EMAIL PROTECTED] Thu, 1 Mar 2001 16:27:21 -0700 (MST) I would think you should be able to write a random string to a file when the form page is accessed, and carry a variable with the action then have the recipient compare. Presents other challenges but should give you that comforting feeling he was looking for. ALl that means is that I have to load your form, identify your magic number, and send it when I return the form data. That makes it a little harder, but only a little. The magic number will be in a hidden field, but hidden fields are not all that 'hidden' when you View Source. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Munging hidden/form variables
Addressed to: "Chris" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Chris" [EMAIL PROTECTED] Thu, 1 Mar 2001 15:43:25 -0800 Would it not be possible to have both the form page and the script page that handles the form be generated o the fly with random filenames? The form page would point to the random generated script page, and the script page could delete itself after it is proccessed. You would also want a cron to delete any files in case they never bothered to submit the form. Can anyone see a problem with this? That makes it a little harder, but I can just view source and hit the page a couple of times, and I will see that the Action="" in the FORM tag changes and know I have to go back one step to get it. If I have to I can emulate a person coming in from the home page, walking all the links to the form, then entering it. I hit the page that generates the random name. It returns the random name. I use it in my following request to get the form. I fill in the form and send it. Maybe you can make it 'not worth the effort' for a hacker, but be careful you don't make it 'not worth the errort' for your legitimate visitors. The big problem you have, is if I can fill it in by hand, I can watch what passes over the network and write a program to emulate it. What a browser can do is very limited, and even things like headers that are not normaly visible when you view source are visible to a network sniffer. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Munging hidden/form variables
Addressed to: "Simon Garner" [EMAIL PROTECTED] "Chris" [EMAIL PROTECTED] "php" [EMAIL PROTECTED] ** Reply to note from "Simon Garner" [EMAIL PROTECTED] Fri, 2 Mar 2001 13:05:00 +1300 So how do you verify that the logged in user is allowed to act on behalf of the other ID? You just have to keep reverifying that the client is allowed to do what they're doing. I suggest it is time to take a look at sessions: http://www.php.net/manual/en/html/ref.session.html Things get easier if you only allow a small group of people into the site. You won't be able to keep someone who knows a valid username and password from exploiting things, but you can limit the possible exploits to what you allow a user to do. I suggest you use a SSL secured server any time you are sending passwords across the net. That way they can only be intercepted by someone with access to the authorized user's machine, or someone with access to your machine. SSL is not magic, all it does is prevent someone along the way from snooping. When someone enters a valid username and password, create a session and store all the temporary data on the server. If it is never sent to the browser, there is no way for someone on the other end to modify it. A PHP session ID is a reasonably secure random number that is hard to guess. It is even harder to guess the session ID, user name and password all at the same time. That still does not stop me, a valid user who can use the system from a browser, from being able to write a script that fakes my user action. It does allow you much more control to make sure that neither me or my robot are able to do anything you don't want me to do. It's a chore I know - security usually is :( Yep! Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Exception Handling in php
Addressed to: kevin1 [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from kevin1 [EMAIL PROTECTED] Tue, 27 Feb 2001 08:10:05 -0500 Is there any equivalent to Java's try-catch or Perl's eval{BLOCK}if($@) structure in PHP? No. There has been some discussion about adding it on the developers list, but I don't expect to see it any time soon. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] DNS Lookups Fail
Addressed to: "Scott Rothgaber" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Scott Rothgaber" [EMAIL PROTECTED] Mon, 26 Feb 2001 09:45:42 -0500 PHP 4.0.4 pl1, Apache 1.3.17, BSD/OS 4.1 pl37 Good Morning! Please forgive me if this has been covered ad nauseum, but I have searched high and low for an answer with no luck. After building PHP as a module, following the online instructions, Apache complained that it could not resolve hostnames. I got around this by using IP's in httpd.conf and making wusage do the lookups. Is there a fix for this or is it an unpleasant side effect that we must accept and deal with? The official word on the Apache config files is that you _should_ use IP addresses rather than host names. That said, I don't do it. I find the host names more understandable when I am working on the file. The problem is you MUST make sure DNS or /etc/hosts name resolution is available BEFORE you start the web server. The first thing to try is get a list of the host names that fail and do a nslookup to make sure you can resolve them. You may have bigger problems with DNS. If the problem happens only when you boot the computer, make sure you start networking ans named long before you try to start the web server. A way to side step the entire DNS issue is to list each of your web IP addresses in /etc/hosts, and make sure that /etc/resolv.conf looks in that file before it goes out to DNS. Even if you do this you need to find out why the host names can not be resolved. If the master DNS server is setup wrong, no one will be able to see the site. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] header() and require()
Addressed to: "Jason Jacobs" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Jason Jacobs" [EMAIL PROTECTED] Mon, 26 Feb 2001 11:28:37 -0500 Hi. In some of my files, I have a require statement to get some global stuff accessable. I also have some header() redirects. They don't work (they worked before I added the requires). I moved the require under one of the header()s and that one works now, but I can't move it under the other one because stuff has to happen before the redirect and it needs the required stuff. So my question is do require statements produce output that I can't see (which would make the redirects not work)? The files I'm requiring don't have any output, which is why I'm confused. Thanks. The most common cause of this problem is a blank line, or evan a space in the wrong place in one of the required files. The following examples will cause the problem: -- ? some code here ? -- -- ? some code here ? -- -- ? some code here ? -- -- ? some code here ? NOTE: even a single space after the will cause a problem. -- -- ? some code ? ? some more code ? -- What they all have in common, is ANYTHING outside of ? and ? in the file. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] DNS Lookups Fail
Addressed to: "Scott Rothgaber" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Scott Rothgaber" [EMAIL PROTECTED] Mon, 26 Feb 2001 12:46:08 -0500 On 26 Feb 2001, at 10:21, [EMAIL PROTECTED] wrote: The first thing to try is get a list of the host names that fail and do a nslookup to make sure you can resolve them. The way I see it, this is strictly a PHP issue. *No* lookups are succeeding, not even in the log file. If I switch back to my Apache binary built without PHP, everything works. Take a look thru your Apache config files for HostNameLookups, that is probably what it is. You can set it to ON to get this behavior back. You might want to think about it a little before you do. Having this on means that EVERY SINGLE page and image hit requires a DNS lookup BEFORE the page/image is sent. If there is a problem with reverse DNS on the modem your visitor is connected to (not uncommon) they get to wait up to 30 seconds for a DNS timeout before the page will load. Not good. Consider how often you really care about what the host name is. Is it worth the extra delay for the DNS lookup on EVERY page sent. You mentioned having to have your log analyzer do the DNS lookups when it processes the logs. I say better pay for it then when it is only you waiting for results than making your visitors pay on every page and image they download. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Enumerate files in a folder
Addressed to: "Karl J. Stubsjoen" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Karl J. Stubsjoen" [EMAIL PROTECTED] Mon, 26 Feb 2001 15:28:27 -0700 Hello, I need a little help getting started with my project (i'm new to PHP). I need to enumerate all of the files in a folder, their name mostly. How would I do that? Take a look here: http://www.php.net/manual/en/html/ref.dir.html opendir, readdir, and closedir will get you moving in the right direction. Opendir includes a complete example. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Mail() Problems in a heterogenous network
Addressed to: "Parker, John (Snorkel)" [EMAIL PROTECTED] "'[EMAIL PROTECTED]'" [EMAIL PROTECTED] ** Reply to note from "Parker, John (Snorkel)" [EMAIL PROTECTED] Mon, 26 Feb 2001 16:02:32 -0600 The behaviour is this: When I send mail from the webserver (running as [EMAIL PROTECTED]) to an inside address (same domain, i.e. [EMAIL PROTECTED]) I get everything just fine. I can even use the from feature in the mail class to make the mail appear to come from a real (or not so real, I've tried [EMAIL PROTECTED] and it takes it just fine) address. However, when I send mail to an outside address, i.e. [EMAIL PROTECTED], it gets dropped somewhere. What gets dropped? The entire message - See the message from Kelly Corkill Just the From info - read on. Unfortunately those running the mailserver are unable/unwilling to help me track this down, Probably unable. Windows is Easy, that means you don't have to know anything to admin it. At least till something unusual happens. Received: from sneasv02.omniquip.textron.com (insidesnorkel.omniquip.textron.com [10.220.15.149]) by oqamapw1ab.omniquip.textron.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21) id 14MPSVVH; Sat, 24 Feb 2001 11:18:24 -0600 Received: (from nobody@localhost) by sneasv02.omniquip.textron.com (980427.SGI.8.8.8/970903.SGI.AUTOCF) id LAA42386; Sat, 24 Feb 2001 11:13:51 -0600 (CST) Take a look at the headers on an internal message. I bet you find some additional headers like: From: and Reply To: that are being stripped by the mail server. Can you load sendmail or qmail on your UNIX box and bypass them. You don't have to handle incoming email, and you don't want the machine listening on port 25, but you may be able to have your own machine handle mail connections and bypass them entirely. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] php quit working
Addressed to: "Jerry Lake" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Jerry Lake" [EMAIL PROTECTED] Mon, 26 Feb 2001 12:58:35 -0800 I just installed php as an apache DSO module on the first try of a phpinfo(); it worked just as it should, then I loaded phpmyadmin and now when I make a request for a php file it tries to download, my httpd.conf file seems to be in order...any ideas? What file extension did you use on your phpinfo() attempt? What file extension does phpMyAdmin use? Are they different You may need to add php3 to the AddType application/x-httpd-php declaration somewhere in your Apache configuration. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] php4 as a module AND a cgi
Addressed to: [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from [EMAIL PROTECTED] Mon, 26 Feb 2001 15:58:19 -0500 hi all, thanks for the replies. many of you asked why I want to use php4 as a cgi. basically it boils down to this, using PHP as CGI you can run PHP scripts via cron tab, which eliminates the need for shell scripting (yeah baby). In that case, compile php without using with-apache or with-apxs to create a php binary. Place it in /usr/local/bin or someplace in your path. There is a way to run php from cron something like: /usr/local/bin/php -q script-name.php The way I do it is a little different. In cron I specify: /path/to/php/script.php In the top of script.php, I add a special first line: #!/usr/local/bin/php -q ? phpinfo(); ? The important thing to remember here, it has NOTHING to do with Apache or CGI, you are using standard shell operations to allow php to execute scripts the same way most perl scripts, and a lot of other scripts are run. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Cookie References?
Addressed to: [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from [EMAIL PROTECTED] Sat, 24 Feb 2001 16:42:09 -0600 Could you give me some URLs for tutorials related to cookies and good reference material? Not directly, but there are a number of tutorial links at: http://www.php.net/links.php One question I have is can a cookie never expire? No, but a cookie that expires in ten years is almost as good. I bet no one will have the same cookie file long enough for that to expire. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Array Help
Addressed to: [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from [EMAIL PROTECTED] Fri, 23 Feb 2001 12:20:12 -0500 I've tried and tried and tried ;-) I have this array; $bikes = array( "Road" = array( "Trek" = array( "Trek 5200" = "road.php?brand=t5200" ), "Schwinn" = array( "Schwinn Fastback Pro" = "road.php?brand=schfp" ), "Moots" = array( "VaMoots" = "road.php?brand=vamoots" ), "Lemond" = array( "Zurich" = "road.php?brand=zurich", "Chambery" = "road.php?brand=chambery", "BuenosAries" = "road.php?brand=bueno", "Tourmalet" = "road.php?brand=tourmalet" ) ), "Dirt" = array( ) ); I would probably do something like: # reset( $Bikes ) while( list( $BikeType, $Manufacturers ) = each( $bikes )) { echo "$BikeTypeBR\n"; # reset( $Manufacturers ); while( list( $Mfr, $Models ) = each( $Manufacturers )) { echo "nbsp;nbsp;$MfrBR\n"; # reset( $Models ); while( list( $Model, $URL ) = each( $Models )) { echo "nbsp;nbsp;nbsp;nbsp;" . "A href=\"$URL\"$Model/ABR\n"; } } } This would give Road Trek Trek -- is a link Schwinn Schwinn Fastback Pro -- is a link Moots VaMoots -- is a link Lemond Zurich -- is a link Chambery -- is a link BuenosAries -- is a link Tourmalet -- is a link Dirt If you realy want Trek Schwinn Moots Lemond Trek -- is a link Schwinn Fastback Pro -- is a link VaMoots -- is a link Zurich -- is a link Chambery -- is a link BuenosAries -- is a link Tourmalet -- is a link You need to do the outer look twice, doing a reset() in it between them, and doing the reset()s I have commented out in the example. Be aware if you go thru the array more than once in the program it will be needed. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] file test
Addressed to: "Kevin Beckford" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Kevin Beckford" [EMAIL PROTECTED] Fri, 23 Feb 2001 15:42:26 -0500 I am opening the top level of a a directory structure with dir. I want make a list of the subdirectories, but not the files. Is there a file test operator like perl's -d in php? I will then have to go into the sub directories to perform actions on non directory files I bet there is... http://www.php.net/manual/en/ref.filesystem.php Would be a good place to find out. Hint: look for is_file() or is_dir(). Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Help INSERTing to MySQL
Addressed to: Clayton Dukes [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from Philip Olson [EMAIL PROTECTED] Sat, 24 Feb 2001 01:31:30 + (GMT) Hello, This is my first attempt, so I'm prolly doing something stupid, but can someone tell me why this doesn't work? All it returns is "Unable to INSERT to database" Change : or die("Unable to INSERT to database"); To : or die(mysql_error()); And see what it tells you. Odds are there's a field not being accounted for. When not designating columns (just values) it's important to make sure all columns are accounted for. See : http://www.sqlcourse.com/ It'll provide some basic SQL help. It's recommended to write out columns and values (easier to make sense of). I find SET even easier: INSERT INTO Table SET or UPDATE Table SET then field1 = '$Field1', field2 = '$Field2', fieldN = '$FieldN' That makes it very easy to keep track of what goes where. It is somewhat new to MySQL, but anything less than a year old should have it available. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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 problems
Addressed to: Jack Davis [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from Jack Davis [EMAIL PROTECTED] Wed, 21 Feb 2001 14:58:13 -0600 We have designed a web based email program that we have recently found a problem with...If you open up two email accounts in two different browser windows, the first window opened takes on the session that the second window is in. It appears that you can open up as many sessions as you like, but all open windows take on the session properties of the most recently opened session...This happens in Windows and Linux with either IE or Netscape...Has anyone else had this problem and if so how can I work around it... I bet you are using cookies to keep track of them. If so, all open windows in a browser share the same set of cookies. The fix is to move the information that identifies which account they are working in to the URL. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] How do I request a new feature?
Addressed to: "Ide, Jim" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Ide, Jim" [EMAIL PROTECTED] Thu, 22 Feb 2001 13:48:34 -0500 Hi - How can/should I contact the developers of PHP to request that they add a new feature to PHP? Submit a bug report at: http://bugs.php.net/ Make sure the Type of Bug is set to Feature/Change Request Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] PDF Problems
Addressed to: Mike Tuller [EMAIL PROTECTED] php mailing list [EMAIL PROTECTED] ** Reply to note from Mike Tuller [EMAIL PROTECTED] Thu, 22 Feb 2001 09:05:34 -0600 Do you have any idea when 4.0.5 will be out? If nothing goes wrong, they hope to do it around the first of the month. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Deleting mySql records based on dates
Addressed to: "Kevin Cawthorne" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Kevin Cawthorne" [EMAIL PROTECTED] Wed, 21 Feb 2001 13:19:54 - The reason I used that route was to show the logic. Yes its long- some people may not want a mysql reliant way of doing it. Oh come on! If you are going to use a database why not USE IT fully? If you are going to treat it like a flat file, why bother installing it in the first place? Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Variable Strangeness
Addressed to: Jason Murray [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from Jason Murray [EMAIL PROTECTED] Wed, 21 Feb 2001 11:37:40 -0600 Hi, I came across this: $confidential = 0; echo "$confidential " . ($confidential == "yes"); In which "0 1" was printed. $confidential = 0; # Numeric 0 That explains the 0. $confidential == "yes" This is a little tricky. The numeric value of 'yes' is 0, so it evaluates to the same thing as 0 == 0, which is true. True has a numeric value of 1, although all values besides 0 are considered true. You might want to look at the === operator which checks that both the value and the type of the operands is identical. http://www.php.net/manual/en/html/language.operators.comparison.html Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] ftp_login problem
Addressed to: [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from [EMAIL PROTECTED] Mon, 19 Feb 2001 15:22:49 -0600 I wanted to check with all of you before I report a bug. Here is the problem: I am attempting to access a OS2 server via ftp. When I login on the command line as anonymous to this server it does not require a password. When I try to login via PHP (ftp_login) it requires that I use a password. When I try to just put in just any password ftp_login comes back with a login failed message. here is the error: Warning: ftp_login: User anonymous logged in. in /home/httpd/html/php/ftpget.php on line 15 You can see the message that the server is returning is saying that my login was ok but ftp_login does not return success. If anyone has insight into this please let me know, I suggest you put a password on that box, before someone else finds it! Besides being more secure, it will allow you to use PHP's ftp as it is usually used. Also, since we are talking anonymous login to ftp, you might try using an email address for a password. That seems to be a common convention. You are MUCH better off password protecting the OS/2 box: Double click on: TCP/IP Internet (LAN) - you may have to look for it in OS/2 System. In that folder, double click on TCP/IP Configuration (LAN). I know these say LAN, but things like FTP passwords will affect dial up networking too. Click on the Security Tab. Click on the Add button. Fill out the form with an explicit username/password combination, and optionally a specific drive and directory you wish to serve via ftp. The directory you specify here will be the 'home' directory for the specified user, and the only area your machine will serve files from. If you have more than one user who wants access, you can create as many authorized users as you wish by repeating the instructions starting at the Add button. P.S. It is nice to see I am not the only OS/2 user left... :) Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] How to determine the parameter is a 1 dimension array or not?
Addressed to: "Zenith" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Zenith" [EMAIL PROTECTED] Tue, 20 Feb 2001 02:45:12 +0800 In a self defined function, a one dimension or two dimension array may be passed, How can I check that, the passed in array is a one dimension array or a two dimension array? If an element of $array[x] returns 'ARRAY' it is multi dimensional. You may have to check my capitolization. Try looking at $array, a known array and see what it returns in an echo. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] the best so far
Addressed to: "Richard Lynch" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Richard Lynch" [EMAIL PROTECTED] Fri, 16 Feb 2001 17:21:03 -0600 Do you get the line number and filename of the script that *called* the query function, or is it always the query function itself. This is the sticking point for the original poster. I get the line and file of the include file. Also, note that the $'s should not be in there, I just removed them from the latest version of the include file too, as it doesn't help much. The idea of being able to get the line and file name info of where a function was called from has come up on the developers list a couple of times, and I'd love to see it happen, but it was shot down, and I'm pretty sure it won't happen. The only way to do it would be like: function Query( $Query, $Line, $File ) { .. } and call it like: Query( $SomeQuery, __LINE__, __FILE__ ); Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Apache on Linux vs. IIS on W2K
Addressed to: [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from [EMAIL PROTECTED] Sat, 17 Feb 2001 14:22:54 - So the question is, why is this acting like this? (When I meet "pro" they say Apache, Linux e.g.. is the best, and curse the IIS and W2K, but at this time I would say it's a myth..) The round() problem is because of differences in your versions of PHP, but the fact of the matter is that the UNIX version of PHP is ahead of the WIndows version because it is easier to program on UNIX, and there are more people interested in programming for UNIX than Windows. Most main stream functions will work on both platforms but there are things like the DBM database that works on UNIX, but fails because of differences in the Windows platform. (See http://bugs.php.net/?id=8819) Then there is a new image library that breaks the 256 color barrier, that is only available on UNIX. Work is in progress (maybe done) on a PHP extension to call it, but unless someone ports the base library to Windows it will not be available on that platform. I know there are other things, these are just some that I've seen recently. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] MySQL COUNT Won't Work
Addressed to: Javier Muniz [EMAIL PROTECTED] Joe Sheble (Wizaerd) [mailto:[EMAIL PROTECTED]] [EMAIL PROTECTED] ** Reply to note from Javier Muniz [EMAIL PROTECTED] Fri, 16 Feb 2001 10:14:29 -0800 You should use fieldnames in your selects... I'd imagine count(*) would be slower just as select * is slower. I agree, SELECT should always specify only the fields you want returned, but COUNT(*) is an optimization. From the MySQL manual: http://www.mysql.com/doc/G/r/Group_by_functions.html COUNT(*) is somewhat different in that it returns a count of the number of rows retrieved, whether or not they contain NULL values. COUNT(*) is optimized to return very quickly if the SELECT retrieves from one table, no other columns are retrieved, and there is no WHERE clause. For example SELECT COUNT(*) FROM TableName will not even look at the table, it can get the number of entries from the index, and return it almost instantly. If you used SELECT COUNT(SomeField) FROM TableName MySQL would have to scan the table to make sure none of the SomeField values were NULL, which would not be included in the count. This can take quite a bit more time. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] PHP globals aren't really globals
Addressed to: Maxim Maletsky [EMAIL PROTECTED] [EMAIL PROTECTED] Christian Dechery [mailto:[EMAIL PROTECTED]] ** Reply to note from Maxim Maletsky [EMAIL PROTECTED] Fri, 16 Feb 2001 12:18:27 +0900 I never used 50 of them, but I think there's such a thing as 'register globals' wchich makes all if the globals become available inside your funcs.. no idea how to use it ... I feel like I've seen it in = someone else's code ... correct me if I am wrong ... Consider your self corrected... :) register_globals is about placing GET/PUT/COOKIE/ENVIRONMENT variables into the global scope. It has nothing to do with functions. Rasmus explained why you need to declare variables as global in EVERY function that uses them here: http://marc.theaimsgroup.com/?l=php-generalm=97984136422910w=2 and here: http://marc.theaimsgroup.com/?l=php-generalm=97717866712033w=2 You may as well get used to it, it isn't going to change any time soon... Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] SMTP
Addressed to: "Richard Lynch" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Richard Lynch" [EMAIL PROTECTED] Thu, 15 Feb 2001 19:25:14 -0600 I think you *can* use the "for win32 only" stuff on Linux if you want to send your mail to a different server... I don't think so... I just tried to add: php_value SMTP 'mail.mydomain.com' php_value sendmail_from '[EMAIL PROTECTED]' php_value sendmail_path ' ' into my Apache configuration, and PHP is still sending mail thru the local sendmail rather than qmail on my main server. I wish it would work as it would take care of a problem I am having. It looks like I may have to dig out the Sendmail book, and do some work on it to take control of bounce messages when PHP's mail() function tries to send to an invalid address. Also, if I use: php_value sendmail_path '' Apache will not run. I get an error that php_value must have two parameters. I am not complaining, it is just something I noticed while testing. FYI, I would like to see this work on UNIX, so I have submitted a feature request to have it added: http://bugs.php.net/?id=9308 Anybody else think this would be good to have? Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Specific PHP/JSP questions
Addressed to: Gerald Gutierrez [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from Gerald Gutierrez [EMAIL PROTECTED] Thu, 15 Feb 2001 01:04:30 -0800 2) In JSPs, it is possible to do server-side page redirection, i.e. "forward" a request from page A to page B, as if the user actually requested page B. There is no browser involvement in the redirection; it is complete on the server. In this scenario, there are two "page scopes", and one "request scope". How is this server-side redirection done in PHP? You might do something like: pageA.php - ? if( user_realy_wants_page_b ) { include( 'pageb.php' ); exit; } ? Page A starts here... - That all happens on the server, and does not require anything outside of page A to implement. 3) In doing the server-side page redirection, variables can be added to a "request" object, which embodies parameters related to a request. Page A can add variables to the request object (perhaps values from an SQL select), which page B can then retrieve and display. How is this done in PHP? In the example above, any variables set in page A will be visible in page B when it is included. The values must be set BEFORE the include() is hit. 5) On a JSP site, I typically arrange things such that a particular JSP (or servlet) accepts requests, processes them and then forwards them to one of a number of different pages, depending on the outcome of the processing. This is in contrast to the alternative approach where one simply goes to a page, which does some processing and then displays the contents of the requested page. What is the typical way to achieving this "funnel all requests to a single point and have it forward the correct response to the user" paradigm? ? switch ( $Desired_Action ) { case 'PageA' : include( 'pagea.php' ); break; case 'PageB' : include( 'pageb.php' ); break; case 'PageC' : include( 'pagec.php' ); break; default: include( 'defailt.php' ); break; } would be one possibility. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] the best so far
Addressed to: "Richard Lynch" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Richard Lynch" [EMAIL PROTECTED] Thu, 15 Feb 2001 19:54:55 -0600 Does die() give you a line number? If not, just put it in there. No, die() does not add to your message. Here is how I solved the problem: function Query( $Query ) { global $ShowQueries; $Result = mysql_query( $Query ); if( !$Result ) echo( mysql_error() . " in Query at $__LINE__ in $__FILE__BR\n$QueryBR\n" ); elseif( $ShowQueries ) echo( "$QueryBR\n" ); return( $Result ); } usage: $Result = Query( "SELECT fielda, fieldb. fieldc, fieldd, fielde " . " fieldf, fieldg, fieldh " . "FROM Table1 " . "LEFT JOIN Table2 USING( common_field ) " . "WHERE condition1 = '$Value1' " . " AND condition2 '$Value2' " . "ORDER BY SortField " ); Every query I've written goes thru this function. A couple of things about this: The queries jump out at you when you are looking at the source code. When you have an error in a query you get the mysql_error() message and the entire query printed just below it. I've found that quite handy for debugging. Almost every one of my programs has #$ShowQueries='on'; very near the top of the file. If I am not sure just what it is doing to the database, I just un-comment this line and each query string is printed as it is executed. I've used it enough that I just add the line in every program, or use a template that includes it. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] foo[bar] _or_ foo['bar'] ?
Addressed to: Derek Sivers [EMAIL PROTECTED] "Matthias Krehl" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from Derek Sivers [EMAIL PROTECTED] Tue, 13 Feb 2001 09:31:29 -0800 I'd really appreciate a clear statement whether to use better $foo = array('bar' = 'boing'); doWhatSoEver($foo[bar]); or $foo = array('bar' = 'boing'); doWhatSoEver($foo['bar']); I had heard someone on the list say that it's always best to use quotes, for the same reason as XHTML, where every value MUST have quotes. But honestly I've been using only NO-quotes all year and find it much easier to read. And NEVER any problem! Also makes it easier when you need to use an array variable inside a quoted string: print "Hello there $client[name]"; Several people have mentioned that this is a bad practice, but no one has mentioned why... There are two gotchas you have to look out for, that quotes will prevent. First, if you are using some_word as an array index and someone decides that it would be a good name for a built in function, constant, or statement all of a sudden all of your programs will break. Second, take one of your programs that uses some_word all over it, and add: define( 'some_word', 'something_else' ); into one of your include files, now life gets very interesting: $X[ 'some_word' ] = 'foo'; $X[ 'something_else' ] = 'bar'; echo $X[ some_word ]; // prints bar echo $X[ 'some_word' ]; // always works as expected. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Time problem
Addressed to: "Steve Werby" [EMAIL PROTECTED] "Roman" [EMAIL PROTECTED] "Php-General" [EMAIL PROTECTED] ** Reply to note from "Steve Werby" [EMAIL PROTECTED] Wed, 7 Feb 2001 09:28:29 -0500 Or you could do it the easy way in MySQL: SELECT SEC_TO_TIME( TIME_TO_SEC( OUT ) - TIME_TO_SEC( IN )) AS Hours, .. .. .. This requires IN and OUT to be type TIME. "Roman" [EMAIL PROTECTED] wrote: I have one problem with mysql database. In table i have 2 arrays with time format. For example this arrays calls IN and OUT. In php script i want to have distinction between this arrays. For example IN is 8:30:45 and OUT is 16:45:15 and result will be: 8:14:30. Exists any function which do this. Tnanx. If your MySQL fields are a datetime type (-MM-DD hh:mm:ss) then you can convert them to seconds since epoch (Jan 1, 1970 at midnight) and then calculate the difference and divide by a number to get appropriate units. Below is a set of functions I wrote to do that. Before I get to that here's a simpler solution: // $time = "16:45:15"; $time_array = explode( ":", $time); // $time[0] = 16, $time[1] = 45, $time[2] = 15 $time_since_midnight = $time[0] * 3600 + $time[1] * 60 + $time[2]; // Do this conversion for both times, subtract and convert units. function get_mysql_to_epoch( $date ) { list( $year, $month, $day, $hour, $minute, $second ) = split( "([^0-9])", $date ); return date( "U", mktime( $hour, $minute, $second, $month, $day, $year ) ); } function get_elapsed_time( $time_start, $time_end, $units = "seconds", $decimals = "2" ) { $divider[years] = ( 60 * 60 * 24 * 365 ); $divider[months] = ( 60 * 60 * 24 * 365 / 12 ); $divider[weeks] = ( 60 * 60 * 24 / 7 ); $divider[days]= ( 60 * 60 * 24 ); $divider[hours] = ( 60 * 60 ); $divider[minutes] = ( 60 ); $divider[seconds] = 1; $elapsed_time = ( ( get_mysql_to_epoch( $time_end ) - get_mysql_to_epoch( $time_start ) ) / $divider[$units] ); $elapsed_time = sprintf( "%0.{$decimals}f", $elapsed_time ); return $elapsed_time; } ?php // Usage example $time_in = "2000-06-14 06:30:00"; $time_out = "2000-12-22 13:45:00"; // Full use of function. echo "brDays: "; echo get_elapsed_time( $time_in, $time_out, "days", "3" ); // Use defaults for units and decimal places. echo "brSeconds: "; echo get_elapsed_time( $time_in, $time_out ); ? -- Steve Werby COO 24-7 Computer Services, LLC Tel: 804.817.2470 http://www.247computing.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] Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] neat html output
Addressed to: "Mark" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Mark" [EMAIL PROTECTED] Wed, 31 Jan 2001 08:29:57 -0600 I'd like my html output to be neatly written, including newlines is helpful but does anyone know of a better way to output newlines than appending .."\n"; to every echo statement. As far as I know that is THE way to output newlines. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Want to learn PHP
Addressed to: "Patrick L." [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Patrick L." [EMAIL PROTECTED] Wed, 31 Jan 2001 00:55:47 -0800 I've been struggling with perl, till someone said why not give PHP a shot. Where do I start? Aside from manuals, are there any online courses/tutorials which will get me going? Lots. Take a look on: http://www.php.net/links.php and http://www.zend.com/ PhpWizards and DevShed helped get me going... Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Best way to describe Doc as HTML
Addressed to: "Karl J. Stubsjoen" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Karl J. Stubsjoen" [EMAIL PROTECTED] Thu, 25 Jan 2001 08:36:43 -0700 Hello, So I think I've found 3 ways to describe the HTML Doc as "HTML". Which one is the best? 1) Via MetTag (this was generated in Dreamweaver): head meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /head 2) Print Statement at top of page: print "Content-type: text/html\n\n"; 3) Using the PHP Header command: header( "Content-type: test/html" ); What do you think? 4) Do nothing. text/html is the default content type for php. A Content-type: text/html header is sent for you unless you specify something else. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] how to rename a database
Addressed to: "Chris Doyle" [EMAIL PROTECTED] "Fang Li" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Chris Doyle" [EMAIL PROTECTED] Thu, 25 Jan 2001 09:38:55 +1000 To be completely safe: cd /var/mysql# or where ever your databases are stored. mysqladmin -p shutdown # shut down database to make sure all # tables are flushed, and closed mv OldDbName NewDbName # rename the directory safe_mysqld # restart mysqld mysql -p # Reassign the permissions REVOKE all users of the old table name GRANT all users of the new table name Prehaps you can rename the database file in mysql/bin ie. database_name.sql to new_database_name.sql and that will work? - Original Message - From: "Fang Li" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, January 25, 2001 7:20 AM Subject: [PHP] how to rename a database Does anyone know how to rename a database in MySQL? Thanks! Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Deleting all cookies so matter where they were set
Addressed to: "Noah Spitzer-Williams" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Noah Spitzer-Williams" [EMAIL PROTECTED] Tue, 23 Jan 2001 10:09:22 -0500 Is there a way to remove all cookies so matter what path they were set as long as it was from me (ex. in my parent directory). i need this because i was screwing around with setting cookies in different paths but now i cant get rid of one. If you are using Netscape, go into Edit - Preferences - Advanced, and disable cookies. Save that change. Then go back in and re-enable them. There is a side effect, _all_ cookies will be deleted. or Exit Netscape. Find your cookies.txt file, and edit it with your favorite text editor. Be careful if you change the length of stuff, but I've had good luck removing individual cookies by delete line. I am sure there are equivalent operations for IE, but I can't tell you how to do them. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Array help needed
Addressed to: CDitty [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from CDitty [EMAIL PROTECTED] Thu, 18 Jan 2001 06:58:22 -0600 I see someone else has another suggestion that might be better, using array_count(). You learn something new every day, which is why I watch this list... anyway, the thing I see in your code: while(list($index, $value) = each($dice)){ // Changed from $Input to ^ $Output[$Value]++; } ^ $Value != $value I know my use of caps or not in this example sucks. I usually always use Caps On Each Word for my var names, but I am trying to switch to what appears to be the php standard, lower case everywhere. Sorry about that... Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] a text formating cpu question
Addressed to: Noel Akins [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from Noel Akins [EMAIL PROTECTED] Thu, 18 Jan 2001 22:05:46 + Hello, Question 1: A long time ago, I started my first big project using php3 and MySQL that would return on a query a listing of info from the database that was displayed in the browser with nested tables. If a user really wanted to test the limits of the database, he/she could get back over 3000 lines. Being that html tables were being used to display the info, a large number of tables were being created, and would crash netscape. I pretty much shelved this project for this reason. I'm now working on a similar project that won't return so many lines, but I would like to be able to use something other than html tables to display the info in a neat manner. Is there any php related things I could use to format a list in a browser other than html tags? could someone point me in the right direction? PRE Or break up your table so there are many small tables rather than one big one. Breaking up the table is probably best. Pre text looks pretty uggly. Question 2: Is there a way for php to detect the cpu speed of a users computer? I don't think so. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Not quite relevant question about coding and query
Addressed to: "Jacky@lilst" [EMAIL PROTECTED] "Jason Murray" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Jacky@lilst" [EMAIL PROTECTED] Fri, 19 Jan 2001 13:15:13 -0600 What happens when more than one person updates the tables at nearly the same time? a - insert record 9 b - insert record 10 a - get max ID = 10 b - get max ID = 10 Something doesn't look right here What you are looking for is mysql-insert-id() Get the id generated from the previous INSERT operation http://www.php.net/manual/en/html/function.mysql-insert-id.html thanks for Jason:-) Lucky the ID is sequential. That was command I was looking for. cheers Jack [EMAIL PROTECTED] "There is nothing more rewarding than reaching the goal you set for yourself" - Original Message - From: Jason Murray [EMAIL PROTECTED] To: 'Jacky@lilst' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, January 18, 2001 11:56 PM Subject: RE: [PHP] Not quite relevant question about coding and query $query = "insert into user values ('firstname','lastname','address','phone')"; $resultinsert = mysql_query($query); $getID = "select userID from user"; // Will this get me the // Id of the record I just inserted? $resultID = mysql_query($getID); No, it won't - it'll return every userID in the table. If your userIDs are sequential, you can just select "MAX(userID)" instead of userID. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Not quite relevant question about coding and query
Addressed to: "Jacky@lilst" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Jacky@lilst" [EMAIL PROTECTED] Fri, 19 Jan 2001 14:00:02 -0600 Sorry, I think it should be like this: $queryInsert = "insert into user values ('firstname','lastname','email')"; $resultinsert = mysql_query($queryInsert); $UserIdLatest = mysql_insert_id(userId); Is that correct? Yes, that is the 'proper' way to find out the value of a auto_incremant field. The SELECT MAX( userid ) method will work fine in testing, but then you get to pull your hair out when it starts to fail under heavy load. You might have a bit of a problem with the values() clause of the insert. That statement expects you to list all the entries in the table, in the order they appear, unless you specify a list right after the table name. I've given up on that syntax in favor of this one: $QueryInsert = "INSERT INTO user SET " . " firstname = '$FirstName', " . " lastname = '$LastName', " . " email = '$Email' ); It also works with update: $QueryUpdate = "UPDATE user SET " . " firstname = '$FirstName', " . " lastname = '$LastName', " . " email = '$Email' . "WHERE userId = 1234 " ); I like the fact that you can list any fields in any order while leaving out anything you want. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Gear Head -- From Home Pages to Popularity
Addressed to: [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] In his current column for Network World, Gear Hear (AKA Mark Gibbs) talks about PHP and Zend Technologies. Since you hang out on this mailing list, you may not learn much, but go ahead and take a look. It is great to know that PHP is getting this kind of press in a major weekly magazine for network managers. http://www.nwfusion.com/columnists/2001/00288015.html PHP4 has become wildly popular and is now a major language in Web scripting. According to the October 2000 NetCraft Web survey, PHP was running in more than 3.8 million domains on 715,283 IP addresses. He promises more on PHP next week! Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] Gear Head -- From Home Pages to Popularity
Addressed to: [EMAIL PROTECTED] [EMAIL PROTECTED] The current column for Gear Head, (AKA Mark Gibbs) in Network World magazine is all about PHP and Zend Technonogies. Since you hang around on this mailing list, you may not learn much but rejoice in the thought that his column is pointed at corporate network managers, and is quite positive about PHP and Zend. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] logging page views, which method is better????
Addressed to: "Dallas Kropka" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Dallas Kropka" [EMAIL PROTECTED] Sun, 14 Jan 2001 00:57:10 -0600 I have a large site, with several hundred pages its a product listing and shopping cart and I want to log my page views I receive an average of 3000 hits per minute. Is it better (faster) to log my views to a database table? or to a flat file? No need to re-invent the wheel, all accesses are already being logged. If you are using Apache, take a look at the access log. Every hit to the server is already logged there. I am not sure what the default location for the file is, but you can find it with locate access_log or by looking for the string Log in your httpd.conf file. I believe it may appear under either the AccessLog or CustomLog keywords. You might want to look at Webalizer, or a couple of other programs to analyze the contents. http://www.mrunix.net/webalizer/ There are others, but this is the one I use. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] load balancing with php/apache?
Addressed to: Alex Black [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from Alex Black [EMAIL PROTECTED] Sun, 14 Jan 2001 17:16:50 -0800 Whoever said NFS is slow hasn't used a NetApp OK, I'll bite. What is NetApp? Network Appliance? Is this a cache technology, or will it help if I want to transfer 1GB of data with no duplication? Once upon a time I was considering using NFS for backing up my web servers. Then I found it would take over 150 hours per backup over my 56K Frame Relay link. I've got it down to about 46 hours with tar.gz and ftp. It takes most of my sleep time during the week. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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] RTFM me to IIF file format creation...
Addressed to: "Dallas Kropka" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "Dallas Kropka" [EMAIL PROTECTED] Sat, 13 Jan 2001 19:15:02 -0600 I need to create files and reports for importation into QuickBooks, but they need to be in the IIF file format that QuickBooks supports where can I find information for creating these files? The content of the iif files is defined in Quickbooks help. Look for IIF or Data import. It differs for each type of data you are transferring. You will have to look in help to get the definitions. There is also info on the subject and example files on the quickbooks web site. www.quickbooks.com, I think. Search on IIF, and maybe the type of file you want to create. From memory, not tested You can provide several different types of data in a single file. The file needs to start with a definition of the fields you are going to present. These definition lines start with !. Each of your data lines must have the exact same fields in the order you defined them in the ! lines. You don't have to provide all the possible values, but some record types do have required fields that must be provided, and filled in. Each record is a number of values with "\t" between them. The record ends with "\r\n". You must use double quotes so the tabs (\t) and Dos/Windows style line breaks {\r\n) are converted to the proper character values. /from memory Once you have reviewed Quickbooks help, and the web site, if you have specific quesions on your file format, ask again. It is actually pretty easy. The best way to verify your files during development is to open them with a spreadsheet program. Also, you MUST backup the quickbooks data before you try testing your upload. If it fails for any reason, just restore, fix the problem and upload again. Don't feel bad if you do this a couple dozen times before everything works. Rick Widmer Internet Marketing Specialists http://www.developersdesk.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]