[PHP] Re: PHP from HTML
On Mon, 8 Apr 2002 10:18:50 +0200, Matjaz Prtenjak [EMAIL PROTECTED] wrote: Except on PHP side I have to produce javascript code without script tag, like xTest.php - SERVER1 with PHP document.write(?php echo(\This WORKS!!!\); ?); That makes sense - it's been awhile since I've had to do something like this. Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how to sort by value in associative array
On Sat, 6 Apr 2002 18:21:10 -0600, Peter J. Schoenster [EMAIL PROTECTED] wrote: I tried the above. uksort ($ArrayOfNewsLinks, SortByValue); function SortByValue ($a, $b) { if ($a[language] == $b[language]) return 0; return ($a[language] $b[language]) ? 1 : -1; } or this function SortByValue ($a, $b) { return strcmp ( $a[language], $b[language]); } Doesn't work. I should have caught this earlier. Try uasort() - uksort() sorts on the array *key*, not the value. ? $ArrayOfNewsLinks = array( http://dailynews.yahoo.com/fc/World/Brazil/; = array( 'title' = 'Yahoo Brazil News', 'category' = 'news', 'language' = 'English', ), http://news.bbc.co.uk/hi/english/world/americas/default.stm; = array( 'title' = 'BBC News', 'category' = 'news', 'language' = 'English', ), http://news.yahoo.com/; = array( 'title' = 'Yahoo News', 'category' = 'news', 'language' = 'English', ), http://chinese.news.yahoo.com/; = array( 'title' = 'Yahoo News', 'category' = 'news', 'language' = 'Chinese', ) ); function news_sort($a, $b) { // Two key sort: first by language, then by title $i = strcmp($a['language'], $b['language']); if ($i != 0) { return $i; } else { return strcmp($a['title'], $b['title']); } } header(Content-Type: text/plain); print_r($ArrayOfNewsLinks); uasort($ArrayOfNewsLinks, news_sort); print_r($ArrayOfNewsLinks); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP from HTML
On Sun, 7 Apr 2002 20:03:42 +0200, Matja¾ Prtenjak [EMAIL PROTECTED] wrote: SERVER1 with PHP some file with name xTest.php xTest.php: ? echo(Hi from SERVER1); ? SERVER2 without PHP some file with name file1.html file1.html: html body Server1 is saying : ? /body /html How can I make HTML file (on SERVER2) say 'Server1 is saying : Hi from SERVER1'? One possibility is an IFRAME. Unfortunately, IFRAME may not be compatible with all of the browsers you need to support and may cause undesirable scrolling effects, so I'd test carefully. One more compatible workaround would be to have your PHP return JavaScript: script lang=javascript1.1 document.write(Hello from Server1); /script In the HTML page on server2: script src=http://server1/xTest.php;/script Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: regular expressions: HUGE speed differences
On Sat, 06 Apr 2002 15:01:24 +0300, Ando [EMAIL PROTECTED] wrote: (eregi((frame[^]*src[[:blank:]]*=|href[[:blank:]]*=|http-equiv=['\]refresh['\] You might want to try using preg_match instead. The PCRE engine should be significantly faster. You might also find the ability to pass an array of expressions would simplify your code significantly. Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to sort by value in associative array
On Sat, 6 Apr 2002 10:36:18 -0600, Peter J. Schoenster [EMAIL PROTECTED] wrote: $ArrayOfNewsLinks = array( http://dailynews.yahoo.com/fc/World/Brazil/; = array( title = 'Yahoo Brazil News', category = 'news', language = 'English', ), ... function cmp ($a, $b) { if ($a[2] == $b[2]) return 0; //return strcmp ( $a[2], $b[2]); // thought this would work return ($a[1]$b[1])?1:-1; } uksort ($ArrayOfNewsLinks, cmp); Try changing those subscripts to keys: if ($a[language] == $b[language]) etc. You should have a ton of PHP warnings generated from the code above, as numeric elements won't exist. As a side note, an interesting addition would be using the title as a second sort key: if ($a[language] == $b[language]) { return strnatcasecmp($a[title], $b[title]); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: MySQL - UPDATE INSERT
In article [EMAIL PROTECTED], Phil Schwarzmann wrote: $query = UPDATE table SET (var1, var2, var3) VALUES ($var1, $var2, $var3) WHERE username='$username'; Im wondering cause I have an INSERT query $query = INSERT INTO table (var1, var2, var3) VALUES ($var1, $var2, $var); ...but only there are like 150 different variables and it will take me forever to write a query like Unfortuantely, UPDATE syntax is in fact completely different. This is usually a good thing - imagine counting commas with those 150 columns to see if you put #93 in the 93rd or 94th spot! It sounds like you need to normalize your data more. I can't imagine anything which would require that many columns in one table and it's usually better to break things into multiple tables where possible. If you can, see if you can't restructure the database considerably - you'll save yourself a great deal of work later. Assuming you can't avoid setting that many variables at once, you can use a PHP script like this to generate some statements programatically: ? header(Content-Type: text/plain); if (empty($_REQUEST['Table'])) { die(Please provide a URL parameter Table); } else { $Table = mysql_escape_string($_REQUEST['Table']); } print -- Generated by . basename(__FILE__) . from $Table table on . date(Y-m-d H:i) . \n; mysql_connect(localhost, USER, PASSWORD); $fields = mysql_list_fields(DATABASE, $Table) or die(mysql_error()); $columns = mysql_num_fields($fields) or die(mysql_error()); print UPDATE $Table SET\n; for ($i = 0; $i $columns; $i++) { $name = mysql_field_name($fields, $i); $type = mysql_field_type($fields, $i); $flags = mysql_field_flags($fields, $i); print \t$name = ; switch ($type) { case int: print \$$name; break; case string: case blob: print '\$$name'; break; case datetime: print '\$$name'; break; default: print unknown type $type; } print /* type: $type flags: $flags */; if ($columns - $i 1) print ,; print \n; } print WHERE ...\n; ? (As a side note, MySQL supports the UPDATE style syntax for INSERT and has a REPLACE command which will UPDATE if the record exists and INSERT if it doesn't - this can help you maintain only one query) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: help condensing regular expressions
In article [EMAIL PROTECTED], Tom Rogers wrote: I am trying to calculate how far into a directory structure I am so that I can include images and include files without having to hard code them. I need to turn $PHP_SELF which could be /admin/emails/index.php into ../../ which I can then use to get to any directory from root. Here's a more compact regexp: preg_replace(|/[^/]+|, ../, dirname($_SERVER['PHP_SELF'])); dirname() returns only the directory part of a filename (e.g. /~chris from /~chris/myfile.php). Using | instead of the usual / to delimit the regular expression just saves a bit of typing. (Note that for includes, you'd be better off setting include_path in php.ini or .htaccess - that avoids the need to worry about where the files are physically located) If you need the local file path and you're using Apache, the PATH_TRANSLATED variable can tell you where your files are: $current_dir = dirname($PATH_TRANSLATED) . /; This could be used to construct absolute paths internally - I use it in my photo gallery code when creating thumbnails such with convert. Using it with DOCUMENT_ROOT can help if you need to construct things like directory listings. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: help condensing regular expressions
In article [EMAIL PROTECTED], Tom Rogers wrote: Thats what I was after :) Glad I could help. At the top of each page I now do $reltoroot = preg_replace(|/[^/]+|, ../, dirname($_SERVER['PHP_SELF'])); ini_set (include_path,ini_get(include_path).:.$reltoroot.../include); which takes care of the include path Out of curiosity, couldn't you put something like php_value include_path .:/document/root/include:/usr/lib/php in a .htaccess file? Or has your ISP disabled .htaccess files? Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Browscap.ini
On 19 May 2001 22:13:05 -0700, Weston Houghton [EMAIL PROTECTED] wrote: I cannot for the life of me get browscap.ini to work. Also the browserhawk version of the browscap.ini is sadly out of date. Anyone have any leads for me on getting this to work? I consistently get an empty array returned. First, get_browser() seems to break in every other release, particularly on Windows. You might want to search bugs.php.net to see if it will work at all on your system version. If you are using a build with a functional get_browser(), check out asptracker.com for a more recent browscap.ini. Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Redirection in PHP ? (newbie)
On 14 May 2001 16:54:49 -0700, Nicolas Mermet [EMAIL PROTECTED] wrote: To avoid spamming my db I would like to implement a simple redirection function, that would redirect the user to the main admin page once the feeding script has successfully executed and would reduce chances of double entries. Is there a simple way to achieve that ? header(Location: index.php) should do the trick. However, I'd recommend something more robust if avoiding duplicates is a big deal. For example, if you're using sessions, you might have your addition script set a confirmation variable using uniqid() and changing it after updating the DB; if confirmation variable passed in the form submission doesn't match the session variable, you can redirect them to the Were you really sure? page. Alternately, depending on your data structure it might be easier to simply insert a dummy record first and then use UPDATEs from that point forward. (The unique confirmation variable approach is also a good idea for security purposes - otherwise if someone can guess the structure of your application, they could do something funny like send an HTML email with a link to /products/delete.php?ID=someIDConfirmed=yes to an admin, which would go directly through without confirmation if they were logged in at the time.) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] need some ideas here...
On 14 May 2001 16:59:48 -0700, Christian Dechery [EMAIL PROTECTED] wrote: My free-web-hosting (www.f2s.com) does not allow PHP to send emails... I've tried everything... the mail() function, my alternate function which calls popen(/usr/lib/sendmail -t) and even a script.cgi with '#!/usr/bin/php' and all that stuff... Did you try a popen with something /usr/bin/mail? (I assume you've checked the file paths to make sure they're correct) the mail simply won't go an mail() always returns false... I'm guessing there's no mail sending in this server... so what do I do? is it possible for me to call a script on another host from with a script and return something to it? PHP does allow arbitrary URLs to be loaded, so you could setup a script and simply do something like this: $email_script = fopen(http://someotherhost/mail/script.php?To=blah...;, r); $Status = fgetss($email_script); If you need to send large emails, you'll need to fake a POST request. I've had to do this the hard way in the past but I think there are a couple PHP classes floating around now which will let you do it. (And, of course, you could use CURL) Alternately, if you have a friendly mail server available, you could simply use one of the SMTP scripts available to send directly to the mail server. Check out phpclasses.upperdesign.com for a couple scripts. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] need some ideas here...
On 14 May 2001 19:04:43 -0700, Ben Gollmer [EMAIL PROTECTED] wrote: If you have an account on a remote host, you can always do something like this: ?php include(http://www.remotehost.com/~myaccount/mailfunction.inc;); mymail($to, $mailbody); ? where mailfunction.inc has the mymail function defined to just take your parameters and stuff them into the standard mail(). Wouldn't this still run the code on the local server with the dysfunctional mail() command? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] OT question..
On 8 May 2001 16:43:03 -0700, Stephan Ahonen [EMAIL PROTECTED] wrote: I ment the signature signed by Adolf Hitler. As a German I doesnt like such nonsense. BTW I'm also a webmaster @ php.net. I side with Christian here - The only way we can prevent mistakes like the whole Hitler thing is to learn about them, and know what it looks like when someone's trying to get crawl into absolute power so we can recognize it and prevent it when it happens. I'll second this - the quote is hardly pro-Nazi. Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Flash/PHP/MySQL
On 6 May 2001 10:25:19 -0700, FredrikAT [EMAIL PROTECTED] wrote: Can Flash import some text from a database (e.g MySQL) and print it on the fly? Yes. It's actually pretty easy - you can tell flash to load a bunch of variables from a URL. Your URL can return the encoded data (basically a URL-style Variable=fooOtherVariable=Bar format - check the Flash docs) and Flash will create/update those variables to have the values returned. This can be as easy as creating a text entry box and having a URL return a variable with the same name - flash will update the contents of the text box automatically. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] php4apachi.dll
On 6 May 2001 05:53:54 -0700, Darren [EMAIL PROTECTED] wrote: Hi. I just installed a fresh copy a windows 95. I installed winsock 2, apache 1.3.19 and php4. I followed the instructions with the php installation and I booted apache, I got a missing dll error message from apache. I got the impression that it wasn't php4apache.dll that was missing as it was there and http.conf was pointing to it. I can only assume that there is another dll somewhere that is missing. Any ideas? Try running the CGI version of PHP - you should get a nice error saying what couldn't be loaded. The most common cause of this is due to extensions - either it can't find the extension itself or, more commonly, the extension needs to load another DLL and it can't find that. It may help to simply clear out your php.ini's extension section and see if the problem goes away. Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Netscape and post
On 4 May 2001 21:48:46 -0700, Richard Kurth [EMAIL PROTECTED] wrote: I am having problems with Netscape and post in a form In I.E. post works fine but in netscape it just gives me a Method Not Allowed The requested method POST is not allowed for the URL /scripts/index.html. form method=post action= Why is this doing this. Sometimes I just hate Netscape Presumably because the action attribute needs to have a value. Since your HTML is broken, Netscape is creatively misinterpreting it, as it is wont to do. Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Need to know this
On 3 May 2001 20:19:51 -0700, YoBro [EMAIL PROTECTED] wrote: ASP or PHP and who has the biggest market share. Which is better is a subject of some debate. Suffice it to say that most of the people on this list will say PHP. I personally consider ASP a good idea only if you have a heavy Microsoft environment. As far as market share goes, that depends on how you measure it. I see more high traffic sites using ASP (although PHP is starting to show up all over the place) but according to the most recent E-Soft survey, IIS ran 778,377 sites and PHP was installed on 646,045 (39.78%) Apache installations. Since not all of the sites with PHP installed may use it (think hosting companies with default installs) and since IIS is often used to run other scripting tools (e.g. JSP, Cold Fusion, even PHP), I'm not going to try to adjust those numbers - it'll probably balance out. If you assume that percentage of PHP usage carries over to Netcraft's results, around 7 million domains use PHP, handily out-numbering the 5.9 million IIS sites. (Disclaimer: all stats are for entertainment purposes only. Microsoft fans are invited to pick a method which favors their choices.) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] why isn't get_browser() not working?
On 30 Apr 2001 00:51:13 -0700, elias [EMAIL PROTECTED] wrote: hello. i'm trying to detect what browser version is there...i'm using get_browser() as it was documented: Check to see if your browscap file is being picked up - try something like this: echo count(file(ini_get(browscap)); If that works, you're probably the latest victim of the way get_browser() has been fixed and rebroken in various versions and ports. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Browser Caching
On 29 Apr 2001 07:19:15 -0700, Steve Haemelinck [EMAIL PROTECTED] wrote: I thought this was because the page might be cached, but when I set the header(cache-control: no-cache) the meta tag http-equiv=Expires content=-1 it still produces the same effect. How can I solve this problem? Have you tried with the other HTTP headers for expiration? This is floating around various places - the PHP manual, etc. header(Expires: Mon, 26 Jul 1997 05:00:00 GMT); // Date in the past header(Last-Modified: . gmdate(D, d M Y H:i:s) . GMT); //always modified header(Cache-Control: no-cache, must-revalidate); // HTTP/1.1 header(Pragma: no-cache); // HTTP/1.0 If that doesn't work (IE/NS can be really buggy with caching - I once had a problem where a page started returning a 500 error code and IE5 continued to display the old version of that page, even though I had set the cache to check every time), some alternatives come to mind: - Embed some random variable in the URL. I think this is the cleanest way of dealing with browsers which ignore the HTTP headers - simply start encoding the session ID in your links or even something like DontCacheThisPage= . time(). If the URLs are different, the browser won't cache them, which should sidestep the issue. If for some reason you can't do that and don't mind kludgy looking code: - Use POST. It's ugly and nasty but the browsers are better about always reloading pages which are the response to a POST request. - Equally ugly, use JavaScript. When you change a document's location, there's a parameter which if true will cause the browser to reload the page even if it's cached. The least ugly way of doing this would be to write a function and put it in a handler ('OnClick=return forceLoad('myurl');') so that poeople w/o JS will still be able to use your pages. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] count() problem :D
On 27 Apr 2001 19:50:04 -0700, Chris Schneck [EMAIL PROTECTED] wrote: anywho, im having problems getting data out of the count() function i've implemented, could anyone lend a hand? $query = select count(fld_gender) from tbl_survey; how exactly is it that you output data retrieved from a count() implementation? The same way you retrieve data from any other query - SQL functions like count() or sum() return data in the same fashion as normal, non-computed data. As an example: $foo = mysql_query(select count(*) from table); echo Number of records in table: . mysql_result($foo, 0); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] help!! newbie
On 21 Apr 2001 19:26:03 -0700, McShen [EMAIL PROTECTED] wrote: then, should i do this? --- $query = "SELECT * FROM refer ORDER BY hits desc LIMIT $i,$end"; Is $end set at this point? Also, if you always want to display 15 records, this could just be LIMIT $i, 15. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Which is better coding style...
On 19 Apr 2001 14:08:13 -0700, ..s.c.o.t.t.. [gts] [EMAIL PROTECTED] wrote: OOooo... it drives me nuts when i see beginning brackets on seperate lines ;) i like to start brackets on the same line as the statement and finish them on a line of their own. Very strong agreement here. I think a lot of it depends on your environment. Some have syntax highlighting and, better yet, syntax highlighting which will prominently mark unbalanced braces, brackets, etc. Also very nice are things like a brace-matching hotkey or options to highlight the matching open character when you close it. If you have all of these tools to help show syntax, I don't think you need as help from the source formatting. (The only times I've liked having them on separate lines is when I've been working with an editor which lacks this) It also helps to properly indent things. I think code like this makes it pretty easy to see which code is in which block: if () { ... if () { if () { // Do something } else { // Do something else } } } else { ... } This is one thing I've always liked about Python. Forcing people to indent consistently is a little harsh but it does have the advantage of making strange code easier to decipher. (it drives me nuts to see "} else {" also) Here, I have to differ - using anything else makes me itch. -- "Any sufficiently accurate worldview is indistinguishable from cynicism" -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] converting DATETIME to a readable date.
On 14 Apr 2001 17:31:02 -0700, DRN [EMAIL PROTECTED] wrote: $date = $row["date"]; $new_date = date("l, j M Y, G:i:s", strtotime($date)); ~~ but I cannot get this to work :(, I get an "unexpected error in date()" At a guess strtotime() is choking on the format MySQL used to return the date, which would lead date() to fail as well. The best way of handling this is to eliminate the need for your program to worry about the day formats. Modify your mysql query so that instead of "SELECT date" you have something like "SELECT UNIX_TIMESTAMP(date) AS date". Then you can simply use date($row["date"]) directly. Alternately, you could use MySQL's date formatting function to return the desired format directly. In either case, you'll save a great deal of trouble by avoiding the need for PHP and MySQL to be parsing each other's human-readable date formats. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] removing slashes from template file
On 12 Apr 2001 19:20:44 -0700, Franklin Hays [EMAIL PROTECTED] wrote: Any ideas? I have tried using stripslashes() in the 'script' above but get errors. Is there something unique to the php cgi I am missing? Something else? Check your magic quotes settings on both systems using phpinfo(). I bet magic_quotes_runtime is set on in your provider's settings but not your development system's php.ini. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Commercial sites that use PHP
On 10 Apr 2001 06:52:07 -0700, Phil Labonte [EMAIL PROTECTED] wrote: Can anyone send me a list of large commercial web sites that use PHP? Cribbed mercilessly from a number of sources: http://gateway.digitaria.com/~chris/php/sites.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] PHP and MD5 passwords?
On 4 Apr 2001 08:06:06 -0700, Chris Hutton [RaptorNet] [EMAIL PROTECTED] wrote: How would I go about using PHP to take an entered password, and check it against an encyrpted MD5 password in a database or flat-file? retrieve the record you'd like to check and compare it to md5($UserEnteredPassword). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] PHP with Win2k or Linux
On 4 Apr 2001 19:12:52 -0700, Frank K [EMAIL PROTECTED] wrote: Does anyone know is there are advantages to running linux while = developing php? I just would like to know if there is anything special = to installing and developing on linux before I move from Win2k?? Three advantages: - it's free - it will more closely follow your production server's environment, which can be handy for more involved things and, of course, any custom extensions you have developed. This is also nice to prevent little problems like different-case links to files which work fine on case-insensitive filesystems. - it's a native environment - the Win32 port isn't as mature, so you may run into problems (e.g. 4.0.5RC1 on my Win32 Apache setup dies nastily if you use MySQL). Also, since IIS is extremely feature-poor compared with Apache, you may need to run Apache. If you have to install all of this Unix software, you might just want to do it under Unix in the first place. Two disadvantages: - Fewer clients - if you need to support, say, IE, you need a Windows box to test with. This becomes worse when you're dealing with things like Flash. - You need to know a lot more Unix. I personally find Unix much easier to use than NT but someone without my Unix background would disagree. My preferred environment is a Unix (Linux, OpenBSD) server running Samba and a WinNT/2K client. This allows you to use Unix as a server and still test with all of the Win32 software a modern developer needs to worry about. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] redirecting without headers or meta tags or javascript
On 3 Apr 2001 06:26:47 -0700, Justin French [EMAIL PROTECTED] wrote: (3) Use output buffering huh? appreciate mroe on this... put ob_start() at the top of your page and ob_end_flush() at the bottom. PHP will store all of the output instead of sending it to the browser. If you put a header("Location: foo"); exit; somewhere, that output will never be set. (Take a look at the ob_* functions in the manual when you have a spare moment - there's some pretty cool things you can do with them, particularly if you use the gz handler to compress pages on the fly.) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] measuring cpu time
On 3 Apr 2001 19:29:14 -0700, Brian Hardwick [EMAIL PROTECTED] wrote: Im trying to optimize some php/mysql code. Does anyone know a way to measure the amount cpu time a php script consumes? Check out the POSIX functions - in particular the posix_times() function, which not only shows CPU time but also breaks it down into user (PHP's code) time and system (time spent by the kernel) time. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Not important - Simple question about microsec()
On 3 Apr 2001 20:31:28 -0700, SED [EMAIL PROTECTED] wrote: I think the latter part of the value is Unix-time in sec (right?), but what does the former part say like: 0.25576700 ?!? For some reason, microtime() returns results backwards - the first part is the decimal portion of the second part. As for the time being returned in properly, are you by any chance running this on Windows? I seem to recall reading something in bugs.php.net about that when I ran into some benchmark problems with code which worked properly on Unix and returned results like you showed on Windows ("Wow! This sure is a fast computer - it finished before it started!"). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Sneaky solution
On 3 Apr 2001 21:02:34 -0700, Les Neste [EMAIL PROTECTED] wrote: Correct me if I'm wrong, but isn't it possible to fake the referrer? Quite easily, even when doing it by hand using telnet or netcat. This may not matter for your application -- are you writing a financial app or a personal portfolio? -- but if you really need to authenticate the source of data that comes from some other IP address (as is the case with a web browser) then you're into PGP keys and signed certificates. s/PGP/SSL/. Although it's not anywhere near as common, SSL supports client certificates. Normally, we only see the server certificate which lets you know who the server is - client certificates allow the server to do the same thing. I've been meaning to setup a demo of this for awhile, but you should be able to read the verified certificate info from the webserver environment, which makes controlling access rather simple for your scripts. The downside is the need to get client certificates on every client system, which is expensive and inconvenient. While setting up your own CA eliminates the former concern, there's little which can be done about the latter. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Ming and flash detection
On 2 Apr 2001 07:58:42 -0700, Jason Stechschulte [EMAIL PROTECTED] wrote: // This movie simply redirects to the appropriate page. $m-add(new SWFAction("getURL('$thisURL', ''); stop();")); I added code to write $thisURL to a file so I could see if it is getting passed correctly, and it is. So there must be a problem with the movie somewhere. In the getURL() function, I have tried many different things for the second argument. _self, _parent, _top. None of these makes any difference. Anyone have any ideas I could try?? Try _level0 - that's what you'd need to replace the current movie. Alternately, you can avoid needing to load Flash at all - use JavaScript to iterate over the plugins array on Netscape and use VBScript with an On Error handler to instantiate the Flash ActiveX control - if it fails, your VBScript can assume Flash isn't installed (which is the sane default). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] form
On 31 Mar 2001 20:33:56 -0800, LDL Enterprise [EMAIL PROTECTED] wrote: Could someone please give me a clue. I have a input type=text form that pulls the quantity from a mysql database. I want the user to be able to update the quatity by just entering the new quantity and when they unfocus on the text box it will automatically update without pressing a submit button. You could use JavaScript to have the form submit OnBlur, but that's going to be pretty slow and annoying - consider what would happen if the user is entering several fields and clicks on another field, intending to come back and change it... What effect are you trying to achieve? Just reducing the number of clicks needed to submit a form? If so, some browers will submit the form when you hit the enter key while in a text field, which might have the effect you're looking for without requiring any coding. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] ereg
On 31 Mar 2001 21:07:59 -0800, Michael Hall [EMAIL PROTECTED] wrote: I'm using the following expression to check input strings: if (!ereg("^[[:alnum:]_-]+$", $string)) { get outta here! } This works fine except for when a string has spaces, as in text. What do I need to add to the expression to handle spaces (internal, not at the beginning or end). if (!ereg("^[[:alnum:]_- ]+$", $string)) { get outta here! } Check out the regular expression documentation or "Mastering Regular Expressions" over at ora.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] form
On 31 Mar 2001 22:03:54 -0800, Sean Weissensee [EMAIL PROTECTED] wrote: I have a shopping cart system I wrote which display several detail lines of items purchased, at the moment if the user changes a quantity they have to manualy click a link to recalulate the total, I would like this to happen as soon as the user tabs of the qty field. Use an OnBlur() handler and some JavaScript. However, you'll still need to do the calculations on the server to prevent cheating because if you want to support older browsers, you'll need to put the total in an INPUT TYPE="TEXT" field. Your PHP code could generate a JavaScript function ("recalc()") that would check each item and a cost * quantity to update the subtotal; when they hit submit, you'd need to do the same check in PHP to be sure of getting an accurate result. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Benchmarks
On 16 Mar 2001 04:39:06 -0800, Phil Driscoll [EMAIL PROTECTED] wrote: http://www.perlmonth.com/features/benchmarks/benchmarks.html?issue=4id=9351 4159 A performance comparison of various web scripting languages. PHP does rather well! It's also important to note that their comment that PHP doesn't cache compiled scripts and thus may not scale as well isn't completely true. The default install doesn't, but you can use one of several products (Zend Cache, Afterburner and a third whose name escapes me) to ensure that your scripts are cached. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] SVG Scripting
In php.general, you wrote: I know (at least the claim) that PHP can do marvelous thing to Flash files (with libswf), presumably including "streaming" realtime feedback of a script's action. It can't. PHP can generate Flash files directly (and using Ming - it beats libswf handily - http://www.opaque.net/ming/) but cannot edit existing movies. Since Flash allows you to load other Flash movies on the fly, you can mix static and dynamically generated Flash movies into the same presentation. As an example, you might have a master interface which is carefully hand-tuned in Flash/LiveMotion and has specific areas where generated movies are loaded. Flash does offer the ability to load content from URLs, but not in a live fashion - you need Director / multi-user server for that. Since Director allows Flash objects, you could theoretically have your Flash interact with the server by sending communications through Director / MUS, but I haven't personally done this. Since Flash / Director performance will already be pathetic, introducing any sort of network overhead would probably reduce it to comical levels. Is there an existing library for SVG manipulation? Are there enthusiasts for this option? SVG files are XML, which means you can use either of PHP's native XML parsers to do low-level manipulation (the entire SVG + scripting option should be very similar to conventional HTML + CSS + JavaScript work). If you're doing much at all, I'd strongly recommend you develop the appropriate function libraries / objects using the underlying primitives. I'm doing this with some extensive Flash generation and it greatly civilizes things - you cannot plan ahead too much with this. If SWF is indicated, is there any known difference so far as libswf is concerned between Flash and LiveMotion generated SWF? libswf / ming can't edit existing files; if you're using LoadMovie, either one should be identical. On thing which may be an issue is Action Script - if LiveMotion doesn't support it or causes problems "navigating" the action script variable hierarchy, getting multiple movies to cooperate would be difficult and kludgy. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Statistics function
On 14 Mar 2001 22:11:10 -0800, Rick St Jean [EMAIL PROTECTED] wrote: All through this process there is a live thread between your browser and the server. unless you send a cancel. One minor addition - the connection will close when you hit cancel but the PHP code can continue running if you choose. This can be quite handy if you want to make sure your code can finish running or clean up nicely before quitting. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Statistics function
On 14 Mar 2001 21:39:05 -0800, Lauri Vain [EMAIL PROTECTED] wrote: How does the behind the scenes work by PHP exactly go? Does the PHP thread remain active so long as the information is sent to the visitor? Or will PHP parse the code and send it to Apache which will send the data to the user itself? 1 Apache receives the request and determines that it's a PHP script. 2 PHP parses your code 3 PHP executes your code 4 PHP passes output back to Apache 5 Apache sends output to the browser (optionally through things like SSL) 6 Apache finishes request (e.g. logs it, closes a non-persistent connection) The catch is that steps 4/5 may repeat - this depends on your output buffering setup. PHP can wait and send everything when the script finishes, send output in blocks or send every output from each echo/print immediately. (PHP can also do things like compress that output on the fly, but that's a separate conversation) The reason that I'm asking this is I'm writing a statistics add-on for one of my sites and was wondering whether the code below would give the time in which PHP parses the code or in which the data gets streamed to the user. You'd get the time needed to read the file and either send it or add it to the output buffer (depending on your output buffer config as mentioned above). By the time your code is executed, PHP will have already parsed your script (with the exception of things like conditional / variable include()s and require()s), so you'd only get the time required to execute the code, not parse it. If you want to get round-trip times including transmission to the user, you'd need to have some way of getting the user's browser to record a second request, which introduces a lot of potential variables. It might be interesting to see how something relying entirely on client-side calculation like the code below would compare with other approaches (e.g. Header("Location: measure.php?start=" . time()) where measure.php just does $elapsed = time() - $start). It should remove almost all of the server-side latency and, in theory, would give some reasonable indication of how long it takes to transfer a file over the intermediate network connection, which would give you a reasonable idea of available bandwidth. (Disclaimer: completely untested code written just now which has never been seen by anything other than vi. Caveat programmer.) html head script lang="javascript" Start = new Date(); function record_elapsed() { Now = new Date(); Elapsed = Now.getTime() - Start.getTime(); recordTimeImg = new Image(); recordTimeImg = "recorder.php?Elapsed=" + Elapsed; } /script ? flush(); /* send this as quickly as possible */ ? /head body OnLoad="record_elapsed();" ... a fair amount of text / HTML ... /body /html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Two Way Encryption
On 13 Mar 2001 03:40:30 -0800, Joe Njeru [EMAIL PROTECTED] wrote: I'm looking for a two way encryption function that I can use to encrypt a cookie value. I have had experience with MD5 but its one way. Is there one I can use with a key in php? Check out the mcrypt extension for conventional cryptography. If you need public key encryption, someone produced an extension which uses OpenSSL not all that long ago. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] MAIL And PHP Question
On 12 Mar 2001 21:47:44 -0800, James Lamb [EMAIL PROTECTED] wrote: Can PHP talk directly to the SMTP server, i know that there is a mail() function but this cannnot specify the reply-to and from addresses easily. Yes, but it's less work to specify reply-to and from using mail(). If you do want to do this, PHP's socket library allows you to directly connect to an SMTP server and send the appropriate commands. There are several PHP classes available which do this - search your favorite PHP code repository - if you don't want to become a lot more familar with RFC 822. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] date
On 11 Mar 2001 10:25:25 -0800, FredrikAT [EMAIL PROTECTED] wrote: I have 2 dates... $start = "20010101"; $end = "20010312"; Use mktime() (http://www.php.net/manual/en/function.mktime.php) on those strings to convert them into Unix timestamps: $start_time = mktime(0,0,0, substr($start, 6, 2), substr($start, 4, 2), substr($start, 0, 4) ); // mktime( hour, minute, second, day, month, year) Since a Unix timestamp is just the number of seconds since a starting point, you can get the elapsed number of seconds by substraing $start_time from $stop_time; divide that by 86400 and you'll have the number of days. You could also use the Calendar extension if you have that installed, since it allows you to covert from several calendar systems into Julian Day counts, which could be subtracted similarly. (See http://www.php.net/manual/en/ref.calendar.php) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Sending pretty email
On 11 Mar 2001 10:57:32 -0800, Michael Geier [EMAIL PROTECTED] wrote: So don't refrain from doing it because some people say it shouldn't be done for one reason or another. Simply fix those reasons so they don't know any different. I'll second this - while I personally consider HTML email a waste of time[1], a lot of people like it and it does open up some nice possibilities. The key is remembering that if you're going to do it, you need to do it right - sending the proper multi-part mime headers, providing alternatives for people who can't use HTML[2] and generally just being polite. When presenting this to managers and/or clients, point out that this maximizes the number of people who can read their messages - they should grasp the whole "block potential customers = fewer sales" concept quickly. [1] For reasons having more to do with security and the crimes against good design committed by a few; an email client which gave the user the kind of control a browser like Opera does would be a lot more tolerable. [2] It's not those of us using text-based email clients, either. Think of wireless device users or people working at large corps which installed software to disable anything remotely dynamic in incoming emails. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] How to tell if client has cookies turned off?
On 6 Mar 2001 07:53:46 -0800, kevin1 [EMAIL PROTECTED] wrote: How can I tell reliably if someone has cookies turned off? Set a cookie on your site (perhaps the homepage?) and use code like this: if (!empty($UserHasCookies)) { echo 'Whew - you do have cookies'; } The idea is to set your code to assume that cookie support is disabled unless it finds a cookie saying otherwise. That way it'll fail safely if someone either doesn't have a cookie or their browser discards the cookie halfway through. This may seem silly, but some people get *really* paranoid about cookies. Combined with the increasingly good cookie management in modern browsers and just about anything is possible - this is in fact the major shortcoming to code like the above - it's possible for someone to accept one cookie and deny another, so just being able to set a cookie once does not mean that you will be able to set another. Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Auto Prepend/Append
On 6 Mar 2001 08:13:00 -0800, Boget, Chris [EMAIL PROTECTED] wrote: Is it possible to use the auto prepend/append directives to prepend/append particular files only to files with a particular extension? I don't believe you can do this directly with PHP but you probably can with Apache: Files *.html php_value prepend_file "foo.php" /Files -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] stumped on mailing a complete page
On 3 Mar 2001 17:17:15 -0800, Brett [EMAIL PROTECTED] wrote: I want to send a confirmation email upon receiving an order, and would like to send the page that I display on the browser to the user. ob_start(); // do something mail('confirm@somewhere', 'confirmation', ob_get_contents()); ob_end_flush(); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] NETSCAPE Screws QUERY STRING!!!!!!
On 4 Mar 2001 04:17:18 -0800, Thomas Edison Jr. [EMAIL PROTECTED] wrote: The Internet Explorer converts the spaces in a query string into it's hexadecimal value of "%20" automatically, but netscape is not doing so. It's not reading the space and thus not displaying the page at all and giving the HTTP error 400. Use urlencode() or rawurlencode() when generating those URLs. The standards don't allow raw spaces in a URL string, so you'll need to encode your data when generating a link to work with browsers other than IE. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Converting String to Variable
On 3 Mar 2001 08:02:16 -0800, Randy Johnson [EMAIL PROTECTED] wrote: Is there anyway to convert a string to a variable example $str="monday"; I would like to then do this: $monday="blah"; extract() does something like that for arrays. There's no way to write the code the way you have it, but you could use this syntax, which is equivalent: $$str = "blah"; $GLOBALS[$str] = "blah"; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Developer certifications
Does anyone know of a company which is offering or planning to offer PHP developer certifications? Arguments against certification programs aside[1], there are a lot of companies which prefer certified developers, even to the point of assuming a project done in ASP will be better than the same thing done in PHP simply because the ASP developers are Microsoft certified. While this seems like an interesting sideline for a company like Zend, I'm also somewhat curious about whether an "Open Source" test could be developed. It'd certainly have to be quite different from normal tests and that move away from easily memorized answers would probably be a very good thing. [1] We've all heard them before. I'm personally in favor only of certifications like certain devilishly hard Cisco exams which measure more than multiple-choice memory. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Temporarily turning off magic quotes?
On 25 Feb 2001 09:15:08 -0800, Philip Olson [EMAIL PROTECTED] wrote: ini_set ('magic_quotes_gpc', 'off'); This will not work, ini_set cannot mess with magic_quotes setting, More precisely, it can change the setting but your PHP code will be executed after the magic quotes work has already completed. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Unwanted Characters
On 24 Feb 2001 21:31:33 -0800, Clayton Dukes [EMAIL PROTECTED] wrote: How do I remove unwanted/unprintable characters from a variable? $sometext =3D "Th=C0e c=D8ar r=F6=F8an over m=D6y dog" needs to be filtered and reprinted as: "The car ran over my dog" Strip everything which isn't in the list of allowed characters: eregi_replace("[^[:alpha:]]", "", $sometext) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] isset()
On 25 Feb 2001 00:01:30 -0800, Mark Maggelet [EMAIL PROTECTED] wrote: On Sat, 24 Feb 2001 17:51:07 +0100, Christian Reiniger ([EMAIL PROTECTED]) wrote: On Saturday 24 February 2001 17:18, PHPBeginner.com wrote: in my preceding email I've written: if($var!='') will fix your all your worries without an intervention of a strings function. Except that it will throw a warning in PHP4 if $var is not set. = isset () should be used. man, this is like the thread that will not die. isset() will return true for an empty string, which is not what he wants. the right thing to do is use if((isset($var))($var!="")) Isn't this a bit more legible: if (!empty($var)) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Plugin Detection with PHP?
On 25 Feb 2001 04:37:21 -0800, Andy Clarke [EMAIL PROTECTED] wrote: Is there a way to use PHP to tell whether a user's browser has a particular plugin? ... I know that this can be done using Javascript, but as this can be turned off by the user etc, it seemed as though it would be more reliable to do it server side (if it is possible). No, it's not possible. The safest approach is to assume the user doesn't have a plugin and then use JavaScript to enable a plugin. In certain cases, there are plugin specific tricks you could play in a detection script (e.g. QuickTime allows a QTSRC attribute which overrides the SRC value - SRC="somefile" QTSRC="plugin_check.php?HasQT=1filename=somefile"). For the rest, you'll need to use JavaScript. This is complicated by the way Microsoft broke Netscape's plugins object - on netscape, you can iterate over that list very easily. IE has the object, but it's always empty. (You can use VBScript to attempt to create an object of that class and then trap the error if it fails, but that's not particularly elegant) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Simple String Replace Question
On 25 Feb 2001 10:34:27 -0800, Jeff Oien [EMAIL PROTECTED] wrote: I would like to get rid of \n characters unless there are two or more in a row. So for example if there The Perl-compatible regular expressions support lookahead and look behind: $str = 'abcdefabcaadd'; echo "$str\n"; $str = preg_replace("/(?!a)a(?!a)/", "-", $str); echo "$str\n"; will display this: abcdefabcaadd -bcdef-bcaadd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Simple String Replace Question
On 25 Feb 2001 14:37:02 -0800, Jeff Oien [EMAIL PROTECTED] wrote: On 25 Feb 2001 10:34:27 -0800, Jeff Oien [EMAIL PROTECTED] wrote: I would like to get rid of \n characters unless there are two or more in a row. So for example if there The Perl-compatible regular expressions support lookahead and look behind: $str = preg_replace("/(?!a)a(?!a)/", "-", $str); Man, that went right over my head. Is there a description of how this works anywhere? Thanks for help in any case. The Regular Expression part of the online PHP manual has a lot of information (http://www.php.net/manual/en/ref.pcre.php) but it does tend to assume you already know what you need to do. Basically, the regular expression in there matches any "a" where the character before isn't an "a" (?!a) and the character after isn't an a (?!a). Any matched characters are replaced with hyphens. For your needs, '/(?!\n)\n(?!\n)/m' should work (the /m turns on multi-line support, which is necessary since we're working with line breaking characters). Note that you'll need to escape those backslashes in PHP if you use doublequotes. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Pop-up warning dialog box
On 18 Feb 2001 20:54:16 -0800, Edith Lai [EMAIL PROTECTED] wrote: If i want to validate a form and check for empty input which then will produce a pop up warning dialog box, what should i do? Read up on your JavaScript. And consider whether this is really a good idea - many people find it annoying. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Parse WML to PHP?
On 8 Feb 2001 06:24:20 -0800, Kato Strandjord [EMAIL PROTECTED] wrote: How is it possible to parse a WML strin variable with a value="SO480", and parse over to a PHP strin variabl , so you can use it to in a PFP function. I get a error messages in M3gate WAP emulator, an UP SDK emulator telling me this"unsupported content-type: text/html" Yes. In fact, WML requests will behave just like normal HTML form requests. The error you are receiving probably means that you need to set the mime-type for the page you are returning: header("Content-Type: text/vnd.wap.wml"); As a side note, consider testing your pages in Opera. Opera supports WML reasonably well and has the side-benefit of being much easier to work with. If you get an error, not all of the WAP emulators will show you the actual error message. Many of them also have an annoying habit of caching pages even if you ask them to clear the cache, which makes development rather more tedious than it needs to be. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] MySQL --- OR in a select statement ???
On 5 Feb 2001 21:27:13 -0800, Dallas Kropka [EMAIL PROTECTED] wrote: SELECT first_name FROM admin_table, user_table WHERE userNum = 1000 The info will only be in one or the other but what (if any) is the correct syntax? You mean something like SELECT first_name FROM users LEFT JOIN admin_table on users.userNum = admin_table.userNum LEFT JOIN user_table on users.userNum = user_table.userNum WHERE admin_table.userNum=1000 OR user_table.userNum = 1000 ? (Disclaimers: There's probably a more efficient way of doing this. I've just finished an epic battle with MS SQL Server's poxy excuse for full-text searching and don't feel list spending any more time playing around with SQL statements this evening.) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] solution
On 5 Feb 2001 23:31:17 -0800, andreas \(@work\) [EMAIL PROTECTED] wrote: a 404 php-file which extracts the path and generates a page for that out of mysql or is there a better solution out there ? This approach can work and, properly done, work fairly well. However, a more elegant approach might be using mod_rewrite on Apache. You could write a regex that would convert addresses of the form /~username into /users/homepage.php?User=username internally. This would also have the advantage of leaving your existing 404 handling unchanged. Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Server VS Client script validation
On 29 Jan 2001 13:38:20 -0800, kaab kaoutar [EMAIL PROTECTED] wrote: What's best ? using client script while validating form inputs(javasript or vbscript) or using php for validating! The only acceptable approaches must be server side - otherwise you've just decided that security and reliability don't matter. If you want to present friendlier errors, you may also choose to add additional client-side scripting but beware that many people, myself included, consider multiple Javascript popups worse than well-designed server-side validation. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] IMAP - attachment-information
On 23 Jan 2001 06:36:02 -0800, Jochen Kchelin [EMAIL PROTECTED] wrote: How can I extract the information about email attachments using the IMAP-functions? Use imap_fetchstructure(). It returns a pretty large array, so you'll probably want to spend some quality time with the documentation and print_r() getting all of the details. One nice thing if you're making a webmail interface is that you won't need to worry too much about mime-types - those can be passed through to the browser, which can figure out anything from text/plain to video/quicktime. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Maximum execution time
On 23 Jan 2001 07:47:03 -0800, Liam Gibbs [EMAIL PROTECTED] wrote: Can anyone tell me how to up the max. execution time in PHP? I know it's = been said before, but I can't remember how it's done. You can change the value max_execution_time in php.ini, or your apache configuration files. If you only want to increase or disable the limit in a single script, try set_time_limit(). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Internals of Session files
On 18 Jan 2001 08:28:50 -0800, Eivind Trondsen [EMAIL PROTECTED] wrote: Can someone shed any light on the internals of the session file format? Is it documented somewhere? We are building a system to log user paths, and are thinking of harvesting PHP session objects to accomplish this. Has someone done the same? First, you probably want to have your code log to a database instead. The session files won't have the context information you want. Alternately, just turn on mod_usertrack in your Apache config and any decent log analysis program will be able to do that for you. However, if you do want to decipher those files, note the similarity between the contents of one and the output of serialize($HTTP_SESSION_VARS). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] CSS and PHP
On 18 Jan 2001 08:58:45 -0800, Brandon Orther [EMAIL PROTECTED] wrote: I am making a script that creates a dynamic htm page. One of the many things that this script does is change the css. The problem I am having is that it doesn't seem to display the css when it is loaded through the web server. When I look at the source and save it as an htm file. It loads up perfectly. Has anyone ever had this problem before? PHP doesn't care about the bytes being sent, so there shouldn't be any special problems related to CSS. Have you verified whether or not any of what you expect is showing up in the generated HTML? At a guess, there's something slightly wrong in the generated code which is causing a display failure. If you're saving it through IE, some of the save options will have IE save it's internal parsed version (it's the same cause as the difference between View Source's code and View Partial Source's output), which could explain why that works. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] XML Parser is a bit strict
On 18 Jan 2001 14:28:16 -0800, Chris Lee [EMAIL PROTECTED] wrote: I dont know if you can use XHTML syntax in XML, I dont think it works like this, I think XML is more strict. XHTML *is* XML - it's just HTML reformulated so that a valid XHTML document can be parsed by a normal XML parser without using all of the special case rules an HTML parser needs. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] WML/WAP and PHP
On 16 Jan 2001 05:05:18 -0800, Rick Hodger [EMAIL PROTECTED] wrote: Here's a fun little thing I discovered, possibly a bug in PHP itself? To output a WAP page you must output a content-type header else the phone's browser won't recognise the page. Dead simple. Use: header("Content-type: text/vnd.wap.wml"); And all is well and good as long as you use echo/printf etc to output your page. The second you deviate out of PHP and back to HTML the content-type gets overwritten with a text/html, and so the page doesn't work. ASP used to be able to cope with this, is it a bug or something I'm doing wrong? Hmmm - you might need to start checking details of your configuration. I've had no problems doing a lot of WML work in PHP and it's always correctly returned the content-type I've set using header on 4.0.3pl1 (OpenBSD) and 4.0.3 / 4.0.4 (Win32). Do you have anything like output buffering turned on? I doubt that's causing the problem as I use output buffering semi-frequently[0] but it can't hurt to check. [0] neat hack - use ob_content_length() to tell when you've output almost as much data as the phone can handle (find this by doing a browser detect) so you can stop looping over a recordset and emit the Next/Prev page headers instead). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Refresh particular browser while updating another browser
On 13 Jan 2001 23:45:58 -0800, Hendry Sumilo [EMAIL PROTECTED] wrote: I would like how to refresh particular browser with a new updated data when the user has updated it at another browser. Purpose of doing this is particular user won't user overwrite new value if he uses another browser to update it. I don't think there's a good way of doing this sort of something strange with a Java applet. The easiest way of doing this would be to include a timestamp row in your database table; the edit form would be generated with the current value of that field. When they submit the form, your code can check to see if the time stamp that was current when the form was created is still valid and either process the request or give the user some sort of "Overwrite newer data (y/n)" prompt. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] BIG site names using PHP?
"Monte Ohrt" [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Can anyone give me a list of big named sites (or point me to a list) that use PHP? Basically, site names that marketers can recognize as "big names", or very well known. I haven't had time to update it recently, but I put a list up at http://gateway.digitaria.com/~chris/php/sites.html. It draws from the PHP.net sites list, Zend.com's case studies and submissions from various PHP users, with a focus on large sites - either big names or lots of traffic. Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]