Re: [PHP] how do I spoof a get request
On Wed, Aug 13, 2003 at 08:17:14AM -0700, Chris Shiflett wrote: why do sites such as Google, Amazon, TicketMaster, Yahoo!, and eBay use them? The difficulty with cookies is when a site doesn't work without them. Fortunately, Google works fine when cookies are disabled. Amazon is a great example of how a complex transaction can be completed without the use of even one cookie. --Dan -- FREE scripts that make web and database programming easier http://www.analysisandsolutions.com/software/ T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7th Ave #4AJ, Brooklyn NYv: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OPINIONS wanted - xml-DOM-xsl + php
On Wed, Aug 13, 2003 at 11:44:18PM +0200, Thomas Hochstetter wrote: Are there plans to make the xml-DOM-xsl combination standard in future releases of php (version 5)? The .dlls are there. A person involved with the development recently said that in PHP 5 The DOM, SAX, XPath, Schema and any other extensions that can work with standard libxml2 will be enabled by default, and stable. Enjoy, --Dan -- FREE scripts that make web and database programming easier http://www.analysisandsolutions.com/software/ T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7th Ave #4AJ, Brooklyn NYv: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what's going on with the hanmir.com guy?
On Tue, Aug 12, 2003 at 03:58:19PM -0700, Chris W. Parker wrote: I'm surprised the email address hasn't been taken off the list yet. [EMAIL PROTECTED] you are my arch-nemesis!! [EMAIL PROTECTED] is the place to kvetch about users like this. I already did. A subject of username bouncing is clear. Might you do the same to make the point clear? --Dan -- FREE scripts that make web and database programming easier http://www.analysisandsolutions.com/software/ T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7th Ave #4AJ, Brooklyn NYv: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how do I spoof a get request
Hey Mike: On Tue, Aug 12, 2003 at 07:33:31PM -0700, Mike Migurski wrote: That's a good guess! Yet further proof that cookies suck, except the ones made with flour, shortening and sugar, of course. Huh? seems like further proof that cookies are working as intended: serving up individual, user-dependent content. Unless you are interested in having your personal info be the default return value from e-bay. :) I'm not going to debate this here. Just so I can quickly explain where I'm coming from regarding cookies, and other client dependent operations, are poor practice on the web -- where anybody can see your site with any browser with any set of preference combinations -- please read: http://www.analysisandsolutions.com/code/weberror.htm Enjoy, --Dan -- FREE scripts that make web and database programming easier http://www.analysisandsolutions.com/software/ T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7th Ave #4AJ, Brooklyn NYv: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] string concatenation from array
On Tue, Aug 12, 2003 at 01:58:21PM -0600, Micah Montoy wrote: I'm having a bit of difficulty getting a string to attach to itself from an array. Here is the bit of code I'm working on. A bunch of simplifications, efficiency tweaks on this approach... $wresult = ; $wresult = ''; foreach ($search_string as $word_result){ $wresult = $wresult $word_result; $wresult = $wresult . ' ' . $word_result; OR you can do... $wresult .= $word_result; } echo ($wresult); echo $wresult; BUT, the far far far better way to do this just takes one line: echo implode(' ', $search_string); --Dan -- FREE scripts that make web and database programming easier http://www.analysisandsolutions.com/software/ T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7th Ave #4AJ, Brooklyn NYv: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how do I spoof a get request
Hey Chris: On Wed, Aug 13, 2003 at 08:44:40AM -0700, Chris Shiflett wrote: --- Analysis Solutions [EMAIL PROTECTED] wrote: The difficulty with cookies is when a site doesn't work without them. Right, which is an example of developers that suck, not the technology. You're right. When I say cookies suck, I'm being flippant. I really mean the programmers suck. By that logic, you would think that PHP sucks, because there are plenty of sucky PHP applications. :-) I've had folks say things along these lines. Considering the number of PHP related vulnerabilities showing up in Bugtraq/Security Focus newsletter, PHP must REALLY suck. :) Enjoy, --Dan -- FREE scripts that make web and database programming easier http://www.analysisandsolutions.com/software/ T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7th Ave #4AJ, Brooklyn NYv: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie Session Question
On Thu, Aug 14, 2003 at 03:44:10PM -0400, CPT John W. Holmes wrote: From: Tim Winters [EMAIL PROTECTED] No, and it's $HTTP_SESSION_VARS. PHP is case sensitive, remember? And, do note, use $_SESSION instead. It will continue to work in default configurations of PHP 5, plus it's already global so saves having to issue global statements in each function using them. Enjoy, --Dan -- FREE scripts that make web and database programming easier http://www.analysisandsolutions.com/software/ T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7th Ave #4AJ, Brooklyn NYv: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reading remote, script-generated files
Hey Matt: On Tue, Aug 12, 2003 at 10:07:10AM -0700, Matt Daleo wrote: I'm attempting to read a remote file and parse it for data. The problem I've having is that the file seems to be generated by Perl (http://alert.dot.pima.gov/scripts/1brpssd.pl) and when I read it the script-generated portion is not available. When I view the page with a browser it is displayed just fine. Sounds like their CGI is snooping which browser you're using. If you're opening the file via http, then the server should send you everything a browser would see. But, do note, that web page is wacked out. I just took a look at it in Mozilla and while the HTML downloaded, it wouldn't render. So, they seem to not quite know what they're doing. Then, going up to http://alert.dot.pima.gov/ produced a JavaScript redirect, so they REALLY don't know what they're doing. --Dan -- FREE scripts that make web and database programming easier http://www.analysisandsolutions.com/software/ T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7th Ave #4AJ, Brooklyn NYv: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Display variable with spaces
On Wed, Aug 13, 2003 at 11:56:43AM -0400, Pushpinder Singh Garcha wrote: input name=email_1 type=text id=email_1 size=50 value = ? echo $email_1; /// However when it comes to displaying it using the table all I get is the thisisa . It simply avoids the spaces. Can anyone tell me why You need to write valid HTML. Put quotes around the value. You don't need quotes around the variable. Plus, close the element, of course. input name=email_1 type=text id=email_1 size=50 value=?php echo $email_1; ? / --Dan -- FREE scripts that make web and database programming easier http://www.analysisandsolutions.com/software/ T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7th Ave #4AJ, Brooklyn NYv: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php conditional loop question
On Wed, Aug 13, 2003 at 09:51:39PM -0400, Randy L Johnson Jr wrote: I have a function that makes a connection to a live datafeed website and downloads data via a pfsockopen() statement. After awhile the data stops feeding but the connection stays open. when the data stops I want to exit out of the function and have the function run again Pseudo code... while (1) { pfsockopen(... blah blah ...); while (not end of file) { get the line and do what you want with it... } } --Dan -- FREE scripts that make web and database programming easier http://www.analysisandsolutions.com/software/ T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7th Ave #4AJ, Brooklyn NYv: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adding days to a date
On Tue, Aug 12, 2003 at 03:37:25PM -0400, Donpro wrote: I am looking for a function that will add a variable number of days and return a valid date, i.e., the array elements for mday, mon and year are reset as needed. Is this possible? Look at mktime(). It allows you to seamlessly add/subtract things. The manual is at http://php.net/mktime --Dan -- FREE scripts that make web and database programming easier http://www.analysisandsolutions.com/software/ T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7th Ave #4AJ, Brooklyn NYv: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple HTTP request, with Range header
HEY KEN On Tue, Aug 12, 2003 at 09:30:21PM -0500, Ken wrote: I imagine I would want to form a basic get header request, with URL, whatever else I need, and a Range:bytes=1000-2000 header. If I understand correctly, the (HTTP/1.1) web server would return the document I want, just bytes 1000-2000. I hadn't heard of that option in HTTP 1.1, but that's because I haven't looked. Interesting. Anyway, if you are certain the information will always be at the same byte locations, then your approach will work. So, in this case you can do something similar to the post to host scripts I mentioned earlier this evening. $Host = 'www.foo.com'; $Script = 'test.bin'; $Return = ''; if ($sp = fsockopen($Host, '80')) { fputs($sp, POST $Script HTTP/1.1\n); fputs($sp, Host: $Host\n); /* * THESE NEXT TWO LINES ARE FROM A POST-TO-HOST SCRIPT. * MODIFY THEM TO FIT YOUR NEEDS, LIKE SWITCHING THEM * TO YOUR Range: bytes=1000-2000\n HEADER. */ fputs($sp, Content-type: application/x-www-form-urlencoded\n); fputs($sp, 'Content-length: ' . strlen($Post) . \n); fputs($sp, Connection: close\n\n); while ( !feof($sp) ) { $Return .= fgets($sp, 2000); } fclose($sp); } else { $Return = 'pNO DICE!/p'; } echo $Return; If that's the approach you use, post back here with the tweaked two lines that made it work. BUT, if the information/byte locations may change, then you'll want to grab the page with readfile() and then use regular expressions to find the stuff you want to keep. I realize it might be simpler to do a file read (assuming I'm doing this on the very same server as the document) You don't need to be on the same server. PHP's file reading functions are all internet aware. http:// and ftp:// are legit. Hope things are well for you out there in the Lone Star State, --Dan -- FREE scripts that make web and database programming easier http://www.analysisandsolutions.com/software/ T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7th Ave #4AJ, Brooklyn NYv: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how do I spoof a get request
Hey Dan: On Tue, Aug 12, 2003 at 08:13:32PM -0400, Dan Anderson wrote: I have noticed that sometimes I cannot fopen($web_address,'r') or use any similar files if the web address contains a form get in it. (i.e. ends in a ?var1=xxxvar2=xxx...). It should work. You said sometimes. What are the times it doesn't work? Are you always passing the same exact query string? If so, then their server is flaky. Or, if are you sending different info in the query string at different times, then you are likely not passing the info correctly. When constructing the query string, the values need to be URL encoded first. See http://php.net/urlencode for more info on this. Also, is there any easy way to spoof posting a form? Yes. http://www.php-faq.com/postToHost.html http://dodds.net/~cardinal/sendtohost.txt --Dan -- FREE scripts that make web and database programming easier http://www.analysisandsolutions.com/software/ T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7th Ave #4AJ, Brooklyn NYv: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Document root
Hey Mukta: On Tue, Aug 12, 2003 at 04:27:55PM +, Mukta Telang wrote: Is there any constant in php like $DOCUMENT_ROOT which holds path to the Document root of the server? 1) $_SERVER['DOCUMENT_ROOT'] 2) Check out phpinfo(). It will produce answers to this and MANY other questions for you in the future. 3) Fix the clock/timezone on your computer. Your messages are coming in out of chronological order. --Dan -- FREE scripts that make web and database programming easier http://www.analysisandsolutions.com/software/ T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7th Ave #4AJ, Brooklyn NYv: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parsing problem with character ''
Marc: On Wed, Aug 13, 2003 at 06:32:50PM -0700, FMM Schillemans wrote: the problem is that the moment the '' character is placed within the PHP code (lets say withing a print-command), then the PHP mode is immideatly ends. Making it impossible to create HTML code run-time Then your PHP coding style isn't correct. Show us a line of code where this happens. --Dan -- FREE scripts that make web and database programming easier http://www.analysisandsolutions.com/software/ T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7th Ave #4AJ, Brooklyn NYv: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how do I spoof a get request
Hey Dan: On Tue, Aug 12, 2003 at 09:12:45PM -0400, Dan Anderson wrote: But some web pages when I cut and paste the URLs don't work. Like when I search for something on Ebay. Could this be because of cookies? That's a good guess! Yet further proof that cookies suck, except the ones made with flour, shortening and sugar, of course. You can insert cookie information if you need to by using the same concepts as the post to host scripts I gave links to in my last post. Enjoy, --Dan -- FREE scripts that make web and database programming easier http://www.analysisandsolutions.com/software/ T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7th Ave #4AJ, Brooklyn NYv: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] libxml in PHP 5
Hey Folks: Adam replied to my message on another mailing list. I'm reposting it here for public edification and education, with a disclaimer from him that what he knows is from discussions on the php-dev mailing list, not first hand experience... From: Adam Maccabee Trachtenberg [EMAIL PROTECTED] To: NYPHP Talk [EMAIL PROTECTED] Date: Tue, 12 Aug 2003 14:46:15 -0400 (EDT) Subject: Re: [nyphp-talk] libxml in PHP 5 On Mon, 11 Aug 2003, Analysis Solutions wrote: I was thinking that the new XML parser would necessitate scripts use different function calls. Or will the main functions and behavior remain the same, but only the library be changed? The plan is to make the libxml switch seamless and not require any changes in your XML code. If the functions will indeed be different, is there some place to find docs about these new procedures? They don't have to be great, just give me an idea of how to start hacking something simple. PHP 5 will also have the SimpleXML extension. I believe the C code in the CVS is also the documentation. (Source code: The ultimate documentation.) -adam PS: Sterling is actually banging the drum on lots of this. He'll know more than I. -- [EMAIL PROTECTED] author of o'reilly's php cookbook avoid the holiday rush, buy your copy today! -- FREE scripts that make web and database programming easier http://www.analysisandsolutions.com/software/ T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7th Ave #4AJ, Brooklyn NYv: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST/GET - if there is a dot in the name it's changes to _
Arnau: On Tue, Aug 12, 2003 at 05:28:54PM +, Arnau Rebassa wrote: I'm having the same problem as the bug report http://bugs.php.net/bug.php?id=7987. They say that's not a bug it's a feature... Anybody knows where I can find which characters are changed and by which character? You're should use field names which conform to the varialbe naming conventions. If you do, you won't run into these conversion problems. Here's what the manual says are valid: Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores... Note: For our purposes here, a letter is a-z, A-Z, and the ASCII characters from 127 through 255 (0x7f-0xff). http://php.net/language.variables So, I guess to answer your question, it seems anything that's not in this list of valid characters will get turned into _ But, let me state again: use valid names in the first place. Enjoy, --Dan -- FREE scripts that make web and database programming easier http://www.analysisandsolutions.com/software/ T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7th Ave #4AJ, Brooklyn NYv: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] libxml in PHP 5
Hey Folks: I'm starting to use PHP 5 on my development machine. The primary XML parser is changing from expat to libxml. I was curious about the change, so sought documentation of the new libxml stuff on the PHP site but haven't been able to find any. Perhaps someone can steer me toward such documentation and/or answer a question. I was thinking that the new XML parser would necessitate scripts use different function calls. Or will the main functions and behavior remain the same, but only the library be changed? If the functions will indeed be different, is there some place to find docs about these new procedures? They don't have to be great, just give me an idea of how to start hacking something simple. Thanks, --Dan -- FREE scripts that make web and database programming easier http://www.analysisandsolutions.com/software/ T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7th Ave #4AJ, Brooklyn NYv: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable
On Wed, Aug 14, 2002 at 08:23:18AM +, Remon Redika wrote: input type=text name=namasa size=40 input type=text name=namadu size=40 input type=text name=namati size=40 $Namak = $namasa; $Namak = $Namak.$namadu; $Namak = $Namak.$namati; Is that REALLY what you want to do? There are no spaces between the names. Try: $Namak = $namsa $namadu $namati; But, that's probably not the problem. I suspect none of the three variables are being set because you have register_globals turned off. Use the $_POST or $_GET variables. Read the manual on these topics for more information. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Credit Card Transactions and Micropayment
Sascha: On Wed, Aug 14, 2002 at 04:06:39PM +0200, Sascha Braun wrote: Are there some ways of using a micropayment system together with PHP? What do you mean by micropayment? Paying for small fees? How small are you talking about? Maybe something where Customers can see the Amount of Money they have to pay, and then they do a phonecall to e specific number and then the page redirects teh customer to a downloads page where the user can receive his picturepackage. Sounds like an overly complex process. Why not do it all automatically with a well designed payment script? --Dan PS: Please turn on line wrapping in your email program. -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with mail()
On Wed, Aug 14, 2002 at 10:04:46AM -0700, Gui Guy wrote: ...: SYSERR(nobody): Can't create transcript file ./xfg7E9Jlr03988: Permission denied : SYSERR(nobody): Cannot create ./dfg7E9Jlr03988: Permission denied Does it mean that php is trying to send mail from user nobody? Good guess! Sounds like a file permissions thing. What directory are those files being created in? Provide nobody with adequate permissions on that directory. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] select distinct mysql
On Thu, Aug 15, 2002 at 01:12:59PM +0300, kale wrote: SELECT *, DISTINCT name FROM history ORDER date DESC, time DESC LIMIT 10 but this not work. how can I do this? I use a mysql server. That's because your query string syntax is all messed up. Put a mysql_error() call in your script after the mysql_query() call. It will tell you what the error is. http://www.php.net/manual/en/function.mysql-error.php. (Or, of course, you can execute the query directly from your MySQL client command line.) If you're unclear about what the error message is saying, read the MySQL manual on how to write SELECT statements. http://www.mysql.com/doc/en/SELECT.html --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Two version of php in the same system
On Wed, Aug 14, 2002 at 07:43:40PM -0300, Breno Cardoso Perucchi wrote: Action application/x-httpd-php403 /ver403/php ScriptAlias /ver403/ /usr/local/php/ver403/bin AddType application/x-httpd-php403 .php3 Not Found The requested URL /ver403/php/index.php3 was not found on this server. That's the Apache error message saying that it could not access the PHP binary in the location you said it was in. You said it was in /usr/local/php/ver403/bin Is it really there? Does that directory, AND all of the directories above it, have the needed execute permissions so the user Apache is running as can get to it? Do the various PHP files in the directory have the read or read/execute permissions necessary for Apache to run them? --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: xml and php
On Thu, Aug 15, 2002 at 11:28:51PM +0200, Pafo wrote: i cant get information from a deeper node... server servers name=ajs blaa blaa blaa pop100/pop relic name=george type=melee ownernisse/owner /relic /servers /server Carefully examine the code at http://www.analysisandsolutions.com/code/phpxml.htm It provides you the basic concepts needed to parse any XML document. BUT, you'll need to use your head in modifying the case statements -- and what they do when triggered -- in the StartHandler() and EndHandler() to meet your needs. I only have a few, cursory comments on your code. I haven't read the whole thing because it's long and poorly formatted. But, in short, it seems overly complex for the task at hand. For example, don't set all those variables individually. Store the information in one array. This will cut down on initialization statements up front and global statements in each function. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Removing session id from url when using session_set_save_handler
On Tue, Aug 13, 2002 at 10:47:13AM +0200, Per wrote: Does anybody know how to get rid of the session id in the url when using session_set_save_handler. Perhaps session.use_trans_sid is the ticket you're looking for... --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and Memory...
On Tue, Aug 13, 2002 at 01:57:54PM +0200, MyBox wrote: function testfunc($var1,$var2) { ...many calculation and variables return $result; } then on call number 12 the script exits whith error-message: Fatal error: Allowed memory size of 8388608 bytes exhausted Exhausting 8 megs of RAM! WOW! Those are some serious calculations! Must i giving free the memory at hand? Yes. When i in the function before its end give all vars free with unset(); then the error also comes on the same place. Hmm... Where are you performing the unset()'s? Before the return, right? Perhaps the memory is being gobbled up by the return $result? I did a search on the mailing list archive trying to learn more about this, but didn't come up with much. Hopefully, someone with more knowledge on PHP's internals will comment. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Writing to a file that's not PHP_SELF
On Tue, Aug 13, 2002 at 04:02:51PM -0230, Kondwani Spike Mkandawire wrote: $file = fopen(Counter.txt, r+); $counter = fread($file, filesize(Counter.txt)); fwrite($file, $counter, strlen($counter)); ... snip ... // For some reason the updated value is not written // to Counter.txt Because you already wrote $counter back to the file there in line 3. Nowhere in those three lines did you increment the counter before doing the write. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [Followup] Exploding Zip Codes! (Using PHP's explode function)
On Tue, Aug 13, 2002 at 12:13:35PM -0700, Keith Posehn wrote: I have the code together now to put it all the zip codes into and array--but now I need to add those zip codes to a sql statement for the WHERE clause. SELECT * FROM [table] WHERE zip=[all the darn zips listed here] $query = ... WHERE zip IN (' . implode(',', $ZipArray) . '); --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] upgrading
On Tue, Aug 13, 2002 at 02:58:02PM -0400, Alex Shi wrote: I am currently have PHP 4.0.4p11 and Apache 1.3.19 running on RH Linux 7.1. Now I am thinking of upgrade my PHP to 4.1.2-7 If you're upgrading, don't waste your time installing very old versions with significant vulnerabilities in them. Upgrade Apache to 1.3.26 and PHP to 4.2.2. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $HTTP_SESSION_VARS vs $_SESSION - cont.
On Tue, Aug 13, 2002 at 10:07:57AM -0700, Rasmus Lerdorf wrote: while ( list($Key, $Val) = each($_SESSION) ) { $$Key = $Val; } extract($_SESSION) is a better way to do that. Yeah. Old habits die hard! :) --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $HTTP_SESSION_VARS vs $_SESSION - cont.
Petre: On Tue, Aug 13, 2002 at 03:18:42PM +0200, Petre Agenbag wrote: I have register_golbals = on, BUT, I want to find a way to code that I know will always work, regardless of register_globals or cookies, so that I am only dependant on the trans-sid ( but If I could rule that out too, it would be even better) This example assumes the machine is running PHP = 4.1.0 allowing use of $_SESSION rather than $HTTP_SESSION_VARS. Adjust as needed. session_start(); if ( !isset($SessionID) ) { # This likely means that register globals is off. # So, loop through the session vars and create regular vars. while ( list($Key, $Val) = each($_SESSION) ) { $$Key = $Val; } } Enjoy, --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP, XML and HTML-Tags
On Tue, Aug 13, 2002 at 03:22:03PM +0200, Bernard wrote: I am using successfully the PHP XML-parser. But I have one problem. I like to include html tags into the texts and I don't want them to be interpreted by the parser. Have you tried putting the XML in CDATA sections? That's really where such things should be. http://www.w3.org/TR/2000/REC-xml-20001006#sec-cdata-sect --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question concerning php parsing
On Tue, Aug 13, 2002 at 09:22:47AM -0400, Randy Johnson wrote: if i have functions.php with 10 functions in it and include the file in my main php file and call 1 of the 10 functions in my program does the whole functions.php have to be parsed or does it just include the function that is needed. The entire included file is parsed into memory. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] Credit Card suggestions
On Wed, Aug 14, 2002 at 02:20:07AM -0400, Robert Parker wrote: I don't remember where I read this but it only takes the crackers about 1 - 2 seconds to crack your average MD5 encrypted password. This is quite logical because all they had to do is make a database of all of the MD5 sums of all the passwords in the various dictionaries. Of course, that would necessitate access to the machine. A brute force dictionary attack is much more likely. To thwart both, enforce strong passwords. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SQL ?
On Mon, Aug 12, 2002 at 02:15:23PM +, Tyler Durdin wrote: SELECT *, IF (answer = 'a', TRUE, FALSE) AS Answer-A What does the As Answer-A mean and what does it do? Why not examine the manual for the answer to such a basic question, especially one that is off topic for the list you posted to? Assuming you're using MySQL read http://www.mysql.com/doc/en/SELECT.html and you'll quickly come across the meaning of AS. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SQL ?
Hi Tyler: On Mon, Aug 12, 2002 at 02:32:57PM +, Tyler Durdin wrote: Why not just let such a simple question go then? I was being helpful by pointing you to the manual where you could find the answer to this particular question AND a means of figuring out answers to future questions. I was terse because you seemed to have hit on a pet peeve of mine: people not wanting to figure things out for themselves. While, of course, I could be mistaken, your post gave no indication of such efforts. Now on to a separate pet peeve... A: No. Q: Is it okay to top post and not snip out unrelated parts of prior posts (let alone the signature lines, etc)? --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Exploding Zip Codes! (Using PHP's explode function)
On Mon, Aug 12, 2002 at 01:29:38PM -0700, Keith Posehn wrote: | 36310 ABBEVILLE | | 35440 ABERNANT | | 35005 ADAMSVILLE | Look at http://www.php.net/manual/en/function.fgetcsv.php. Use Example 1, substitutingas your delimiter argument and your file name in lieu of test.csv $Data[0] will hold | $Data[1] will hold the zip $Data[2] will hold the city $Data[3] will hold | --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] .htaccess and PHP
On Tue, Aug 13, 2002 at 12:01:24AM +0300, Smad wrote: I am authenticating users on my website using .htaccess. After they log in, I want to pass the user info (for ex: a unique nr. identifiying the person) thruought all the pages which are affected by the .htaccess file $_SERVER['PHP_AUTH_USER'] contains the user name from the Apache HTTP authentication when PHP is running as module. http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question about UNIX command-line directives
On Sun, Aug 11, 2002 at 12:33:55PM -0400, Al wrote: The .htaccess approach appears to fit my situation best; but, I've not been able to get it to work. I wondered about the DirectoryIndex directive's ability to utilize files in other directories, so did a little test, which is what you indicated you tried in your initial email: DirectoryIndex ../index.htm Worked fine. Apache 1.3.26. Windows NT. So, your problem could be a web server configuration thing, as Rasmus hinted at. Beyond the things already discussed, I'm at a loss. Good luck, --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Save ability... Duplicate DB entries
Hi JJ: On Sun, Aug 11, 2002 at 01:44:53AM +1000, JJ Harrison wrote: Which has a save or a publish option. I only want to keep one copy of each article in the DB. This adds a new one each time. I know about updates in SQL but the file may or may not already be in the db. Does anyone have a good way to go about this? Here's a quick outline of what I do. I have a form for entering in articles. If the form is opened without an ArticleID, the ArticleID (a hidden form field) becomes 0. But, if the form is opened with an ArticleID, the given ArticleID is put in the hidden field. Now, when I make my changes and hit the Save (submit) button, the script checks the ArticleID. If it's 0, do an insert. If it's non-zero, do an update. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP form port
On Sat, Aug 10, 2002 at 09:14:03AM -0700, Daniel Guerrier wrote: How do i execute a form post with php? I want to validate CCard info etc.. then perform the post with no furtheraction from the user. Basically If not valid stay here and show whats wrong ELSE post form to process.php Don't. Put the whole procedure into one script. In the first step, do the validation, if it's bad, tell the people so and exit. If it's okay, continue the processing. This will make things easier to control and work reliably. Forwarding post information can lead to a variety of difficulties such as strange behavior when people hit the back button, odd timeouts, let alone, people could play games and go directly to process.php without doing the validation step... among other things. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question about UNIX command-line directives
On Sat, Aug 10, 2002 at 01:12:38PM -0400, Al wrote: I'm on a virtual host without a shell account and need execute a UNIX command. ln -s ../afile.php index.php In a PHP script, you can do this -- if permissions are favorable: exec('ln -s ../afile.php index.php'); Is there some way to do this [e.g., with a htaccess file]? In an .htaccess file, you can put this DirectoryIndex afile.php What happens when you execute UNIX commands like the one above? Does it make a file, change the config? It makes a link in the file system. -s makes the link symbolic. http://www.tac.eu.org/cgi-bin/man-cgi?ln++NetBSD-current --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHPS on apache 2
On Sat, Aug 10, 2002 at 07:38:05PM +0200, FileCop wrote: I have installed apache 2.0.39 and php 4.2.2 on a windows maschine (yes I know that sucks). I have added the AddType application/x-httpd-php-source .phps line to my httpd.conf file, but .phps does not work. Did you add the corresponding Action and ScriptAlias lines to the configuration file as well? If so, what do you have in there for them? --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] records in db
On Sat, Aug 10, 2002 at 05:52:42PM +, Tyler Durdin wrote: If I have a field in my DB that can have 4 different answers, lets say a,b,c and d. How can I count the number of each in that field. So if there are 4 a's 1 b 0 c's and 12 d's how can I get php to count this? Us the database to do that: SELECT FieldName, count(*) FROM TableName GROUP BY FieldName --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Checking Var's passed via URL
On Thu, Aug 08, 2002 at 03:01:15PM -0300, Saci wrote: Parse error: parse error, unexpected T_ISSET, expecting '(' in http://mydomain/Cliente.php on line 2 ?php if (isset($_GET['modo'])){ Your error message is complaining about line 2. Well, that right there is line 2. I bet you retyped the code for your email message. But, in your script, you had mistakenly left off a ( as it says in the error message. PS: May I suggest not putting sooo much vertical whitespace in your messages? The email you sent was hard to read. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with multiple select
Untested... $row = mysql_fetch_array($result, MYSQL_ASSOC); # Assuming items are comma separated in the field... $mins = explode(',', $row['mins']); echo formtabletrtd\n; echo select name=\mins[]\ size=\12\ multiple\n; for ($i=0; $i12; $i++) { echo option value\$i\; if ( in_array($i, $mins) ) { echo ' selected'; } echo $i/option\n } echo /select\n\n; echo /tdtd\n; echo select name=\mins[]\ size=\12\ multiple\n; for (; $i24; $i++) { echo option value\$i\; if ( in_array($i, $mins) ) { echo ' selected'; } echo $i/option\n } echo /select\n\n; echo /td/tr/table/form; --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $http_host use case
David: On Thu, Aug 08, 2002 at 10:30:15PM +0200, David D wrote: I make 2 sites with 2 domain names that use same scripts, Each has got its html templates in a special dir selected judgging from $HTTP_HOST values. ... snip ... search engine works, did they affect this var correctly ? If there was an HTTP request, then the HTTP_HOST will be set. The only problem you can run into is if someone hits the site via the IP address, since you said you only have one. In that case, the HTTP_HOST will hold the IP address. So, decide now which scripts you want to use in that case. Even better, set up two options in your logic: if domain name 1, use script set 1 everything else, use script set 2 --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Having an issue with a Directory Listing in the php Scripting
On Fri, Aug 09, 2002 at 08:58:41AM -0500, §§ Duncan MacLeod §§ wrote: I am only being able to list the first file in each of the directories. Not the entire directory. ... snip ... Although, the only files I really need out of the directory are going to be '.JPG', '.jpg', '.GIF', '.gif', '.JPEG', '.jpeg'. While this doesn't do exactly what your script does, it will point you in the right direction... ?php $DirHandle=opendir('.'); while ($FileName = readdir($DirHandle)) { switch ( substr($FileName, -4) ) { case '.jpg': case '.JPG': case 'jpeg': case 'JPEG': case '.gif': case '.GIF': $FileList[] = $FileName; break; } } # Sort the list alphabetically: asort($FileList); echo 'ul'; while (list(,$Name) = each($FileList) ) { echo lia href=\$Name\$Name/a/li\n; } echo '/ul'; ? -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP: problem with patterns
Hi Alia: On Fri, Aug 09, 2002 at 02:50:32PM +0300, Alia Mikati wrote: I have to parse an html file and replace src attribute of an img. I'm using 'preg_match_all' First off, if you're doing a search and replace, use preg_replace(). having problem with patterns. This is the part of code that should find the appropriate img src: $preg='/img(.*?)src=[\'|]'.addcslashes($original,/).'[\'|](.*?)/si'; The | OR operator is not for use in [] character range blocks. where $original contains the value of src that it should find. For expl, $original can be: ../../MyMCMSSite/images/pic1_abeoway.gif. But the problem is it's not catching the right img src. I don't know why it's not working for you. A slightly tweaked version of that works for me... Do note, you weren't escaping the periods in your addcslashes() call. ?php $document = 'begin img size=5 src=../../MyMCMSSite/images/pic1_abeoway.gif height=3 / end'; echo htmlspecialchars($document); $original = '../../MyMCMSSite/images/pic1_abeoway.gif'; $original = addcslashes($original, '/.'); $preg = '/img(.*?)src=[\']' . $original . '[\'](.*?)/si'; echo 'br /'; echo htmlspecialchars($preg); $document = preg_replace($preg, ' REPLACED ', $document); echo 'br /'; echo htmlspecialchars($document); ? Enjoy, --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Name of Include File breaking a Function - Strange!
On Fri, Aug 09, 2002 at 01:59:09PM -0400, Monty wrote: function user_acess() { if ( isset($_SESSION['valid_user']) ) { return 1; } return 0; } Most of the time it returns 0 (zero) even though I know the session variable is set. However, if I rename the functions.inc.php file to functions.php and make NO changes at all to the code, it suddenly works!? Perhaps, somewhere in your include path is another file named functions.inc.php? Perhpas another file you're mistakenly including has a function already named user_acess()? In your test script, use the function_exists() function before you define the user_acess() function to see what's going on. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question about SQL result formatting
On Fri, Aug 09, 2002 at 10:55:52PM +0200, Kristoffer Strom wrote: How do I convert the result to HTML code, I especially want the linebreaks!! Two options. Put the output in between pre tags. Or if you want the regular font, in PHP use the nl2br() function. --Dan PS: For future reference... The mailing list archive is at http://groups.google.com/groups?hl=ensafe=offgroup=php.general Putting in the search terms line break produces a plethora of results with this same answer. -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] special characters
On Fri, Aug 09, 2002 at 02:58:26PM -0400, Jeb A. Scarbrough (home) wrote: a) strip out any non-standard ascii characters (like the TM or copyright symbol) preg_replace() or ereg_replace(). b) have PHP encode all these symbols. I know about htmlentities, but it not catch everything. htmlentities() is the only automatic game in town. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Having an issue with a Directory Listing in the php Scripting
Hi Duncan: On Fri, Aug 09, 2002 at 04:14:47PM -0500, §§ Duncan MacLeod §§ wrote: it seems as though this wold work great if I had the script running in a actual php.. the initial file is index.php but calls to indexcontent.inc that calls to another inc file that has the actual content info in it. Where the script is doesn't matter. You could include 5 billion layers deep and the operation I sent you will still work the same. Regardless, the point of my code was to show you the direction you need to start thinking in to properly read a directory and extract the names of the files you're looking for. If what I showed you doesn't suit your needs, then tweak things in your script and/or my script until they do. If there's a part of the example you don't understand, go to the manual and check it out. From what I quickly saw of your large script in your first posting, it seemed WAY overly complex for the simple task at hand. maybe it would help if put a copy of the inc file and a copy of the php files.. Not really. The likelyhood of someone wanting to read huge chunks of code is low. Especially when it's base64 encoded. Posting such stuff (let alone top posting w/o removing irrelevant parts of prior posts) to the list wastes a lot of bandwith and disk storage space. Later, --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] First Attempt to use DB failed.
On Fri, Aug 09, 2002 at 04:27:56PM -0500, Jim Bailey wrote: $die_msg = Connection to Database Failed Where's the terminating ; on that prior line? $connect = mysql_connect(localhost,UserName,UserPW) or die(Connect Failed ): You put a : rather than ; on the prior line. Also, to make your debugging easier, use mysql_error() in your die statements in order to figure out why things didn't work as expected. Naturally, for that to be of any assistance, you'll need to clean up your parse errors first. :) --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RegEx (back referencing)
On Sat, Aug 03, 2002 at 05:03:36PM +0100, Phil Ewington wrote: Hi, I am am writing a function to color code and indent JavaScript source using regular expressions and cannot seem to get back referencing working. What you're using isn't back referencing, it's utilizing substrings. Back referencing is when you bring the substrings back into the regular expression definition. $string = eregi_replace((/?)(scr[^]*), «font color=maroon»\1«/font», $string); Here's what your command asks PHP to do: Find any opening or closing script tag and replace it with «font color=maroon»\1«/font». That's not what you intend. Let's make a test script: ?php $string = 'begin scriptjava is dumb/script end'; $string = eregi_replace((/?)(scr[^]*), «font color=maroon»\1«/font», $string); echo $string\n; ? This is what comes out: begin «font color=maroon»«/font»java is dumb«font color=maroon»«/font» end First off, if you want to utilize substrings, you need to use two backslashes. \\1 instead of \1. Second, \\1 refers to the first parenthesized part of the pattern, which in the pattern you set up is the forward slash at the beginning of the script tag. So, let's modify the pattern accordingly and see what happens: $string = eregi_replace((/?)(scr[^]*), «font color=maroon»\\1«/font», $string); Creates: begin «font color=maroon»«/font»java is dumb«font color=maroon»/«/font» end But, that's still not what you intend. I think you're really looking to surround the scripts with maroon font tags. To do that, you need to tweak the expression to grab the script tags, the script itself and the closing script tag. $string = eregi_replace('(script[^]*[^]*/script)', 'font color=maroon\\1/font', $string); Outputs: begin font color=maroonscriptjava is dumb/script/font end Notice the use of ' rather than , which saves a little processor time by not evaluaing the strings for variables. One final improvement. Font tags are obnoxious. They cause problems for people that choose their own background colors in their browsers. Read http://www.analysisandsolutions.com/code/weberror.htm?ft=y for more info on that. Anyway, I suggest using Cascading Style Sheets, http://www.w3.org/TR/REC-CSS1, for the colroing instead: $string = eregi_replace('(script[^]*[^]*/script)', 'code class=js\\1/code', $string); echo stylecode.js {color: maroon;}/style\n; echo $string\n; Yields: stylecode.js {color: maroon;}/style begin code class=jsscriptjava is dumb/script/code end Voila! --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] isset($var) !empty($var) same time!
On Fri, Aug 02, 2002 at 04:48:17PM +0200, lallous wrote: function issne($var) { return isset($var) !empty($var) ? true : false; } is there is any builtin function that does that? (one function call). Yes. Just use empty(). It automatically checks if the variable is: not set null an empty string zero If any of them are true, the empty() function returns true. You don't need your function at all. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] isset($var) !empty($var) same time!
Folks: On Fri, Aug 02, 2002 at 07:01:38PM +0200, Jürgen wrote: Why would i ever want to use isset() then? Because sometimes you just want to check if something is set due to null, '' and 0 being important. $var = ''; empty($var); // evaluates to true isset($var); // evaluates to true unset($var); empty($var); // evaluates to true isset($var); // evaluates to false If i understood you correctly, would the following op = isset($_GET['op']) !empty($_GET['op']) ? $_GET['op'] : ''; be the same as op = !empty($_GET['op']) ? $_GET['op'] : ''; Yes. They do the same thing. Couple things to think about, though. If $_GET['op'] is 0, those commands will turn it into ''. Probably not what you want. Also, though less important, if it's already '', there's no need to do the step of resetting it to ''. Sometimes, a cleaner test is: $op = isset($_GET['op']) ? $_GET['op'] : ''; --Dan PS: Don't be lazy. Trim unneeded parts of prior postings. -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parsing XML into PHP array.
I send the XML request in a string to the credit bureau through cURL and vice versa. Most of the PHP scripting I found everywhere spoke about breaking up the xml tag into the array only when they come from the file and is use for parsing. The example on my page you looked at does get the stuff from a file, BUT, it takes that content and puts it into a string. All the xml_parse() function needs is the string. So, just feed it the string you get back from the agency. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem of characters with xml_parse
On Tue, Jul 30, 2002 at 05:12:25PM +0200, Sebastien Mole wrote: but when I try to parse characters such as chr(#x0001) or chr(#x001F) (or others) the parser returns me an error Line wrapping... What a concept. In my PHP XML parsing tutorial, http://www.analysisandsolutions.com/code/phpxml.htm, I use the following preg to clean out those nasty characters: # Remove all non-visible characters except SP, TAB, LF and CR. $Contents = preg_replace('/[^\x20-\x7E\x09\x0A\x0D]/', \n, $Contents); --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Create a link where http://
On Mon, Jul 29, 2002 at 08:12:33AM -0400, Jesse Lawrence wrote: would like to automatically turn any instance of http://whatever into a link, without requiring the viewers to enter html. The mailing list archive: http://groups.google.com/groups?group=php.general Good search terms: hyperlink regular expression Yields this article: http://groups.google.com/groups?q=hyperlink+%22regular+expression%22+group:php.generalhl=enlr=ie=UTF-8safe=offselm=3A248B2C.13ED233C%40analysisandsolutions.comrnum=2 Which has an excellent [shamelessly patting myself on the back] hyperlink regular expression for ereg*: (http://|https://|ftp://|gopher://|news:|mailto:) ([[:alnum:]/!#$%'()*+,.:;=?@~-]+)([[:alnum:]/!#$%'()*+:;=?@~-]) Do note, if the last character of the URI is a , or . it assumes those are punctuation and leaves them off. Enjoy, --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: REGEX for phone #
Hi Richard: On Mon, Jul 29, 2002 at 05:02:49AM -0500, Richard Lynch wrote: For starters, if Perl wants \ PHP needs \\ since \ is special in both languages. I'm curiuos what you're talking about. The manual says nothing about this in the PCRE section: Example 1. Examples of valid patterns * \/\w+/ * |(\d{3})-\d+|Sm http://www.php.net/manual/en/ref.pcre.php The Pattern Syntax page has a backslashes section which states: In particular, if you want to match a backslash, you write \\. Then, all of my patterns work just fine w/o escaping the backslashes. So, uh, what are you talking about? :) --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Picking up Data of Previous Date from Table
On Mon, Jul 29, 2002 at 01:03:55AM -0700, Thomas Edison Jr. wrote: SELECT * FROM transactions,holdings where transactions.isinno=holdings.isinno AND transactions.clientid='$clientid' AND holdings.clbal!=0 GROUP BY holdings.isinno ORDER BY shares Now for this purpose i'm facing a simple problem. The Data being picked up is of the same date from both the Tables. However, what is required is that the Data from the Holdings table needs to be picked up from a Date a day earlier then the Transactions Table Data. You don't have any JOIN's in there. Set up your JOIN syntax something like this: ...FROM transactions LEFT JOIN holdings ON (transactions.date = date_sub(holdings.date, INTERVAL 1 DAY))... This probably isn't exactly what you need because I'm not really paying attention to the exact demands your request. Rather, I'm pointing you in the right direction for you to figure out what you need to do by reading the manual, hacking and searching newsgroup archives. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates and Date()
On Mon, Jul 29, 2002 at 10:51:39AM -0400, Christopher J. Crane wrote: I believethisto be one way to find out yesterday's date: $tomorrow = mktime (0,0,0,date(m) ,date(d)-1,date(Y)); However, I would like to have a snippet of code to tell me how to get the date of today - 10 days ago. You have a working example of how to get yesterday. Did you even try to rework it to get ten days ago by substituting -10 for -1? What happened? --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ENCRYPT() in MySQL
On Mon, Jul 29, 2002 at 10:06:29PM +1000, Justin French wrote: I'm on a shared server which does not have mcrypt... not good, since i want to temporarily store credit card numbers in an encrypted manner, either in a MySQL database, or in a text file. Uh, what are you going to do with the cc data that you need to store it? Couldn't find much, then did a search on MySQL.com, and found the ENCRYPT(), DECRYPT(), ENCODE() and DECODE() functions. Am I barking up the wrong tree, or can these be used for storing sensitive information (credit card, etc etc) in a mysql table? Should work. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Disturbing parsing problems
On Mon, Jul 29, 2002 at 12:19:50PM -0400, [EMAIL PROTECTED] wrote: if (){ do { if (){ while () {} if () ; else if (); else ; } I don't like one line if statements. Perhaps there's a problem in there. Makes things harder to see. I'd write it: while () {} if () { } elseif () { }else { } if () {} if () { if { Does your code have the () between the if and {? } // } if () { if { Does your code have the () between the if and {? } // } } while (); if() {} //(4x) } Also, your problem could be arising because of some unnoticed (, ), { or } in a command between your control statements. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Credit Card Validation Solution updated
Hi Folks: I'm happy to announce the latest versions of my Credit Card Validation Solution. This includes a new JSP Edition and reworking the PHP and Perl Editions into an Object Oriented paradigm. If you're using a version prior to the following, please upgrade: Ed. Ver URI --- --- JSP 4.2 http://www.analysisandsolutions.com/code/ccvs-jsp.htm Perl 4.7 http://www.analysisandsolutions.com/code/ccvs-pl.htm PHP 4.4 http://www.analysisandsolutions.com/code/ccvs-ph.htm An older version of it is also available for Visual Basic at http://www.analysisandsolutions.com/code/ccvs-vb.htm If you're not familliar with these scripts, here's a quick description: It ensures credit card numbers are keyed in correctly. Includes checks that the length is correct, the first four digits are within accepted ranges, the number passes the Mod 10 Checksum and that you accept the given type of card. Just to be clear, this process does not check with banks or credit card companies to see if the card number given is actually associated with a good account. It just checks to see if the number matches the expected format. Enjoy, --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] REGEX for credit card number
On Sun, Jul 28, 2002 at 04:02:32PM -0400, Mike Mannakee wrote: Does anyone have a regular expression that works to validate credit card numbers? http://www.analysisandsolutions.com/code/ccvs-ph.htm I just updated it to Version 4.3 LATE Friday night. So, anyone using anything earlier than that should upgrade. Enjoy, --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help invoking a regexp
Hi Niklas: On Fri, Jul 26, 2002 at 01:54:25AM +0200, Nicklas af Ekenstam wrote: Hi I have this regular expression: (((http|https|ftp|gopher)|mailto):(//)?[^ \t]*|www\.[-a-z0-9.]+)[^ .,;\t\):] Which is supposed to match hyperlinks. I would like to use this from php to grab all hyperlinks in a text file and return them in an array. I've messed around with the function preg_match_all() but I just can't seem to get it to work. Any suggestions would be very appreciated. Thanks, Nicklas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php The mailing list archive: http://groups.google.com/groups?group=php.general Good search terms: hyperlink regular expression Yields this article: http://groups.google.com/groups?q=hyperlink+%22regular+expression%22+group:php.generalhl=enlr=ie=UTF-8safe=offselm=3A248B2C.13ED233C%40analysisandsolutions.comrnum=2 Which has an excellent [shamelessly patting myself on the back] hyperlink regular expression for ereg*: (http://|https://|ftp://|gopher://|news:|mailto:) ([[:alnum:]/!#$%'()*+,.:;=?@~-]+)([[:alnum:]/!#$%'()*+:;=?@~-]) Do note, if the last character of the URI is a , or . it assumes those are punctuation and leaves them off. Enjoy, --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: newbie form problem
On Sun, Jul 21, 2002 at 03:50:15PM -0500, Richard Lynch wrote: if (!$MailFromAddress) { This should probably be: if (!isset($MailFromAddress) || !$MailFromAddress)){ Or better: if ( empty($MailFromAddress) ) { --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] web-based survey form design : PHP MySQL
On Sun, Jul 21, 2002 at 11:57:25AM -0700, Dipendra Raj Subedi wrote: first goal of doing one project Design web-based survey using PHP and MySQL. I would appreciate if anybody give me some links that help to develope such skills. Try the various script archives. Good one is php.resourceindex.com. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Traversing an appendable file
On Sun, Jul 21, 2002 at 08:50:15PM -0400, Chris Earle wrote: Is there any way to fseek (or something to the exact same effect) a file opened with a or a+? I've tried rewinding and fseeking appendable files, but neither work. Opening up in r+ gives me part of the desired result, but if where I want to write is not at the end, it writes over things, which I obviously do not want. Go to the archives, http://groups.google.com/ and look up the thread on the php-general list entitled Editing files by line --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reg exp to remove line feeds before lines starting with white space
On Thu, Jul 25, 2002 at 12:36:27PM +0200, Nicklas af Ekenstam wrote: In order to read the headers into an array of header key/value fields i would like a reg exp to remove all new lines/line feeds before a line starting with one or more white spaces or tabs. In ereg_replace() you can use [[:space:]] as the pattern and replace it with ' '. That will grab all whitespace characters and replace them with a one space. To do that with preg_replace() use \s. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mySQL Queries using PHP's SESSION variables
On Thu, Jul 25, 2002 at 02:51:13PM -0400, Anup wrote: Hello, I am stuck here. In the name of efficiency I want to lower the number of callls to the database. So I am trying to give the most stringent query possible. This is the problem: I have stored the surfers shopping cart, where each item is stored as a session variable.Now on the database I have ALL inventory items, but I want to only display the details of what the user has in his cart. eg. : I want something like this: $result = mysql_query(SELECT * from Inventory where ItemNumber is in $HTTP_SESSION_VARS); Other folks have made suggestions, but this is way simpler. Assuming the session vars and ItemNumber are numbers: $result = mysql_query('SELECT * from Inventory where ItemNumber IN (' . implode(',', $_SESSION) . ')'); If it's strings: $result = mysql_query(SELECT * from Inventory where ItemNumber IN (' . implode(',', $_SESSION) . ')); --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parse error - new set of eyes?
Hi: On Thu, Jul 25, 2002 at 02:40:28PM -0600, Jas wrote: I am getting a parse error on line 14, I am trying to make sure session vars are being set before rendering the page. This is lines 12,13,14 15. The way you posted it here, it's hard to tell which line is which. Layout your script the same way it will look in your email, then run it. More importantly, we need to see the error message. There are TONS of different parse errors that can happen. Plus, I bet if you read the message, and THINK about what it says, it'll give you a clue what to look for. if ((!$u_name) || (!$p_word)){ Use empty($var) rather than (!$var) to avoid warnings where the var isn't even set. header(Location: index.php); Location needs a full URI: http://www.foo.com/index.php. But, I don't think any of those will produce parse errors. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unset array here?
On Thu, Jul 25, 2002 at 10:26:03PM +0200, Bas Jobsen wrote: Hello, I have this example code: function doprint($a){foreach($a as $value)echo $value;} doprint(array('1','test','hello','and')); Question, is the array in memory after the function call? So, should it be better to use this: function doprint($a){foreach($a as $value)echo $value;} doprint($temp=array('1','test','hello','and')); unset($temp); Depends on the scope you're talking about. The first way doesn't set the array into memory outside the function, but it goes into memory inside the function as $a. The second way puts it into memory twice, first as $temp and second as $a. Now, I'm not certain of what happens to your memory allocation inside the function. I don't believe PHP automatically cleans up memory under such circumstances. If I'm correct and you want to keep memory down, you could do an unset() INSIDE the function. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reg exp to remove line feeds before lines starting with white space
On Thu, Jul 25, 2002 at 12:36:27PM +0200, Nicklas af Ekenstam wrote: In order to read the headers into an array of header key/value fields i would like a reg exp to remove all new lines/line feeds before a line starting with one or more white spaces or tabs. Pardon my prior post. I only saw how to remove new lines/line feeds and not the second part of the sentence before a line starting with one or more white spaces or tabs. preg_replace('/[\r\n]+[ \t]+/', ' ', $header); --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] modify an element of a HTML tag within a string
Hi Justin: On Fri, Jul 19, 2002 at 01:50:08PM +1000, Justin French wrote: 1. look for a given tag eg DIV 2. capture the tag (everything from 'DIV' up to the '') 3. look for a given attribute (eg ID=foo, ID=foo, ID='foo' -- all valid ways) 4. capture it 5. be given the opportunity to manipulate the attribute's value, delete it, etc 6. place captured tag (complete with modifed elements) back into the string in it's original position 7. return to step 1, looking for the next occurence of a DIV tag This can be done with preg_replace() and a function. Here are some variations on such an expression / function combo. ?php $Val = 'begin div middle div id=idattr end'; function alter($var) { return _$var . '_'; } # To grab all attributes... $Out = preg_replace('/((div)([^]*))/i', '\\2' . alter(\\3), $Val); # \\1 contains whole match # \\2 contains tag type # \\3 contains attributes echo htmlspecialchars($Out); echo 'hr /'; # To grab just the id attribute... $Out = preg_replace('/((div) ?(id=(?:|\')([^\']*)(?:|\'))*)/i', '\\2' . alter(\\4), $Val); # \\2 contains tag type # \\3 contains whole id attribute statement # \\4 contains the attribute value echo htmlspecialchars($Out); ? Of course, be a good hacker and modify it to suit your actual needs. :) Enjoy, --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] vertical word match SOLUTION
Hi Joe: On Fri, Jul 19, 2002 at 12:50:53PM -0500, 'Joe Rice' wrote: $answer = hello\na\np\np\nl\ne\n; /*from textarea in form*/ /* replace all whitespace and newlines with nothing */ $tempanswer = preg_replace(/\s*|\n*/,,$answer); Easier: $tempanswer = preg_replace('/\s/', '', $answer); The \s includes all white space, including line breaks. You don't need the *'s in there because all of them get replaced anyway. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST question
Jadiel: On Sat, Jul 20, 2002 at 12:58:25AM -0500, Jadiel Flores wrote: header(Location: computer.php); Do note, proper syntax uses complete URI's, not just the page name. Also, you can do this with single quotes. header('Location: http://www.foo.org/computer.php'); Enjoy, --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CRLF Injection in mail()
John: On Fri, Jul 19, 2002 at 11:19:59PM -0400, John Holmes wrote: Maybe I'm behind the times, but I just found out about this one today. Basically if a user can take your form that sends an email, and send a value like This is my subject\nBcc: [EMAIL PROTECTED] for the subject, then they will get Bcc'd on every email your script later sends. Well, as mentioned by others, not every email, just the one being sent at that time. But, more importantly, folks can put in other people's addresses into the Bcc and spam them all using your resources. This has already been exploited on some web to mail forms. My email form functions check user input for unwanted characters, including \r and \n via ereg. If any are found, they're removed and the form is redisplayed saying they can't use such characters. Later, --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML vs. PHP manual???
On Tue, Jul 23, 2002 at 12:33:19PM -0400, Scott Fletcher wrote: I read the useful document about XML in PHP on http://www.analysisandsolutions.com/code/phpxml.html. Thanks. But, you mean: http://www.analysisandsolutions.com/code/phpxml.htm I had to write XML stuffs on the client-side with the build-in XML request and it doesn't make sense that the client brower should be communicating to credit bureau network without going to my company's PHP webserver to that credit bureau. Programs do what you tell them to do. If you write something on the client and then tell it to get data from (or send data to) the credit bureau, why would you expect it to communicate with your server? If you want it to send/receive from your server, then you need to tell the program to do that. Also, PHP is a server side language, so, if you wrote something client side, what language did you write it in and you might be better off asking on a list for that language. So, it meant I have to use the post request that would send the data to my company's PHP webserver and somehow convert it into xml and send it to that credit bureau by cURL. Is there a way to do that?? Sure. Make an HTML form on your server where users type in the input. You need to then design a script that handles the data the users submit. I don't know how you want the data formatted nor how data gets submitted to your credit bureau, so I can't state anything specific on the remaining steps. Anyway, when you're writing your HTML form in the first step, the action attribute in the form tag should lead to that second script you made. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Credit card checks?
On Tue, Jul 23, 2002 at 11:17:19AM -0700, Richard Baskett wrote: http://www.AnalysisAndSolutions.com/code/ccvs-ph.htm Rick, thanks for the plug. Allow me to plug it further... I updated that page just this minute. So, whomever looked at it in the past (prior to 12:00 am 24 July 2002 EST) should check it out again. These changes make the checks easier to integrate into your own programs. This function, now a class, is the most comprehensive, flexible and easy to use credit card validation script I've seen. Also, I've now integrated this function into my Form Solution class: http://www.FormSolution.info/ Enjoy, --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cookies - good or bad???
On Thu, Jul 18, 2002 at 03:38:51PM +0200, PHPCoder wrote: What are the general feeling out there amongst developers about the use of cookies? Cookies rely on client side. I never rely on the client for anything. When it comes to examples of how to do things The Right Way, I say go take a look at amazon.com. No cookies. No Java'sCrap. Works flawlessly. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML with PHP cURL.
On Thu, Jul 18, 2002 at 11:03:10AM -0400, Scott Fletcher wrote: Hi! I find it to be mind-boggling to try to make xml work with php and curl. What do anyone here think of it? Well, I can offer help on the XML: http://www.analysisandsolutions.com/code/phpxml.htm --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Someone Help please
On Thu, Jul 18, 2002 at 11:06:11AM -0400, Chris Crane wrote: Well, I posted it the first time and no one responded so I figured the subject did not interest anyone. I changed it. I am not sure how the third one started. We're all here volunteering, trying to help each other out. If you want an instant response, hire someone. Otherwise, you need to be patient. Sure, if you don't get a reply in a few days, your request probably slipped through the cracks, post again. But, in this case, you're being unreasonable: First post was at 10:00. Second at 11:58. Third at 13:16. Posting to the list multiple times makes the list less pleasant for the people trying to help and those trying to learn. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code errors
On Thu, Jul 18, 2002 at 11:35:55AM -0400, Chris Crane wrote: Hey thank Dan, I will try this. Does List waste lots of time and memory? It does if you don't need to do it. Just put the data you really need into memory. Forget about the rest. If you already have something in memory, don't duplicate it. Normally, I create a function and global a bunch of variables to be used later on the HTML/PHP file. If you're globaling the variables, why not just write the code without enclosing it in a function? After I global the variables I split the string using the List function. I do that for stock quotes from YAHOO so I can code the layout in like Dreamweaver and place the varaibles where I would like instead of the function writing out the html for me. Is that bad? In general, it makes sense, but, does it make the most sense. Depends on the situation. But, in this situation, you're printing out a whole table of the data, so your way doesn't make sense. A: No. Q: Is okay to top post and/or quote the entirety of the a post? --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php.ini problem
On Thu, Jul 18, 2002 at 12:55:34PM -0300, Andre wrote: The configuration in php.ini seems not to be used by httpd. Make a script with phpinfo() in it and examine which php.ini file is being used. Sounds like you may be accessing the wrong file, even though you're saying you're not. I've traced my httpd process and it opens the php.ini file in the expected directory, but variables set in there don't take effect (e.g. engine=On, display_errors=Off, etc.). Are you making the changes in php.ini and _then_ restarting Apache? If not, you need to. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cookies - good or bad???
On Thu, Jul 18, 2002 at 08:47:45PM +0300, Alberto Serra wrote: It's a customer's choice, obviously. Most customers do not give a damn about minorities (and so do not want to increase budgets to develop an alternate solution that will address a minor community). What increased cost? If someone does the right thing in the first place, there's no cost. The developers are either gettting paid to develop something that works right in the first place or they're getting paid to develop something that doesn't. Let's use your Iframes example. My client was using them. I replaced such with proper layout for local content and importing remote content through implode('', file()). How does that cost more? Anyway, cutting out potential long term revenue by alienating potential customers is a bad business decision. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ARRAY_PUSH with $key
On Thu, Jul 18, 2002 at 03:40:58PM -0400, Joshua E Minnie wrote: Hey all, Does anybody know of a way to push an element onto an array with a specific key? What I am trying to do is create a dynamically created associative array. Here is a sample print_r of what an array would look like: I don't understand the value of array_push(). I just add new elements by something like: $Array[$Key] = $Value; --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about using if elseif ...
On Thu, Jul 18, 2002 at 02:28:23PM -0700, Fargo Lee wrote: When viewing examples of using if and elseif I often see the example ending with an else like ... if($a == '1'){ echo '1'; } elseif ($a == '2'){ echo '2'; } else { echo '0'; } On a side note, switch would be more efficient: switch ($a) { case 1: echo '1'; break; case 2: echo '2'; break; default: echo 'other'; } Also use nesting / indenting to make your code more readable: if ($a == '1') { echo '1'; } Is there any problem with leaving out the last else and just ending it with an elseif such as ... if($a == '1'){ echo '1'; } elseif ($a == '2'){ echo '2'; } That all depends on the circumstances. Both have their places. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Arrays and Regs
Martin: On Thu, Jul 18, 2002 at 03:55:13PM -0400, Martin Clifford wrote: Just a performance question, if anyone knows for sure. Within a large array, would using numerical indices be quicker than associative? I'm talking about a *noticeable* difference in performance, here. The difference is marginal. The longer the variable name, the more resources used, but it's not something that you're really going to notice. More important is code readability. But, the difference between turning line wrapping on (~77 columns) in your email client will save significant time for people replying to your posts. $text = eregi_replace(([abc]+), span style=\color: red\\\1/span, $text); Would this replace any occurences of the pattern with the same pattern match in red text? I'm not sure exactly how the \\1, \\2, etc. works. It matches sub-patterns, which are the things in parentheses. The number corresponds to the parenthetical order. $text = eregi_replace((a)(b)(c), \\1, $text); Does this output only the 'a'? Exactly. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Loading a File into Variable - How??
On Thu, Jul 18, 2002 at 04:28:57PM -0400, Monty wrote: Look 4 implode() in the function list Implode isn't really what I need, I just want to load an entire file into a single string variable. Yes, it IS what you need. Plus, to work around your other problems mentioned in later posts... $string = implode('', file('filename') ); --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ARRAY_PUSH with $key
On Fri, Jul 19, 2002 at 01:58:42AM +0300, Pekka Saarinen wrote: I think array_push gets you cleaner lookin code (subjective). It also ensures you always add to end of the array - good for novices like me. Array_push is also TWO times faster (academic difference in the speeds of modern computers, but faster :) : AH! But your test is flawed. Reorder things so the push is first and that'll be slower. In addition, push() is more like setting $Array[] rather than $Array[$n]. So, here's my test, including some arithmetic calculation changes: pre ?php function getMicrotime() { list($usec, $sec) = explode(' ', microtime() ); return bcadd($usec, $sec, 6); } # ROUND 1 $Array = array(); $start = getMicrotime(); for ($n=0;$n=1;$n++) { $Array[$n] = $n; } $stop = getMicrotime(); echo 'key num: ' . (bcsub($stop, $start, 6)) . \n; $Array = array(); $start = getMicrotime(); for ($n=0; $n=1; $n++) { array_push($Array, $n); } $stop = getMicrotime(); echo 'push: ' . (bcsub($stop, $start, 6)) . \n; $Array = array(); $start = getMicrotime(); for ($n=0; $n=1; $n++) { $Array[] = $n; } $stop = getMicrotime(); echo 'key blank: ' . (bcsub($stop, $start, 6)) . \n; # ROUND 2 $Array = array(); $start = getMicrotime(); for ($n=0;$n=1;$n++) { $Array[$n] = $n; } $stop = getMicrotime(); echo 'key num: ' . (bcsub($stop, $start, 6)) . \n; $Array = array(); $start = getMicrotime(); for ($n=0; $n=1; $n++) { array_push($Array, $n); } $stop = getMicrotime(); echo 'push: ' . (bcsub($stop, $start, 6)) . \n; $Array = array(); $start = getMicrotime(); for ($n=0; $n=1; $n++) { $Array[] = $n; } $stop = getMicrotime(); echo 'key blank: ' . (bcsub($stop, $start, 6)) . \n; ? /pre Results... key num: 0.000301 push: 0.000145 key blank: 0.000135 key num: 0.000136 push: 0.000135 key blank: 0.000135 The times compared to each other varied each time I reran the test. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Strong Web Hosts in Canada?
Hi Folks: A client of mine has a large series of high traffic, PHP/MySQL intensive websites. They're looking for dedicated hosting in Canada. Any recommendations? Enjoy, --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem on file_exists() function
On Wed, Jul 17, 2002 at 03:55:10PM +0800, Jack wrote: if (file_exists(c:\\pdf_reports\\dealing\\test.txt)) It seems that php can't detect the file in such path!!! While this isn't your problem, it's nicer coding. Single quotes and forward slashes: if ( file_exists('c:/pdf_reports/dealing/test.txt') ) if (file_exists(c:\\pdf_reports\\test.txt)) Then it can detect the file is there! why? Probably, PHP doesn't have permissions on the dealing directory or you misspelled it. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regular expression
On Wed, Jul 17, 2002 at 04:03:02PM +0200, Michal Albrecht wrote: Andrey Hristov wrote: $your_string = preg_replace('/[\d\w]+([\w\d]{3,}\.)+([\w]{2,4})/','', Thank you very much for your time, but this strips the e-mail address and lives the domain. Could you give me some hints on how to make it working the opposite way? Let alone, it assumes TLD's are 2-4 characters long, when in reality, they're presently up to 6 characters long. preg_replace('/^([a-z0-9_.=+-])+([a-z0-9-]+\.)+([a-z]{2,6})$/', '\\1', $your_string); --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Classes Constructor syntax
On Wed, Jul 17, 2002 at 03:26:15PM +0200, David Russell wrote: class issue { function issue() { //default constructor } function issue($number) { //1 variable constructor } } My question is: will this work? does PHP OOP support more than one constructor? No. But, here's a workaround: class issue { function issue($number=NULL) { if ( is_null($number) ) { echo 'doing the first function'; } else { $this-issue1($number); } } function issue1($number) { echo 'in the second function'; } } # To call first function only... $Obj = new issue(); echo 'hr /'; # To call second function... $Obj = new issue('blue'); Enjoy, --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File reading help with Syntax
On Wed, Jul 17, 2002 at 10:00:29AM -0400, Chris Crane wrote: I am getting data froma website for stock information. If I type in the brower the URL I get a text file display list this; Date,Open,High,Low,Close,Volume 16-Jul-02,7.92,8.10,7.68,7.82,605500 15-Jul-02,7.98,8.02,7.59,8.02,577200 12-Jul-02,7.80,8.00,7.57,7.95,411100 11-Jul-02,7.82,7.94,7.34,7.80,802400 So, now you're working an another approach to the stock quote question, eh? Use these functions: fopen() fgetcsv() Look at the manual on how to use them. If, for some reason, that's not clear, check out the archives for this list on http://groups.google.com/. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ARRAY_PUSH()
Chris: Why'd you start a second thread on this? See my reply in the File reading help with Syntax thread. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php