[PHP] mailparse or imap* ?
I need functions to parse an email and I've been using mailparse sofar. Works pretty well, except it has a couple of shortcomings - will only retrieve last of the Received:-headers, does not decode quoted-printable body-parts, does not decode RFC2047-encoded filenames in COntent-Disposition. So I've been having a closer at imap* - but it's just not very clear if imap* will for instance deal with a single email available as a string? mailparse does exactly what I need, except the shortcomings listed are becoming a problem. any suggestions? (other than fixing mailparse :-) -- Per Jessen, Zurich Let your spam stop here -- http://www.spamchek.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MultiSelect List Box in PHP
Hi. I was just wondering where I can find info on how to use a MultiSelect List Box with PHP? I need to use it with MYSQL 5.0.0, PHP 4.3.9, and windows XP sp2. Any help/leads would be greatly appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: image files - upload and managment
Robby Russell wrote: I tend to stick as much in the database with strict restraints. I know that in my database, an image cannot be deleted unless several rules are met. In the filesystem, a number of things could accidently delete the wrong file. I treat my images as another piece of data and that data is kept there by constraints. If you don't feel you can protect your filesystem from accidental deletions, are the images *really* any safer stored in a database which obviously will use the filesystem as storage? /Per -- Per Jessen, Zurich Let your spam stop here -- http://www.spamchek.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] MultiSelect List Box in PHP
Sorry that doesn't do me a huge bit of good since I have no clue how to write java in the first place. Does anybody know where I can find or get an example of php code that shows how to get all the selected items from a multiselect listbox and loop through them printing them on the screen?? -Original Message- From: Eric Lee [mailto:[EMAIL PROTECTED] Sent: Sunday, October 31, 2004 3:06 AM To: Andy B Subject: Re: [PHP] MultiSelect List Box in PHP it's just likes you used in normal html javascript, but the code that generated to control the ui are now moved to server-sided. :) On Sun, 31 Oct 2004 01:33:13 -0500, Andy B [EMAIL PROTECTED] wrote: Hi. I was just wondering where I can find info on how to use a MultiSelect List Box with PHP? I need to use it with MYSQL 5.0.0, PHP 4.3.9, and windows XP sp2. Any help/leads would be greatly appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Eric Lee -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP in CGI ....php.in
where did you place your php.ini? In the root of my application in www. /home/mydomaine/www Thanks, Christian, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MultiSelect List Box in PHP
-[ input.html ]-- html form action=input.php method=post select name=select[] multiple option value=1one/option option value=2two/option option value=3three/option /select input type=submit value=submit name=submit /form /html -[]-- -[ input.php ]-- ?php print_r($_POST); ? -[]-- -[ output ]-- Array ( [select] = Array ( [0] = 1 [1] = 2 ) [submit] = submit ) -[]-- Above output is with #1 and #2 selected, and #3 not selected. Easy, huh? - Tul Andy B wrote: Sorry that doesn't do me a huge bit of good since I have no clue how to write java in the first place. Does anybody know where I can find or get an example of php code that shows how to get all the selected items from a multiselect listbox and loop through them printing them on the screen?? -Original Message- From: Eric Lee [mailto:[EMAIL PROTECTED] Sent: Sunday, October 31, 2004 3:06 AM To: Andy B Subject: Re: [PHP] MultiSelect List Box in PHP it's just likes you used in normal html javascript, but the code that generated to control the ui are now moved to server-sided. :) On Sun, 31 Oct 2004 01:33:13 -0500, Andy B [EMAIL PROTECTED] wrote: Hi. I was just wondering where I can find info on how to use a MultiSelect List Box with PHP? I need to use it with MYSQL 5.0.0, PHP 4.3.9, and windows XP sp2. Any help/leads would be greatly appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Eric Lee -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] MultiSelect List Box in PHP
You can use this to work with. It's something I made some time ago, so it's probably not the most optimal solution, but it gets the job done... In this case it builds parameters for a SQL query, but it's easily modified to suit your needs. The reason it's a 'for' loop and not a 'foreach' is simply to make it simpler to keep track of how many items there IS in the list, so that the OR part of the SQL query gets built correctly. // load field list [multiselect box] from $_POST $fields = $_POST['fields']; // walk through all fields and build WHERE clause for ($i = 0; $i count($fields); $i++) { if ($i 0) { $addtoquery .= ' OR '; } switch ($fields[$i]) { case 'nick': $addtoquery .= `nickname` LIKE '%$search%' OR `akanick` LIKE '%$search%'; break; case 'real': $addtoquery .= `fname` LIKE '%$search%' OR `lname` LIKE '%$search%'; break; case 'email': $addtoquery .= `email` LIKE '%$search%'; break; case 'icq': $addtoquery .= `icq` LIKE '%$search%'; break; case 'aim': $addtoquery .= `aim` LIKE '%$search%'; break; case 'msn': $addtoquery .= `msn` LIKE '%$search%'; break; case 'yim': $addtoquery .= `yim` LIKE '%$search%'; break; } } // end for - fields builder The accompanying part of the form looks like this (don't ask why this is done with a for loop, guess we had about those when I did it): td align=left valign=topSearch in:br select name=fields[] id=fields size=4 multiple ?php $fieldarray = array('nick','real','email','icq','aim','msn','yim'); $fieldnames = array('Nickname','Real name','Email','ICQ','AIM','MSN','YIM'); for ($i=0; $i count($fieldarray); $i++) { echo('option value='.$fieldarray[$i].''); if (! empty($_POST['fields'])) { foreach($_POST['fields'] as $field) { if ($fieldarray[$i] == $field) { echo(' selected'); } } } else if ($fieldarray[$i] == 'nick') { echo(' selected'); } echo(''.$fieldnames[$i]); } ? /select/td FWIW Rene At 09:21 31-10-2004, Andy B wrote: Sorry that doesn't do me a huge bit of good since I have no clue how to write java in the first place. Does anybody know where I can find or get an example of php code that shows how to get all the selected items from a multiselect listbox and loop through them printing them on the screen?? -- Rene Brehmer aka Metalbunny If your life was a dream, would you wake up from a nightmare, dripping of sweat, hoping it was over? Or would you wake up happy and pleased, ready to take on the day with a smile? http://metalbunny.net/ References, tools, and other useful stuff... Check out the new Metalbunny forums at http://forums.metalbunny.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MultiSelect List Box in PHP
Would be easier if you didn't send it as HTML ... bad boy you Rene At 10:00 31-10-2004, M. Sokolewicz wrote: -[ input.html ]-- one two three -[]-- -[ input.php ]-- ?php print_r($_POST); ? -[]-- -[ output ]-- Array ( [select] = Array ( [0] = 1 [1] = 2 ) [submit] = submit ) -[]-- Above output is with #1 and #2 selected, and #3 not selected. Easy, huh? - Tul -- Rene Brehmer aka Metalbunny If your life was a dream, would you wake up from a nightmare, dripping of sweat, hoping it was over? Or would you wake up happy and pleased, ready to take on the day with a smile? http://metalbunny.net/ References, tools, and other useful stuff... Check out the new Metalbunny forums at http://forums.metalbunny.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Matching *exact* string?
hello all I am foreach()ing through an array of ip addresses in a 'ban script' and have the following php code: foreach($ips as $ip) { preg_match(/$ip/, $_SERVER[REMOTE_ADDR]); $ban = TRUE; } This is great, but if 127.0.0 were in the ban list (for example) it would still produce a ban as it partially matches. How can I alter the above so that only *exact* matches are banned? Much thanks! -- Nick W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] beginnind and end of the week
I need to run a query using PHP/MYSQL. The query should be for a week. So if today is tuesday, the query should be from Monday to Sunday. How in in php I can know when the beginning and end of the week? TH -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Matching *exact* string?
Nick Wilson wrote: hello all I am foreach()ing through an array of ip addresses in a 'ban script' and have the following php code: foreach($ips as $ip) { preg_match(/$ip/, $_SERVER[REMOTE_ADDR]); $ban = TRUE; } This is great, but if 127.0.0 were in the ban list (for example) it would still produce a ban as it partially matches. How can I alter the above so that only *exact* matches are banned? If I've understood your question right: foreach($ips as $ip) { preg_match(/^$ip$/, $_SERVER[REMOTE_ADDR]); $ban = TRUE; } -- Per Jessen, Zurich Let your spam stop here -- http://www.spamchek.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Matching *exact* string?
Nick Wilson wrote: How can I alter the above so that only *exact* matches are banned? Using ^ and $ to mark the begin and end of the line. So try this /^$ip\$/ -- Bye, K http://www.ailis.de/~k/ (FidoNet: 2:240/2188.18) [A735 47EC D87B 1F15 C1E9 53D3 AA03 6173 A723 E391] (Finger [EMAIL PROTECTED] to get public key) signature.asc Description: OpenPGP digital signature
[PHP] Re: Matching *exact* string?
I cannot fathom why you would use preg_match for this. This will get an exact match... if ($ip == $_SERVER[REMOTE_ADDR]) { $ban = true; } Despite this being the worst idea I've ever seen, combined with a true lack of understanding, I wish you well. Nick Wilson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] hello all I am foreach()ing through an array of ip addresses in a 'ban script' and have the following php code: foreach($ips as $ip) { preg_match(/$ip/, $_SERVER[REMOTE_ADDR]); $ban = TRUE; } This is great, but if 127.0.0 were in the ban list (for example) it would still produce a ban as it partially matches. How can I alter the above so that only *exact* matches are banned? Much thanks! -- Nick W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Matching *exact* string?
Nick Wilson wrote: hello all I am foreach()ing through an array of ip addresses in a 'ban script' and have the following php code: foreach($ips as $ip) { preg_match(/$ip/, $_SERVER[REMOTE_ADDR]); $ban = TRUE; } This is great, but if 127.0.0 were in the ban list (for example) it would still produce a ban as it partially matches. How can I alter the above so that only *exact* matches are banned? Much thanks! I'd rather go with something like this: $banned_ips = array('123.123.123.123', '321.321.321.321'); // Banned IPs if (in_array($_SERVER['REMOTE_ADDR'], $banned_ips)) { die('Dude, you\'re banned!'); } But if I were you I'd choose something more advanced. -- Daniel Schierbeck Help spread Firefox (www.getfirefox.com): http://www.spreadfirefox.com/?q=user/registerr=6584 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] beginnind and end of the week
Hi Jerry, I dunno if i got what you want to do... But i would say : 1. Set a number to each day of the week (0 = sunday, 1 = monday, 6 = saturday) 2. Get the date of today, so you can get the number of the day : $noDay 3. Do you SQL request from ($noDay + 1) to ($noDay-1) (just need to test if $noDay 6, then you loop it to 0) Seb Jerry Swanson wrote: I need to run a query using PHP/MYSQL. The query should be for a week. So if today is tuesday, the query should be from Monday to Sunday. How in in php I can know when the beginning and end of the week? TH -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Matching *exact* string?
Daniel Schierbeck wrote: Nick Wilson wrote: hello all I am foreach()ing through an array of ip addresses in a 'ban script' and have the following php code: foreach($ips as $ip) { preg_match(/$ip/, $_SERVER[REMOTE_ADDR]); $ban = TRUE; } This is great, but if 127.0.0 were in the ban list (for example) it would still produce a ban as it partially matches. How can I alter the above so that only *exact* matches are banned? Much thanks! I'd rather go with something like this: $banned_ips = array('123.123.123.123', '321.321.321.321'); // Banned IPs if (in_array($_SERVER['REMOTE_ADDR'], $banned_ips)) { die('Dude, you\'re banned!'); } But if I were you I'd choose something more advanced. And yes, I'm aware of the fact that 321.321.321.321 isn't a valid IP... -- Daniel Schierbeck Help spread Firefox (www.getfirefox.com): http://www.spreadfirefox.com/?q=user/registerr=6584 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Matching *exact* string?
* and then Aidan Lister declared I cannot fathom why you would use preg_match for this. This will get an exact match... if ($ip == $_SERVER[REMOTE_ADDR]) { $ban = true; } Ahh.. an oversight. The script has been cobbled together from a previous version that supported partial matches. I'd just missed the obvious, thankyou ;-) Despite this being the worst idea I've ever seen, combined with a true lack of understanding, I wish you well. There is no need to be insulting. I doubt very much anyone thinks your a clever guy for acting like a twat on a mailing list. -- Nick W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Matching *exact* string?
* and then Per Jessen declared foreach($ips as $ip) { preg_match(/^$ip$/, $_SERVER[REMOTE_ADDR]); $ban = TRUE; } Great! - found a more sutable way but that's appreciated. Cheers! -- Nick W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Matching *exact* string?
* and then Daniel Schierbeck declared I'd rather go with something like this: $banned_ips = array('123.123.123.123', '321.321.321.321'); // Banned IPs if (in_array($_SERVER['REMOTE_ADDR'], $banned_ips)) { die('Dude, you\'re banned!'); } But if I were you I'd choose something more advanced. I think in_array() sounds like a great solution, wonder if it's faster than comparing each ooe with == ? thanks! -- Nick W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Matching *exact* string?
On Sun, 31 Oct 2004 12:58:04 +0100, Nick Wilson [EMAIL PROTECTED] wrote: I think in_array() sounds like a great solution, wonder if it's faster than comparing each ooe with == ? thanks! Benchmark it both ways and find out. Then post back and tell us. :) -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_select_db error
On Sun, 31 Oct 2004 00:19:12 -0400, Steven James Samuel Stapleton [EMAIL PROTECTED] wrote: Relevant information: Windows XP Pro SP2 PHP 5.0.2 MySQL 4.0.21-nt command line (not server-side) mysql_select_db returns no errors, and does not result in a mysql_error(), however, later queries result in errors suggesting that the switch failed: No errors, that's correct, but it does return a boolean value. So are you testing that return value? if( mysql_select_db('foo') !== true ) die('cannot select db'); //I'm having problems with mysql_select_db(DBNAME, resource) and $test = mysql_query(use DBNAME, $resource); You might want to try killing it right there with something like: $test = mysql_query() || die('bad query: ' . mysql_error()); //This results in no errors (I checked to make sure a true value was returned, mysql_query() returns a resource handler, not a boolean value. //and made sure mysql_errno() returned 0). if(!$test || mysql_errno()) { die(Error selecting DB); } //next, I'll make a query: mysql_query(create table foo ( bar int, morebar int ), $resource); if(mysql_errno()) { die(mysql_error()); } //I get //No Database Selected $test = mysql_query() || die('bad query: ' . mysql_error()); -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image files - upload and managment
On 30 Oct 2004 22:30:35 -, Matthew Weier O'Phinney [EMAIL PROTECTED] wrote: I have difficulty believing retrieving an image from a database will have similar speed performance as simply grabbing it from the filesystem... and if you're seeing a need to cache images on the filesystem anyways, that's certainly already an argument against it. Zend.com / Leon Atkinson benchmarked it. http://www.zend.com/zend/trick/tricks-sept-2001.php snip Conclusions Based on the test results, it seems that keeping files in a database cuts performance by approximately a third. It's hard to accept this penalty in light of any meager advantages offered by keeping the files in the databases instead of in a directory. /snip -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Reflection API, ReflectionMethod::invoke(object $obj, array $args)
Hi Sebastian Apologies for the random email, I wonder if you can take a look at a PHP5 aggregation issue I've run into. I've modified your aggregation/delegate example[1] trying to get it to work as there appear to have been API changes since that was written. Getting the method of the delegate object and invoking it seems fine, however it doesn't seem to be able to interpret params. When my delegated object's method is invoked, the $parameters arg appears to be ignored, although it correctly exists as an array of args when it gets to __call(). I've tried various formats for the args to invoke(), but can't get it to work - any ideas? I've modified the __call method of my class to look like this: function __call($methodName, $parameters) { $delegated = false; foreach ($this-aDelegates as $delegate) { $method = new ReflectionMethod(get_class($delegate), $methodName); $delegated = true; return $method-invoke($delegate, $parameters); } if (!$delegated) { PEAR::raiseError('Problem aggregating object', SGL_ERROR_INVALIDCALL, PEAR_ERROR_DIE); } } function addDelegate($delegate) { $this-aDelegates[] = $delegate; } Am running - winXP - PHP 5.02 - apache 2.052 thanks in advance, Demian Turner [1] http://www.zend.com/zend/php5/php5-delegation.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Matching *exact* string?
* and then Greg Donald declared On Sun, 31 Oct 2004 12:58:04 +0100, Nick Wilson [EMAIL PROTECTED] wrote: I think in_array() sounds like a great solution, wonder if it's faster than comparing each ooe with == ? thanks! Benchmark it both ways and find out. Then post back and tell us. :) Started to, but found I cant ;( I need to get the key from the array also (for use in a corresponding array) and with in_array() I couldnt find a way to do it. So, im just using == which is lightning fast anyway so no worries :) thanks again.. -- Nick W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Unable to validate XML with Schema if namespace is specified.
I am trying to validate an XML document, using DomDocument::schemaValidate() as in the following code: ?php $txt =EOT ?xml version=1.0? Article xmlns='http://www.example.com/xml' ItemItemText/Item /Article EOT; $dom = new DOMDocument(); $dom-loadXML($txt); if ($dom-schemaValidate(Article.xsd)) { print $dom-saveXML(); } ? The schema I am trying to validate against is: ?xml version=1.0 ? xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema; xs:element name=Article xs:complexType xs:sequence xs:element name=Item maxOccurs=unbounded/ /xs:sequence /xs:complexType /xs:element /xs:schema This produces the following output: Warning: Element Article not declared in E:\PHPTest\testXML.php on line 10 Warning: Element Article not declared in E:\PHPTest\testXML.php on line 10 If I remove the default namespace from the article tag, the XML validates correctly. I seem to recollect that namespace support is not fully implemented, so my question is, is this a bug, or just something not yet implemented, or is there an obvious blunder in what I am trying to do, which I cannot see. Best regards. . . Dusty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php command to open a url?
I've been looking around in the php documentation for a couple of hours now but can't seem to find any functions to open a url in the current browser window. Does php allow this? If so, could someone point me to a link? Basically what I'm trying to do is loop back in a login form until a user enters a valid username/password and then redirect to that user's personal info page. Thanks for any help Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php command to open a url?
header (Location: ./); exit; I use the above at the end of a authorization script, to direct back to a page. On Oct 31, 2004, at 12:03 PM, Ken Tozier wrote: I've been looking around in the php documentation for a couple of hours now but can't seem to find any functions to open a url in the current browser window. Does php allow this? If so, could someone point me to a link? Basically what I'm trying to do is loop back in a login form until a user enters a valid username/password and then redirect to that user's personal info page. Thanks for any help Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php command to open a url?
Ken Tozier wrote: I've been looking around in the php documentation for a couple of hours now but can't seem to find any functions to open a url in the current browser window. Does php allow this? If so, could someone point me to a link? Check out the PHP header() function, specifically the Location header: http://www.php.net/header -- Regards, Ben Ramsey http://benramsey.com --- Atlanta PHP - http://www.atlphp.org/ The Southeast's premier PHP community. --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: SOAP w/PHP 4
Dan Joseph wrote: Does PHP 4 support SOAP, or does something have to be added to it?? I know I've already given you some pointers on this, and hopefully you're on your way to playing with PHP and SOAP, but I noticed a potentially helpful article in the current issue of PHP Magazine. It's by Adam Trachtenberg and entitled Talking to eBay with PHP SOAP. Unfortunately, it's not available on-line, but you may be able to find a copy in a bookstore or order it from the PHP Magazine Web site. http://www.php-mag.net/itr/ausgaben/psecom,id,229,nodeid,112.html -- Regards, Ben Ramsey http://benramsey.com --- Atlanta PHP - http://www.atlphp.org/ The Southeast's premier PHP community. --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] MultiSelect List Box in PHP
I need to be able to print the selected items without the array... thing around it. so example would be if 1 and 2 are selected it would print: 1, 2 it's supposed to be formatted for the user... -Original Message- From: -{ Rene Brehmer }- [mailto:[EMAIL PROTECTED] Sent: Sunday, October 31, 2004 5:12 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] MultiSelect List Box in PHP Would be easier if you didn't send it as HTML ... bad boy you Rene At 10:00 31-10-2004, M. Sokolewicz wrote: -[ input.html ]-- one two three -[]-- -[ input.php ]-- ?php print_r($_POST); ? -[]-- -[ output ]-- Array ( [select] = Array ( [0] = 1 [1] = 2 ) [submit] = submit ) -[]-- Above output is with #1 and #2 selected, and #3 not selected. Easy, huh? - Tul -- Rene Brehmer aka Metalbunny If your life was a dream, would you wake up from a nightmare, dripping of sweat, hoping it was over? Or would you wake up happy and pleased, ready to take on the day with a smile? http://metalbunny.net/ References, tools, and other useful stuff... Check out the new Metalbunny forums at http://forums.metalbunny.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql_fetch_assoc(): 3 is not a valid MySQL result resource
My page displays the first result and then I get the following error. Warning: mysql_fetch_assoc(): 3 is not a valid MySQL result resource in c:\inetpub\wwwroot\testy\Untitled-1.php on line 29 Please help. R. my code. ?php require_once('Connections/ross.php'); ? ?php $maxRows_Recordset1 = 10; $pageNum_Recordset1 = 0; if (isset($_GET['pageNum_Recordset1'])) { $pageNum_Recordset1 = $_GET['pageNum_Recordset1']; } $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1; mysql_select_db($database_ross, $ross); $query_Recordset1 = SELECT portfolio.location_name FROM portfolio; $query_limit_Recordset1 = sprintf(%s LIMIT %d, %d, $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1); $Recordset1 = mysql_query($query_limit_Recordset1, $ross) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); if (isset($_GET['totalRows_Recordset1'])) { $totalRows_Recordset1 = $_GET['totalRows_Recordset1']; } else { $all_Recordset1 = mysql_query($query_Recordset1); $totalRows_Recordset1 = mysql_num_rows($all_Recordset1); } $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1; mysql_free_result($Recordset1); ? ?php echo $totalRows_Recordset1 ? ?php do { ? p?php echo $row_Recordset1['location_name']; ?/p ?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MultiSelect List Box in PHP
implode() Andy B wrote: I need to be able to print the selected items without the array... thing around it. so example would be if 1 and 2 are selected it would print: 1, 2 it's supposed to be formatted for the user... -Original Message- From: -{ Rene Brehmer }- [mailto:[EMAIL PROTECTED] Sent: Sunday, October 31, 2004 5:12 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] MultiSelect List Box in PHP Would be easier if you didn't send it as HTML ... bad boy you Rene At 10:00 31-10-2004, M. Sokolewicz wrote: -[ input.html ]-- one two three -[]-- -[ input.php ]-- ?php print_r($_POST); ? -[]-- -[ output ]-- Array ( [select] = Array ( [0] = 1 [1] = 2 ) [submit] = submit ) -[]-- Above output is with #1 and #2 selected, and #3 not selected. Easy, huh? - Tul -- Rene Brehmer aka Metalbunny If your life was a dream, would you wake up from a nightmare, dripping of sweat, hoping it was over? Or would you wake up happy and pleased, ready to take on the day with a smile? http://metalbunny.net/ References, tools, and other useful stuff... Check out the new Metalbunny forums at http://forums.metalbunny.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] code problem
This is my code... ?php require_once('Connections/ross.php'); ? ?php $maxRows_Recordset1 = 10; $pageNum_Recordset1 = 0; if (isset($_GET['pageNum_Recordset1'])) { $pageNum_Recordset1 = $_GET['pageNum_Recordset1']; } $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1; mysql_select_db($database_ross, $ross); $query_Recordset1 = SELECT portfolio.location_name FROM portfolio; $query_limit_Recordset1 = sprintf(%s LIMIT %d, %d, $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1); $Recordset1 = mysql_query($query_limit_Recordset1, $ross) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); if (isset($_GET['totalRows_Recordset1'])) { $totalRows_Recordset1 = $_GET['totalRows_Recordset1']; } else { $all_Recordset1 = mysql_query($query_Recordset1); $totalRows_Recordset1 = mysql_num_rows($all_Recordset1); } $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1; mysql_free_result($Recordset1); ? ?php echo $totalRows_Recordset1 ? ?php do { ? p?php echo $row_Recordset1['location_name']; ?/p ?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ? It displays one result then thows up the following error Warning: mysql_fetch_assoc(): 3 is not a valid MySQL result resource in c:\inetpub\wwwroot\testy\Untitled-1.php on line 29 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Help with Advanced Guestbook
I am trying to use Advanced Guestbook in my website (www.tracingfootprints.com) but would like to have it match (in style, background, etc) the other pages in the site. I've been trying to figure out how to do that (with very limited PHP knowledge) without success. My site is hosted by Go Daddy on LInux. I'm designing the site in FrontPage 2002. Thanks! Melanie -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] code problem
Ross Hulford wrote: This is my code... [snip] mysql_free_result($Recordset1); ... ?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ? It displays one result then thows up the following error Warning: mysql_fetch_assoc(): 3 is not a valid MySQL result resource in c:\inetpub\wwwroot\testy\Untitled-1.php on line 29 You free the result and then try to fetch more rows from it... not going to work. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] MultiSelect List Box in PHP
here is my total code for this file: //note that the html structure isn't there yet but it still gives the general idea ? include(libs/conf.db); mysql_connect($host, $mysqluser, $mysqlpwd); $query=mysql_query(select company from wata.members); ? form method=post action=?echo $_SERVER['PHP_SELF'];? select name=members[] multiple ? while($listbox=mysql_fetch_array($query)){? option value=?echo $listbox['company'];??echo $listbox['company'];? ?}? /select input type=submit value=submit /form ? echo implode(, ,$_POST['members']); ? //end code... result printed at bottom of page under submit button is this: (only prints last element of array) for some reason it seems that my array isn't being built right... you can change it to work with your db just change the connect string and the field list from a db to test it... -Original Message- From: Marek Kilimajer [mailto:[EMAIL PROTECTED] Sent: Sunday, October 31, 2004 4:14 PM To: Andy B Cc: PHP mailing list Subject: Re: [PHP] MultiSelect List Box in PHP implode() -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with Advanced Guestbook
It looks like you can change quite a bit by opening the body.php file in the templates folder. If you are using FP, if you haven't already, make sure to set it so it does not affect code. You might want to open that in Notepad to make sure though. On Oct 31, 2004, at 1:03 PM, Melanie wrote: I am trying to use Advanced Guestbook in my website (www.tracingfootprints.com) but would like to have it match (in style, background, etc) the other pages in the site. I've been trying to figure out how to do that (with very limited PHP knowledge) without success. My site is hosted by Go Daddy on LInux. I'm designing the site in FrontPage 2002. Thanks! Melanie -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] str_pad with nbsp;
Hi guys, i was trying to do an str_pad with nbsp; (space) but somehow it's just putting in one space and nbs sample code: ? echo str_pad($varname,20,nbsp; ? anybody else experienced this? thanks and regards, jonel -- I not know English well, but I know 7 computer languages. -anonymous -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP in CGI ....php.in
have you tried #!/usr/local/lib/php -c /home/mydomaine/www -- I not know English well, but I know 7 computer languages. On Oct 31, 2004, at 2:32 AM, Christian Ista wrote: where did you place your php.ini? In the root of my application in www. /home/mydomaine/www Thanks, Christian, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] str_pad with nbsp;
On Sun, 31 Oct 2004 16:13:44 -0600, Jonel Rienton [EMAIL PROTECTED] wrote: i was trying to do an str_pad with nbsp; (space) but somehow it's just putting in one space and nbs sample code: ? echo str_pad($varname,20,nbsp; ? anybody else experienced this? nbsp; is 6 characters. It may only appear as one character when viewed as html, but to str_pad() it's 6 characters. -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] MultiSelect List Box in PHP
--- Andy B [EMAIL PROTECTED] wrote: I need to be able to print the selected items without the array... thing around it. so example would be if 1 and 2 are selected it would print: 1, 2 It sounds like you just need to learn how to use arrays with PHP. The manual is a good place to start: http://www.php.net/array Hope that helps. Chris = Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly HTTP Developer's Handbook - Sams Coming January 2005 http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Help with preg_match_all()
Hello people... I'm relatively a beginner with regular expressions, so I need a little help here.. I hope you can help me... Ok, I have a HTML file with several tags like this: {$base.username} {$base.date} {$blog.lastpost} And so on.. It's a kind of a template system... well... I need to create a expression to get all the tags from the HTML with preg_match_all() in order to have them in a array... Can you help me with this.. I already Googled for that, but I really don't understand too well :P -- Francisco Javier Escoppinichi Fernández Email: [EMAIL PROTECTED] Web: http://www.fire-dragon.net/ MSN: [EMAIL PROTECTED] Cel: 044 (612) 348 91 00 Sólo hay 3 cosas que no vuelven atrás: la palabra emitida, la flecha lanzada y la oportunidad perdida. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php compiler
Hi! I think the precedence of left and right associative operands can't be compared. The switch between associativities already separates the expression (if it could be explained this way). Yes, this behaviour confused me. This is not common in other programming languages: o C : invalid lvalue in assignment o Java : required: variable found : value o JavaScript: invalid assignment left-hand side (Mozilla) syntax error (Internet explorer) But for me it isn't egxactly clear how the evaluation order was calculated (why doesn't the first = operator executed before ). Does anybody know for example a flowchart, how it is implemented in PHP? Felho -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Getting Information From Another Page
I would like to know how to extract the following from the website http://www.state.ny.us/security/ The Values for New York State is currently at: New York City is currently at: I would like to store this information into my database and check it every half hour to see if it has been updated? How can I do this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Getting Information From Another Page
On Sunday 31 October 2004 23:12, GH wrote: I would like to know how to extract the following from the website http://www.state.ny.us/security/ The Values for New York State is currently at: New York City is currently at: I would like to store this information into my database and check it every half hour to see if it has been updated? How can I do this? fopen(), preg_match() -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* I bet Einstein turned himself all sorts of colors before he invented the lightbulb. -- Homer Simpson Bart the Genius */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Need to add a 0 to a float number
Hi, How would I add a 0 to variables that have the following? I want $var = 6.5 to be converted to $var = 6.50 Thanks, Brent
[PHP] PHP Working With Excel File ?
Hi, Can PHP work with Excel files as database ? If not, how can I conver it to MySQL format and reconvert it to Excel 'coz I need it to report it in Excel format, Thx ___ Do you Yahoo!? Express yourself with Y! Messenger! Free. Download now. http://messenger.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need to add a 0 to a float number
Solved my own problem Note to self, RTFM: number_format is w hat I needed. Thanks, Brent - Original Message - From: Brent Clements [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, October 31, 2004 8:01 PM Subject: [PHP] Need to add a 0 to a float number Hi, How would I add a 0 to variables that have the following? I want $var = 6.5 to be converted to $var = 6.50 Thanks, Brent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Working With Excel File ?
On Monday 01 November 2004 02:58 am, Sejati Opreker wrote: Hi, Can PHP work with Excel files as database ? If not, how can I conver it to MySQL format and reconvert it to Excel 'coz I need it to report it in Excel format, With exel, export your exel file to CSV (by doing save as...) then you can import your CSV file to mysql using the phpmyadmin import interface. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Working With Excel File ?
On Monday 01 November 2004 02:58 am, Sejati Opreker wrote: Hi, Can PHP work with Excel files as database ? If not, how can I conver it to MySQL format and reconvert it to Excel 'coz I need it to report it in Excel format, Thx With exel, export your exel file to CSV (by doing save as...) then you can import your CSV file to mysql using the phpmyadmin import interface. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php compiler
* Thus wrote Hodicska Gergely: Hi! I think the precedence of left and right associative operands can't be compared. The switch between associativities already separates the expression (if it could be explained this way). Yes, this behaviour confused me. This is not common in other programming languages: o C : invalid lvalue in assignment o Java : required: variable found : value o JavaScript: invalid assignment left-hand side (Mozilla) syntax error (Internet explorer) But for me it isn't egxactly clear how the evaluation order was calculated (why doesn't the first = operator executed before ). Does anybody know for example a flowchart, how it is implemented in PHP? I kind of hinted in my earlier what is going on but: $a = 1 $b = 0; Is first silently evaluated as: $a = (1 $b = 0); Now we test the left and right expressions of . The left expression is true. So the right expression is tested which happens to be ($b = 0). Curt -- Quoth the Raven, Nevermore. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] beginnind and end of the week
* Thus wrote Jerry Swanson: I need to run a query using PHP/MYSQL. The query should be for a week. So if today is tuesday, the query should be from Monday to Sunday. How in in php I can know when the beginning and end of the week? ?php // in case the date unlikley changes $t = time(); // this weeks monday $m = strtotime('this monday', $t); // next weeks monday minus 1 second $s = strtotime('next monday', $t) - 1; echo date('r', $m), \n; echo date('r', $s), \n ? Now $m and $s contain the proper timestamps. Curt -- Quoth the Raven, Nevermore. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_fetch_assoc(): 3 is not a valid MySQL result resource
* Thus wrote Ross Hulford: My page displays the first result and then I get the following error. Warning: mysql_fetch_assoc(): 3 is not a valid MySQL result resource in c:\inetpub\wwwroot\testy\Untitled-1.php on line 29 Please help. R. my code. ... $Recordset1 = mysql_query($query_limit_Recordset1, $ross) or die(mysql_error()); ... mysql_free_result($Recordset1); You are freeing $Recordset1, thus making it useless. ? ?php echo $totalRows_Recordset1 ? ?php do { ? p?php echo $row_Recordset1['location_name']; ?/p ?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ? Curt -- Quoth the Raven, Nevermore. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with preg_match_all()
* Thus wrote Francisco Javier Escoppinichi Fernndez: Hello people... I'm relatively a beginner with regular expressions, so I need a little help here.. I hope you can help me... If you read the whole section @ http://php.net/pcre you'll be able to do this in your sleep. Ok, I have a HTML file with several tags like this: {$base.username} {$base.date} {$blog.lastpost} And so on.. It's a kind of a template system... well... I need to create a expression to get all the tags from the HTML with preg_match_all() in order to have them in a array... So your looking from something that starts with '{' and continues while not a ')' ... /{([^}]*?)}/ Curt -- Quoth the Raven, Nevermore. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP_EOL on Darwin?
Hi all, What's the standard line ending for Darwin? is it still the same as old Mac, which I think was just \r? Or does it use \n like unix? Greg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with preg_match_all()
Thanks! Worked like a charm! *Problem solved* On Mon, 1 Nov 2004 03:01:12 +, Curt Zirzow [EMAIL PROTECTED] wrote: * Thus wrote Francisco Javier Escoppinichi Fernndez: Hello people... I'm relatively a beginner with regular expressions, so I need a little help here.. I hope you can help me... If you read the whole section @ http://php.net/pcre you'll be able to do this in your sleep. Ok, I have a HTML file with several tags like this: {$base.username} {$base.date} {$blog.lastpost} And so on.. It's a kind of a template system... well... I need to create a expression to get all the tags from the HTML with preg_match_all() in order to have them in a array... So your looking from something that starts with '{' and continues while not a ')' ... /{([^}]*?)}/ Curt -- Quoth the Raven, Nevermore. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Francisco Javier Escoppinichi Fernández Email: [EMAIL PROTECTED] Web: http://www.fire-dragon.net/ MSN: [EMAIL PROTECTED] Cel: 044 (612) 348 91 00 Sólo hay 3 cosas que no vuelven atrás: la palabra emitida, la flecha lanzada y la oportunidad perdida. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Simple math failing - PHP Bug?
Hi, OK, I'm totally stumped by this. This should be the simplest math imaginable (addition and subtraction), but PHP is coming up with the wrong answer! I've checked on 3 different machines (all linux) running both PHP 4 and PHP 5. Here is the code to duplicate the problem: --- ?php $a = 2503.54; $b = 303.55; $c = 202.13; $total = 0; $total += $a; $total += $b; $total += $c; $added_total = $total; echo $a + $b + $c = $totalbr; echo Actual: $totalbrbr; $total -= $a; $total -= $b; $total -= $c; echo $added_total - $a - $b - $c = 0br; echo Actual: $totalbrbr; ? --- This ~should~ output this: 2503.54 + 303.55 + 202.13 = 3009.22 Actual: 3009.22 3009.22 - 2503.54 - 303.55 - 202.13 = 0 Actual: 0 But instead it outputs this: 2503.54 + 303.55 + 202.13 = 3009.22 Actual: 3009.22 3009.22 - 2503.54 - 303.55 - 202.13 = 0 Actual: 2.84217094304E-13 Now I'm the first to admit that 0.284217094304 and 0 are really very close, but when you are testing a variable to see if it equals 0, it is the difference between true and false. This seems very, very basic to me, but I can't find the flaw in my code. Is this legitimately bad math on the part of PHP? Thanks, Brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple math failing - PHP Bug?
On Sun, 31 Oct 2004 21:52:32 -0700, Brian T. Allen [EMAIL PROTECTED] wrote: Hi, OK, I'm totally stumped by this. This should be the simplest math imaginable (addition and subtraction), but PHP is coming up with the wrong answer! [snip] Is this legitimately bad math on the part of PHP? Thanks, Brian This is a flaw in how computers handle floating point numbers, not php. As the memory needed to store exact floats to any useful precision would quickly get out of control, floats are handled inprecisely. As a result, you should never test for equality with a float, but rather check if the float is within a certain range of the desired number. -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ http://www.smempire.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple math failing - PHP Bug?
On Monday 01 November 2004 04:52, Brian T. Allen wrote: OK, I'm totally stumped by this. This should be the simplest math imaginable (addition and subtraction), but PHP is coming up with the wrong answer! I've checked on 3 different machines (all linux) running both PHP 4 and PHP 5. Here is the code to duplicate the problem: [snip] Now I'm the first to admit that 0.284217094304 and 0 are really very close, but when you are testing a variable to see if it equals 0, it is the difference between true and false. This seems very, very basic to me, but I can't find the flaw in my code. Is this legitimately bad math on the part of PHP? Most computer languages handling floating point calculations just as poorly. If accuracy is important use the BCMath functions. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* BOFH Excuse #332: suboptimal routing experience */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple math failing - PHP Bug?
--- Jason Wong [EMAIL PROTECTED] wrote: Most computer languages handling floating point calculations just as poorly. If accuracy is important use the BCMath functions. Or use Fortran and double precision. :-) Still, testing a floating point number as a boolean is one of the worst ideas I've ever heard... Chris = Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly HTTP Developer's Handbook - Sams Coming January 2005 http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple math failing - PHP Bug?
Thomas Goyne wrote: On Sun, 31 Oct 2004 21:52:32 -0700, Brian T. Allen [EMAIL PROTECTED] wrote: Hi, OK, I'm totally stumped by this. This should be the simplest math imaginable (addition and subtraction), but PHP is coming up with the wrong answer! [snip] Is this legitimately bad math on the part of PHP? Thanks, Brian This is a flaw in how computers handle floating point numbers, not php. As the memory needed to store exact floats to any useful precision would quickly get out of control, floats are handled inprecisely. As a result, you should never test for equality with a float, but rather check if the float is within a certain range of the desired number. Wow, this is pretty dissappointing. I can understand if I was doing math on 12 or 13 digit numbers, but just adding and subtracting back out a couple of 2 digit decimals I would expect to end up back at zero. I understand it isn't PHP's fault. Thanks for the quick reply, Brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple math failing - PHP Bug?
Chris Shiflett wrote: --- Jason Wong [EMAIL PROTECTED] wrote: Most computer languages handling floating point calculations just as poorly. If accuracy is important use the BCMath functions. Or use Fortran and double precision. :-) Still, testing a floating point number as a boolean is one of the worst ideas I've ever heard... Chris = Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly HTTP Developer's Handbook - Sams Coming January 2005 http://httphandbook.org/ Well, in fairness, it's one of the worst ideas you've ever heard because you know of this limitation. In reality, using a calculator or something that doesn't share this limitation, 0 = 0 and this wouldn't be a problem. It's only when 0 = 0.1342344 that this becomes a problem. Brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple math failing - PHP Bug?
--- Brian T. Allen [EMAIL PROTECTED] wrote: Well, in fairness, it's one of the worst ideas you've ever heard because you know of this limitation. Of course. That wasn't a dig at you or anything - just a comment. You're free to heed or ignore it. In reality, using a calculator or something that doesn't share this limitation, 0 = 0 and this wouldn't be a problem. Well, 0 == 0 in PHP, too. Calculators have the same limitations that any other computing device does. Some modern calculators have some pretty impressive precision, but it's not hard to exceed it with a few seemingly harmless operations. A couple of numbers like 12.34567 and 23.45678 can get pretty nasty with a few operations. Regardless of this, I'm not in favor of depending on anything that's the least bit questionable or complicated. I don't even like evaluating integers as boolean unless they are strictly 0 or 1, and even then there can be problems (you accidentally decrement a variable twice before evaluating it again, so that it goes from 1 to -1 and continues to evaluate as true forever). In short, complexity breeds problems, regardless of how smart you are. Chris = Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly HTTP Developer's Handbook - Sams Coming January 2005 http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unable to validate XML with Schema if namespace is specified.
On Sun, 31 Oct 2004 19:08:04 +, Dusty Bin [EMAIL PROTECTED] wrote: I am trying to validate an XML document, using DomDocument::schemaValidate() as in the following code: ?php $txt =EOT ?xml version=1.0? Article xmlns='http://www.example.com/xml' ItemItemText/Item /Article EOT; $dom = new DOMDocument(); $dom-loadXML($txt); if ($dom-schemaValidate(Article.xsd)) { print $dom-saveXML(); } ? The schema I am trying to validate against is: ?xml version=1.0 ? xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema; xs:element name=Article xs:complexType xs:sequence xs:element name=Item maxOccurs=unbounded/ /xs:sequence /xs:complexType /xs:element /xs:schema This produces the following output: Warning: Element Article not declared in E:\PHPTest\testXML.php on line 10 Warning: Element Article not declared in E:\PHPTest\testXML.php on line 10 Aren't you missing any namespace declaration in your Schema File? I'm no XML Schema Expert at al, so I took trang and let it made one out of your XML and it produced the following: ?xml version=1.0 encoding=UTF-8? xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema; elementFormDefault=qualified targetNamespace=http://www.example.com/xml; xmlns:x=http://www.example.com/xml; xs:element name=Article xs:complexType xs:sequence xs:element ref=x:Item/ /xs:sequence /xs:complexType /xs:element xs:element name=Item type=xs:NCName/ /xs:schema And this validates (at least with libxml2 version 2.6.14, the PHP version doesn't matter, since all the validation is done by libxml2...) chregu If I remove the default namespace from the article tag, the XML validates correctly. I seem to recollect that namespace support is not fully implemented, so my question is, is this a bug, or just something not yet implemented, or is there an obvious blunder in what I am trying to do, which I cannot see. Best regards. . . Dusty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich phone +41 1 240 56 70 | mobile +41 76 561 88 60 | fax +41 1 240 56 71 http://www.bitflux.ch | [EMAIL PROTECTED] | gnupg-keyid 0x5CE1DECB -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple math failing - PHP Bug?
Chris Shiflett wrote: --- Brian T. Allen [EMAIL PROTECTED] wrote: Well, in fairness, it's one of the worst ideas you've ever heard because you know of this limitation. Of course. That wasn't a dig at you or anything - just a comment. You're free to heed or ignore it. In reality, using a calculator or something that doesn't share this limitation, 0 = 0 and this wouldn't be a problem. Well, 0 == 0 in PHP, too. Calculators have the same limitations that any other computing device does. Some modern calculators have some pretty impressive precision, but it's not hard to exceed it with a few seemingly harmless operations. A couple of numbers like 12.34567 and 23.45678 can get pretty nasty with a few operations. Regardless of this, I'm not in favor of depending on anything that's the least bit questionable or complicated. I don't even like evaluating integers as boolean unless they are strictly 0 or 1, and even then there can be problems (you accidentally decrement a variable twice before evaluating it again, so that it goes from 1 to -1 and continues to evaluate as true forever). In short, complexity breeds problems, regardless of how smart you are. Chris = Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly HTTP Developer's Handbook - Sams Coming January 2005 http://httphandbook.org/ No worries, this isn't personal. I just want to explore this limitation and it's implications for my benefit and the benefit of any that read this thread later when they are searching for answers to a similar problem. I just think the following should work, and outside of this limitation of computers is sound programming: $subtotal = 0; $subtotal += 503.54; $subtotal += 303.55; $subtotal -= 503.54; $subtotal -= 303.55; if($subtotal 0){ // A balance is due } But if $subtotal is 0.00034322 then it shows a balance is due when one isn't. When adding dollar amounts using only whole cents (and excluding the limitation we've been discussing) you should always have a credit = .01, a balance = .01, or no balance / credit due, which would equal 0 or 0.00, but NOT 0.00034322. Yes, there are ways to program around this, but it shouldn't be necessary. The example above shouldn't be questionable or complicated, in fact it is about as basic as it comes. It's 2nd Grade math. You just should have to program around that. I would MUCH rather have PHP run a little slower and take up more memory and get the answer right then have every PHP programmer have to program around this limitation for even the most basic math. Thanks, Brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple math failing - PHP Bug?
Brian T. Allen wrote: Chris Shiflett wrote: --- Brian T. Allen [EMAIL PROTECTED] wrote: Well, in fairness, it's one of the worst ideas you've ever heard because you know of this limitation. Of course. That wasn't a dig at you or anything - just a comment. You're free to heed or ignore it. In reality, using a calculator or something that doesn't share this limitation, 0 = 0 and this wouldn't be a problem. Well, 0 == 0 in PHP, too. Calculators have the same limitations that any other computing device does. Some modern calculators have some pretty impressive precision, but it's not hard to exceed it with a few seemingly harmless operations. A couple of numbers like 12.34567 and 23.45678 can get pretty nasty with a few operations. Regardless of this, I'm not in favor of depending on anything that's the least bit questionable or complicated. I don't even like evaluating integers as boolean unless they are strictly 0 or 1, and even then there can be problems (you accidentally decrement a variable twice before evaluating it again, so that it goes from 1 to -1 and continues to evaluate as true forever). In short, complexity breeds problems, regardless of how smart you are. Chris = Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly HTTP Developer's Handbook - Sams Coming January 2005 http://httphandbook.org/ No worries, this isn't personal. I just want to explore this limitation and it's implications for my benefit and the benefit of any that read this thread later when they are searching for answers to a similar problem. I just think the following should work, and outside of this limitation of computers is sound programming: $subtotal = 0; $subtotal += 503.54; $subtotal += 303.55; $subtotal -= 503.54; $subtotal -= 303.55; if($subtotal 0){ // A balance is due } But if $subtotal is 0.00034322 then it shows a balance is due when one isn't. When adding dollar amounts using only whole cents (and excluding the limitation we've been discussing) you should always have a credit = .01, a balance = .01, or no balance / credit due, which would equal 0 or 0.00, but NOT 0.00034322. Yes, there are ways to program around this, but it shouldn't be necessary. The example above shouldn't be questionable or complicated, in fact it is about as basic as it comes. It's 2nd Grade math. You just should have to program around that. I would MUCH rather have PHP run a little slower and take up more memory and get the answer right then have every PHP programmer have to program around this limitation for even the most basic math. Thanks, Brian have you ever thought about working with all those numbers in cents, as integers, and applying the math to that? That'll work *just fine* -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PLEASE HELP ON MAIL FUNCTION
Dear friend, I am using PHP 4.3.4 version. Please tell how to unpload a mail function. Error comes on executing mail function is mail(): SMTP server response: 550 5.7.1 Unable to relay for [EMAIL PROTECTED] in C:\Program Files\Apache Group\Apache2\htdocs\testprodigious\MAIL\mail_enquiry.php on line 30 Scprit used is ? /* recipients */ $to = [EMAIL PROTECTED]; /* subject */ $subject = Automatic Weekly Reports of Marketing from Prodigious; /*making message body */ $message =Wekly Reprot; /* To send HTML mail, you can set the Content-type header. there header are nessare for maing table in php and even for html pahe without these header only script will send in mail no brwser look*/ $headers = MIME-Version: 1.0\r\n; $headers .= Content-type: text/html; charset=iso-8859-1\r\n; /* and now mail it */ mail($to, $subject, $message,$headers ); ? I will be grateful to you. With Best Regards `.(*.(`. .).*).` ..Er. Kunal Aggarwal .. `.(.*(. `.)*.).` Software Engineer ICL Certifications Limited 372, Industrial Area Phase 1 Panchkula Haryana India Voice Talk:-+91-98159-65988(Mobile), +91-0172-2563358 (Office) * 24, +91-0172-2563358 (Fax) Email: [EMAIL PROTECTED] Website: www.iclcertifications.com
Re: [PHP] Simple math failing - PHP Bug?
On Sun, 31 Oct 2004 23:30:53 -0700, Brian T. Allen [EMAIL PROTECTED] wrote: No worries, this isn't personal. I just want to explore this limitation and it's implications for my benefit and the benefit of any that read this thread later when they are searching for answers to a similar problem. I just think the following should work, and outside of this limitation of computers is sound programming: $subtotal = 0; $subtotal += 503.54; $subtotal += 303.55; $subtotal -= 503.54; $subtotal -= 303.55; if($subtotal 0){ // A balance is due } But if $subtotal is 0.00034322 then it shows a balance is due when one isn't. When adding dollar amounts using only whole cents (and excluding the limitation we've been discussing) you should always have a credit = .01, a balance = .01, or no balance / credit due, which would equal 0 or 0.00, but NOT 0.00034322. Yes, there are ways to program around this, but it shouldn't be necessary. The example above shouldn't be questionable or complicated, in fact it is about as basic as it comes. It's 2nd Grade math. You just should have to program around that. I would MUCH rather have PHP run a little slower and take up more memory and get the answer right then have every PHP programmer have to program around this limitation for even the most basic math. Thanks, Brian It would be more than a minor slowdown, as php would have to inplement something that is so slow when done at a far lower level that there used to be a seperate processor just to handle it. Also, 1/3 is certainly basic math, but it eventually gets impossible to store accuratly, as there is not exact decimal value. You could store the fractional value of it, but what happens when you have something like log(sqrt(1/3))? The only way to have an exact value would be to store every single operation done to the number, and rerun them every time the number is refered to, but you still have rounding between every step of that. -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ http://www.smempire.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PLEASE HELP ON MAIL FUNCTION
Your Apache/PHP Mail function is working properly. The SMTP server needs to be configured to relay email from the PHP server. The normal configuration would be to allow the relay of all mail from that server. Chris kunal Aggarwal wrote: Dear friend, I am using PHP 4.3.4 version. Please tell how to unpload a mail function. Error comes on executing mail function is mail(): SMTP server response: 550 5.7.1 Unable to relay for [EMAIL PROTECTED] in C:\Program Files\Apache Group\Apache2\htdocs\testprodigious\MAIL\mail_enquiry.php on line 30 Scprit used is ? /* recipients */ $to = [EMAIL PROTECTED]; /* subject */ $subject = Automatic Weekly Reports of Marketing from Prodigious; /*making message body */ $message =Wekly Reprot; /* To send HTML mail, you can set the Content-type header. there header are nessare for maing table in php and even for html pahe without these header only script will send in mail no brwser look*/ $headers = MIME-Version: 1.0\r\n; $headers .= Content-type: text/html; charset=iso-8859-1\r\n; /* and now mail it */ mail($to, $subject, $message,$headers ); ? I will be grateful to you. With Best Regards `.(*.(`. .).*).` ..Er. Kunal Aggarwal .. `.(.*(. `.)*.).` Software Engineer ICL Certifications Limited 372, Industrial Area Phase 1 Panchkula Haryana India Voice Talk:-+91-98159-65988(Mobile), +91-0172-2563358 (Office) * 24, +91-0172-2563358 (Fax) Email: [EMAIL PROTECTED] Website: www.iclcertifications.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PLEASE HELP ON MAIL FUNCTION
Hello, On 11/01/2004 03:58 AM, Kunal Aggarwal wrote: I am using PHP 4.3.4 version. Please tell how to unpload a mail function. Error comes on executing mail function is mail(): SMTP server response: 550 5.7.1 Unable to relay for [EMAIL PROTECTED] in C:\Program Files\Apache Group\Apache2\htdocs\testprodigious\MAIL\mail_enquiry.php on line 30 This means that your SMTP server is requiring authentication to relay messages. The mail function does not support authentication. You may want to try this class that comes with wrapper function named smtp_mail(). It emulates the mail() function except that it lets you relay messages on a server authenticating with a user name and password that you can provide: http://www.phpclasses.org/mimemessage You also need these two classes: http://www.phpclasses.org/smtpclass http://www.phpclasses.org/sasl -- Regards, Manuel Lemos PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ PHP Reviews - Reviews of PHP books and other products http://www.phpclasses.org/reviews/ Metastorage - Data object relational mapping layer generator http://www.meta-language.net/metastorage.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php