[PHP] newbie question
Greetings, This is the example from the php manual: *** Example 6. sprintf(): formatting currency *** I don't understand the meaning of the 01 above, which follows the % sign. I tried the "%.2f" and "%1.2f", both work fine. So, what's the meaning of 01(especially what the 0 is for)? Seems very much the same as C anyway :-). Please explain. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie question
On Sun, Oct 12, 2003 at 06:09:21PM +1000, Wang Feng wrote: : : This is the example from the php manual: [...] : $formatted = sprintf("%01.2f", $money);// my question comes here : // echo $formatted will output "123.10" [...] : : I don't understand the meaning of the 01 above, which follows the % sign. I : tried the "%.2f" and "%1.2f", both work fine. So, what's the meaning of : 01(especially what the 0 is for)? Seems very much the same as C anyway :-). The "01" part guarantees that your money always has a preceding "0" for decimal-only amounts. For example, ".15" should be displayed as "0.15". -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie question
Hi, Eugene, If I get rid of the 0 and tried this: $price=.65; $f_price=sprintf("%1.2f",$price); It displays "0.65" in my Mozilla browser correctly. What do you say then? BTW, what's the 1 used for? cheers, feng - Original Message - From: "Eugene Lee" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, October 12, 2003 6:49 PM Subject: Re: [PHP] newbie question > On Sun, Oct 12, 2003 at 06:09:21PM +1000, Wang Feng wrote: > : > : This is the example from the php manual: > [...] > : $formatted = sprintf("%01.2f", $money);// my question comes here > : // echo $formatted will output "123.10" > [...] > : > : I don't understand the meaning of the 01 above, which follows the % sign. I > : tried the "%.2f" and "%1.2f", both work fine. So, what's the meaning of > : 01(especially what the 0 is for)? Seems very much the same as C anyway :-). > > The "01" part guarantees that your money always has a preceding "0" for > decimal-only amounts. For example, ".15" should be displayed as "0.15". > > -- > 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] Age from date field?
On Sun, Oct 12, 2003 at 02:09:38AM +0200, DvDmanDT wrote: : : Does anyone have a good solution on how to get the age of someone from a : date column in mysql... This is what I have, but it's not really the : truth... What's the right way to do it? : : floor((time()-$a["born"])/(3600*24*365.25)) : : where $a["born"] is the timestamp of the birthdate... Current query: This should work for well-formed timestamps, i.e. they are not in the future: function age($ts) { list($y1, $m1, $d1) = explode(' ', date('Y m d', $ts)); list($y2, $m2, $d2) = explode(' ', date('Y m d', time())); $age = $y2 - $y1 - ((($m2 < $m1) || ($d2 < $d1)) ? 1 : 0); return $age; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] Re: Detecting devices i.e. PDA, Mobile
Hi, Sunday, October 12, 2003, 4:53:27 PM, you wrote: JF> On Sunday, October 12, 2003, at 12:02 PM, Manuel Vázquez Acosta wrote: >> Take a look at what is printed by: >> >> var_dump($_SERVER); >> >> Maybe the HTTP_USER_AGENT can lead you to somewhere out of this >> problem. >> >> Manu. >> >> "Shaun" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >>> Hi, >>> >>> I have created an online system, and have created a WAP version, and >>> am >>> currently crreating a PDA version. What I wuold like to to do is give >>> out >>> the same URL instead of domain.com for normal use, domain.com/wap/ or >>> domain.com/pda/. Is there a way of detecting what device is loading >>> the >> site >>> and redirect them accordingly? >>> >>> Thanks for your help JF> Manuel, Shaun, JF> $_SERVER['HTTP_USER_AGENT'] (just like anything else from the client JF> side) can't be trusted to either exist, or to be correct. Some user JF> agents don't set this value, and it's quite easy for it to be faked. JF> More to the point, there's no way you can possibly account for all JF> possible user agents out there... perhaps only the popular ones. JF> So, $_SERVER['HTTP_USER_AGENT'] is a good starting point or method for JF> guessing where to send people, but it's not fail safe AT ALL. JF> I think the fail safe way is to create pages which are standards JF> compliant (XHTML strict) and use CSS for all styling/presentation, JF> which means your pages will accessible via the largest possible number JF> of viewing devices, like PDA, WAP, text-to-speech, desktop browsers, JF> Web TV, etc. JF> The move away from table based layouts and poorly accessible webpages JF> is a big one, but not THAT big :) JF> Justin JF> -- JF> PHP General Mailing List (http://www.php.net/) JF> To unsubscribe, visit: http://www.php.net/unsub.php From my experience css is even more unreliable than user agent being set and all browser producers seem to have their own idea of what a standard is supposed to look like as well. At least with table layouts most of the current desktop browsers will make a half decent try. With companies like Netscape and Microsoft providing browsers you should stay away from strict anything is my advice :) The ideal way of detecting a wap browser is through the accepted mime types from the request header but I am not sure if that info is passed on by PHP. You could try
[PHP] I can't make 'read_tag.php' file
I have found that this script doesn't work: read_tag.php --- "; $tagdata = stristr($filedata, $tagrealname); $posofend = strpos($tagdata, ""); $length = strlen($tagdata); $lengthoftag = strlen($tagrealname); $lengthofend = strlen(""); $lengthofstr = $length - $posofend - $lengthoftag; $returndata = substr($tagdata, $lengthoftag, $lengthofstr); if ($debug == 1) { echo "Length = " . $length; echo "Of Tag = " . $lengthoftag; echo "Of Str = " . $lengthofstr; echo "Of End = " . $posofend; echo "TagData:" . $tagdata; } return $returndata; } ?> Test readTag-functie --- And with this, it needs the file 'test.tag' --- I am myself!! This is a test!!! Welcome!!! Closing!!! --- The first parameter of the readTag function is the filename of the tag file. The second is the tag to search for an the third is the debug mode. The error is that if i load this, the readTag function returns everything except for the Closing!!! What's wrong? I'm running Win XP with Apache 2.0.44(Win32) CGI setup and PHP 4.3.3 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] https detection
Hi, Is there a way to determite with PHP thath site visitor is in https (SSL) mode or in normal mode ? Thanks, Rosen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] https detection
Hi, Sunday, October 12, 2003, 9:09:15 PM, you wrote: R> Hi, R> Is there a way to determite with PHP thath site visitor is in https (SSL) R> mode or in normal mode ? R> Thanks, R> Rosen put phpinfo(32); at the top of the page and that should show what is available with an ssl connection if you make one. -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] https detection
I.e. if I use _SERVER["SERVER_PORT"] = 443 - for https connection and 80 for "normal" - i'll be able to determite if user is in https mode - I think thath should be works . ? Thanks, Rosen "Tom Rogers" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > Sunday, October 12, 2003, 9:09:15 PM, you wrote: > R> Hi, > R> Is there a way to determite with PHP thath site visitor is in https (SSL) > R> mode or in normal mode ? > > R> Thanks, > R> Rosen > > > put phpinfo(32); at the top of the page and that should show what is available > with an ssl connection if you make one. > > -- > regards, > Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie question
On Sun, Oct 12, 2003 at 06:57:35PM +1000, Wang Feng wrote: : : If I get rid of the 0 and tried this: : : $price=.65; : $f_price=sprintf("%1.2f",$price); : : It displays "0.65" in my Mozilla browser correctly. What do you say then? I say, "I dunno". :-) It seems to follow C's printf(3) conversion specification. If a decimal point is needed for a float, it must also have a digit in front of the decimal point. This is kind of annoying if I want to print decimal-only values without preceding zeroes. Maybe money_format() is a better solution. : BTW, what's the 1 used for? Specifies the minimum character width of the conversion. See PHP's sprintf() docs for more details. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] https detection
Hi, Sunday, October 12, 2003, 9:24:40 PM, you wrote: R> I.e. if I use _SERVER["SERVER_PORT"] = 443 - for https connection and 80 R> for "normal" - i'll be able to determite if user is in https mode - I think R> thath should be works . ? R> Thanks, R> Rosen looks like a good start :) -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] https detection
On Sun, Oct 12, 2003 at 01:09:15PM +0200, Rosen wrote: : : Is there a way to determite with PHP thath site visitor is in https (SSL) : mode or in normal mode ? Check for the existence of $_SERVER['HTTPS'] which gets set only on SSL pages. I wonder why it's still not mentioned in the official docs. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] https detection
On Sun, Oct 12, 2003 at 01:24:40PM +0200, Rosen wrote: : : I.e. if I use _SERVER["SERVER_PORT"] = 443 - for https connection and 80 : for "normal" - i'll be able to determite if user is in https mode - I think : thath should be works . ? Technically, you can't guarantee that anything running over port 443 will be HTTPS. This is part of the more general problem of running your web server on non-standard ports. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] https detection
Hi, Sunday, October 12, 2003, 8:46:41 PM, you wrote: EL> On Sun, Oct 12, 2003 at 01:24:40PM +0200, Rosen wrote: EL> : EL> : I.e. if I use _SERVER["SERVER_PORT"] = 443 - for https connection and 80 EL> : for "normal" - i'll be able to determite if user is in https mode - I think EL> : thath should be works . ? EL> Technically, you can't guarantee that anything running over port 443 EL> will be HTTPS. This is part of the more general problem of running your EL> web server on non-standard ports. His script will only see valid ssl connections as all other attempts should be ditched by apache or whatever before php gets involved...in theory anyway :) -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] https detection
On Sun, Oct 12, 2003 at 08:52:30PM +1000, Tom Rogers wrote: : Sunday, October 12, 2003, 8:46:41 PM, Eugene wrote: : EL> On Sun, Oct 12, 2003 at 01:24:40PM +0200, Rosen wrote: : EL> : : EL> : I.e. if I use _SERVER["SERVER_PORT"] = 443 - for https connection : EL> : and 80 for "normal" - i'll be able to determite if user is in https : EL> : mode - I think thath should be works . ? : : EL> Technically, you can't guarantee that anything running over port 443 : EL> will be HTTPS. This is part of the more general problem of running your : EL> web server on non-standard ports. : : His script will only see valid ssl connections as all other attempts should be : ditched by apache or whatever before php gets involved...in theory anyway :) Unless Apache is configured so that both SSL and non-SSL virtualhosts to point to the same directory containing said script, or said script is shared (via PHP include(), require(), etc.) by other PHP scripts in both SSL and non-SSL virtualhosts. :-) And $_SERVER['HTTPS'] is so much easier to check for existence! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] Re: Detecting devices i.e. PDA, Mobile
On Sunday, October 12, 2003, at 07:46 PM, Tom Rogers wrote: From my experience css is even more unreliable than user agent being set and all browser producers seem to have their own idea of what a standard is supposed to look like as well. At least with table layouts most of the current desktop browsers will make a half decent try. With companies like Netscape and Microsoft providing browsers you should stay away from strict anything is my advice :) It depends what you're aiming for. If you're aiming for pixel perfect display on the usual browsers, great -- go for tables and the usual hacks. But in the meantime you're sacrificing forwards compatibility for backwards compatibility, making your site hugely inaccessible, causing huge ongoing development costs (update the hacks to support newer browsers and devices), etc etc. What's the point in developing three or more sites (WAP, PDA, Desktop) when one can do the same, with a few SMALL sacrifices. As a bonus, you're developing HTML for EVERYONE, not turning away ANYONE, and you're saving your client some money. Anyway, this is getting a little OT :) You're entitled to do things your way, and so am I... the $'s and accessibility are making my decisions for me. The ideal way of detecting a wap browser is through the accepted mime types from the request header but I am not sure if that info is passed on by PHP. You could try You need to look for something like this: text/vnd.wap.wml for .wml files (WML source files) application/vnd.wap.wmlc for .wmlc files (WML compiled files) text/vnd.wap.wmlscript for .wmls files (WMLScript source files) application/vnd.wap.wmlscriptc for .wmlsc files (WMLScript compiled files) image/vnd.wap.wbmp for .wbmp files (wireless bitmaps) Nice idea! Justin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Detecting devices i.e. PDA, Mobile
Hi Justin et al, Yes you are right that user agent field is not always reliable but 98% of the time you will be able to tell if it's a mobile or a pc. That's good enough. If someone fakes the header they will just get a wrong content type and no harm done. I first did a wap site with php using this method way back in 2000. Unidentified browsers were given html. As for a detailed list of various mobile browers, it's impossible to maintain this list. That's why there is a sourceforge project that does it and we can all benefit. did i mention xslt? Justin French wrote: On Sunday, October 12, 2003, at 12:02 PM, Manuel Vázquez Acosta wrote: Take a look at what is printed by: var_dump($_SERVER); Maybe the HTTP_USER_AGENT can lead you to somewhere out of this problem. Manu. "Shaun" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hi, I have created an online system, and have created a WAP version, and am currently crreating a PDA version. What I wuold like to to do is give out the same URL instead of domain.com for normal use, domain.com/wap/ or domain.com/pda/. Is there a way of detecting what device is loading the site and redirect them accordingly? Thanks for your help Manuel, Shaun, $_SERVER['HTTP_USER_AGENT'] (just like anything else from the client side) can't be trusted to either exist, or to be correct. Some user agents don't set this value, and it's quite easy for it to be faked. More to the point, there's no way you can possibly account for all possible user agents out there... perhaps only the popular ones. So, $_SERVER['HTTP_USER_AGENT'] is a good starting point or method for guessing where to send people, but it's not fail safe AT ALL. I think the fail safe way is to create pages which are standards compliant (XHTML strict) and use CSS for all styling/presentation, which means your pages will accessible via the largest possible number of viewing devices, like PDA, WAP, text-to-speech, desktop browsers, Web TV, etc. The move away from table based layouts and poorly accessible webpages is a big one, but not THAT big :) Justin -- Raditha Dissanayake. http://www.radinks.com/sftp/ | http://www.raditha/megaupload/ Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 150 KB | with progress bar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] https detection
Hi, Sunday, October 12, 2003, 10:27:21 PM, you wrote: EL> Unless Apache is configured so that both SSL and non-SSL virtualhosts EL> to point to the same directory containing said script, or said script is EL> shared (via PHP include(), require(), etc.) by other PHP scripts in both EL> SSL and non-SSL virtualhosts. :-) EL> And $_SERVER['HTTPS'] is so much easier to check for existence! I couldn't remember what variables were set so I said to use phpinfo and see what pops upyou are probably right :) -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] xml in php5.0.0beta1
Hello - Does the new xml api provide high level function calls (does it map the libxml api)? Regards Dennis Heuer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PNG to GIF conversion
<[EMAIL PROTECTED]> John Ryan: > Loser >>And believe it or >> not, the shift key is there for a reason. Please don't flame. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: I can't make 'read_tag.php' file
Try this: function readTag($filenane, $tagtype, $degub = false) // I prefer boolean for debug :) { $filedata = file_get_contents($filename); $tagtype = preg_quote($tagtype); $tagRegExp = "/((?:.|\s)*?)/"; preg_replace_callback($tagRegExp, 'replaceFunc', $filedata); } function replaceFunc(match) { // match[0] --- the whole tag from to // match[1] --- the contents of the tag //I am my self !!! in the example return WHATEVER_YOU_WANT_TO_REPLACE_THE_TAG; } I didnt make sure this script will work 100%; but it should. Manu. "Bas" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I have found that this script doesn't work: > > read_tag.php > > --- > > function readTag($filename, $tagtype, $debug = 0) { > $filedata = file_get_contents($filename); > $tagrealname = " $tagrealname .= $tagtype; > $tagrealname .= ">"; > > $tagdata = stristr($filedata, $tagrealname); > $posofend = strpos($tagdata, ""); > $length = strlen($tagdata); > $lengthoftag = strlen($tagrealname); > $lengthofend = strlen(""); > $lengthofstr = $length - $posofend - $lengthoftag; > $returndata = substr($tagdata, $lengthoftag, $lengthofstr); > if ($debug == 1) { > echo "Length = " . $length; > echo "Of Tag = " . $lengthoftag; > echo "Of Str = " . $lengthofstr; > echo "Of End = " . $posofend; > echo "TagData:" . $tagdata; > } > return $returndata; > } > ?> > > > > Test readTag-functie > > > > > --- > And with this, it needs the file 'test.tag' > --- > > I am myself!! > > > This is a test!!! > > > Welcome!!! > > > Closing!!! > > --- > The first parameter of the readTag function is the filename of the tag file. > The second is the tag to search for an the third is the debug mode. > > The error is that if i load this, the readTag function returns everything > except for the Closing!!! > > What's wrong? > > I'm running Win XP with Apache 2.0.44(Win32) CGI setup and PHP 4.3.3 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Age from date field?
* Thus wrote Eugene Lee ([EMAIL PROTECTED]): > On Sun, Oct 12, 2003 at 02:09:38AM +0200, DvDmanDT wrote: > : > : Does anyone have a good solution on how to get the age of someone from a > : date column in mysql... This is what I have, but it's not really the > : truth... What's the right way to do it? > : > : floor((time()-$a["born"])/(3600*24*365.25)) > : > : where $a["born"] is the timestamp of the birthdate... Current query: > > This should work for well-formed timestamps, i.e. they are not in the > future: > > function age($ts) > { > list($y1, $m1, $d1) = explode(' ', date('Y m d', $ts)); > list($y2, $m2, $d2) = explode(' ', date('Y m d', time())); > $age = $y2 - $y1 - ((($m2 < $m1) || ($d2 < $d1)) ? 1 : 0); What happens if the month is the same but the day hasnt been reached? Shouldnt this be: $age = $y2 - $y1 - ((($m2 < $m1) || ($m2 == $m1 && $d2 < $d1)) ? 1 : 0); To account for it being the same month but not yet the day. Curt -- "My PHP key is worn out" PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] xml in php5.0.0beta1
Not to sure about what I'm saying, but if I remember well my readings regarding php5 and xml, I think it implements the gnome libxml2, not libxml, which is much better. Hopefully php + xml will be less of a pain in the arse after the 5 is out. cheers .b -Original Message- From: Dennis Heuer [mailto:[EMAIL PROTECTED] Sent: 12 October 2003 15:19 To: [EMAIL PROTECTED] Subject: [PHP] xml in php5.0.0beta1 Hello - Does the new xml api provide high level function calls (does it map the libxml api)? Regards Dennis Heuer -- 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] I can't make 'read_tag.php' file
* Thus wrote Bas ([EMAIL PROTECTED]): > > --- > And with this, it needs the file 'test.tag' > --- > > I am myself!! > [...] > > The error is that if i load this, the readTag function returns everything > except for the Closing!!! Do you mean that all the other tags return the proper content except the last one? I didn't study the code too closely for reasons that follow. > > What's wrong? Glad you asked :) Here are a couple things I noticed: - every call to this function has the overhead of reading the file. - The parsing is error prone, ie. someone puts: If its possible I would take a complete different approach at parsing the tags. There are two options that I see right away. Use XML as your data format and an xml parser to obtain the values in the tags. Or use preg_match_all. Here is how I would approach the preg_match_all: function parseTags($file) { /* readfile... here */ $tag_match = "!\s*([^<]*)\s*!is"; preg_match_all($tag_match, $filedata, $matches); for ($i=0; $i< count($matches[0]); $i++) { $tagname = $matches[1][$i]; $tags[$tagname] = $matches[2][$i]; } return $tags; } Then you can use it like so: Test readTag-functie HTH, Curt -- "My PHP key is worn out" PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] https detection
* Thus wrote Rosen ([EMAIL PROTECTED]): > I.e. if I use _SERVER["SERVER_PORT"] = 443 - for https connection and 80 > for "normal" - i'll be able to determite if user is in https mode - I think > thath should be works . ? There is no guarantee that port 443 == https and 80 == http. Curt -- "My PHP key is worn out" PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie question
* Thus wrote Eugene Lee ([EMAIL PROTECTED]): > On Sun, Oct 12, 2003 at 06:57:35PM +1000, Wang Feng wrote: > : > : If I get rid of the 0 and tried this: > : > : $price=.65; > : $f_price=sprintf("%1.2f",$price); > : > : It displays "0.65" in my Mozilla browser correctly. What do you say then? > > I say, "I dunno". :-) It seems to follow C's printf(3) conversion > specification. If a decimal point is needed for a float, it must also > have a digit in front of the decimal point. This is kind of annoying if > I want to print decimal-only values without preceding zeroes. Maybe > money_format() is a better solution. yep, and even "%0.2f" yields 0.65 Curt -- "My PHP key is worn out" PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie question
I think, without any help, the only way to make it clear is to read the source code of that function in php. The manual doesn't explain the function well. But I'm sure many people here knows the answer well. Come on. Where are you? cheers, feng - Original Message - From: "Curt Zirzow" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, October 13, 2003 2:01 AM Subject: Re: [PHP] newbie question > * Thus wrote Eugene Lee ([EMAIL PROTECTED]): > > On Sun, Oct 12, 2003 at 06:57:35PM +1000, Wang Feng wrote: > > : > > : If I get rid of the 0 and tried this: > > : > > : $price=.65; > > : $f_price=sprintf("%1.2f",$price); > > : > > : It displays "0.65" in my Mozilla browser correctly. What do you say then? > > > > I say, "I dunno". :-) It seems to follow C's printf(3) conversion > > specification. If a decimal point is needed for a float, it must also > > have a digit in front of the decimal point. This is kind of annoying if > > I want to print decimal-only values without preceding zeroes. Maybe > > money_format() is a better solution. > > yep, and even "%0.2f" yields 0.65 > > > Curt > -- > "My PHP key is worn out" > > PHP List stats since 1997: > http://zirzow.dyndns.org/html/mlists/ > > -- > 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] newbie question
On Sun, 2003-10-12 at 12:19, Wang Feng wrote: > I think, without any help, the only way to make it clear is to read the > source code of that function in php. The manual doesn't explain the function > well. > > But I'm sure many people here knows the answer well. Come on. Where are you? I believe the documentation (in at least on of the ?printf() functions describes how the implementation follows the C specs. I'm pretty sure the ?printf() family of functions were added almost entirely for the benefit of C coders :) Cheers, Rob. > > > cheers, > > feng > > > > - Original Message - > From: "Curt Zirzow" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Monday, October 13, 2003 2:01 AM > Subject: Re: [PHP] newbie question > > > > * Thus wrote Eugene Lee ([EMAIL PROTECTED]): > > > On Sun, Oct 12, 2003 at 06:57:35PM +1000, Wang Feng wrote: > > > : > > > : If I get rid of the 0 and tried this: > > > : > > > : $price=.65; > > > : $f_price=sprintf("%1.2f",$price); > > > : > > > : It displays "0.65" in my Mozilla browser correctly. What do you say > then? > > > > > > I say, "I dunno". :-) It seems to follow C's printf(3) conversion > > > specification. If a decimal point is needed for a float, it must also > > > have a digit in front of the decimal point. This is kind of annoying if > > > I want to print decimal-only values without preceding zeroes. Maybe > > > money_format() is a better solution. > > > > yep, and even "%0.2f" yields 0.65 > > > > > > Curt > > -- > > "My PHP key is worn out" > > > > PHP List stats since 1997: > > http://zirzow.dyndns.org/html/mlists/ > > > > -- > > 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 > > -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] awful newbie question
I'm one of the ignorant multitude beginning to grope their way across the threshhold of web programming. I come from another world, not computer science, and thus have a question so basic I haven't found any reference to it anywhere. It's killing me. In the php statement $q->qzml(); what is the symbol '->' called? What does it mean? A php script with this line in it, in which $q is an object and qzml() is a function, returns the error message "undefined function". When I remove this line, the function qzml() is recognized. I have also come across the symbol '=>'. I assume it is not the same symbol. What is it, and what does it mean? Any help would be greatly appreciated. Thanks, -Paul
Re: [PHP] awful newbie question
Paul Freedman wrote: I'm one of the ignorant multitude beginning to grope their way across the threshhold of web programming. I come from another world, not computer science, and thus have a question so basic I haven't found any reference to it anywhere. It's killing me. In the php statement $q->qzml(); what is the symbol '->' called? What does it mean? It calls *member* function of object $q. So even if qzml is a global function it will not work, the function must be defined in the object's class definition: class Q { function qzml() { echo 'Q::qzml() function'; } } $q=new Q; $q->qzml(); A php script with this line in it, in which $q is an object and qzml() is a function, returns the error message "undefined function". When I remove this line, the function qzml() is recognized. I have also come across the symbol '=>'. I assume it is not the same symbol. What is it, and what does it mean? It is used to assign values to keys in array() construct: http://sk.php.net/manual/en/function.array.php Any help would be greatly appreciated. Thanks, -Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] levenshtein - comparing strings?
Hi, I am trying to add a function to my template system where the script will output a similar name to the one entered, e.g.: array('main','page1','testing','main_info'); user input: 'mai' then it should return 'main' & 'main_info' from the array as possible matches. (Ok, easy example, but it's supposed to work as well with worse typos) Anyway, so I stumbled upon the levenshtein funtion which seems to be the right thing to use for s.th. like that. However, how does on php.net the "search function" do it? Does it use a database match checking, or are they using some php function(s) to display matching function names? Thanks, Duncan
[PHP] Output control - IE problem with flush()
Hi, I am currently working with the output control functions and they work like a charm - as long as I don't start using IE to view my test page. I put together the below code from a couple of comments on php.net and it works like a charm with mozilla, where the content gets displayed with each loop run - but as soon as I start using tables then IE waits until the table gets closed to display the output, so it basically waits until everything is put together anyway and outputs it all. So, mozilla starts drawing the first table which gets surrounded by the first table border, then the next table appears so that both get surrounded by the first table border and so on. IE simply keeps on loading until all 3 parts of the array have been put together and then starts displaying the output in the window. So, my question: is there a way to make IE display the flush'ed output even when I am using tables? I guess I am simply making a stupid mistake here, but so far all my tries resulted in IE not being able to use flush() within tables (e.g.: remove the surrounding table and it will work just fine again). S.o. mentioned in the php.net comments that the < tr > tag is causing those problems, but I tried all kind of combinations to no avail. However, since I see that kind of output control on several sites I assume there has to be some kind of way to get the data displayed before the table structure has been closed again - or is that an ASP only feature? Any help would be appreciated, Duncan Line 1'; $arg[1] = 'Line 2'; $arg[2] = 'Line 3'; ob_start(); for ($j=0; $j != sizeof($arg); $j++) { @eval("?>" . $arg[$j] .str_pad(" ", 300). "
Re: [PHP] newbie question
"1. An optional padding specifier that says what character will be used for padding the results to the right string size. This may be a space character or a 0 (zero character). The default is to pad with spaces. An alternate padding character can be specified by prefixing it with a single quote ('). See the examples below." "3. An optional number, a width specifier that says how many characters (minimum) this conversion should result in." http://au.php.net/manual/en/function.sprintf.php Assume that $price=.65; then the "%0.2f" yields 0.65. If we follow what the manual says, then can you tell me what the 0 is used for? Is it a (optional) paddinng spcifier OR is it a (optional) width specifier OR both? And why does it yiled 0.65 rather than .65? (The manual doesn't explain things clear, man.) cheers, feng - Original Message - From: "Robert Cummings" <[EMAIL PROTECTED]> To: "Wang Feng" <[EMAIL PROTECTED]> Cc: "Curt Zirzow" <[EMAIL PROTECTED]>; "PHP-General" <[EMAIL PROTECTED]> Sent: Monday, October 13, 2003 2:29 AM Subject: Re: [PHP] newbie question > I believe the documentation (in at least on of the ?printf() functions > describes how the implementation follows the C specs. I'm pretty sure > the ?printf() family of functions were added almost entirely for the > benefit of C coders :) > > Cheers, > Rob. > > > > > > > cheers, > > > > feng > > > > > > > > - Original Message - > > From: "Curt Zirzow" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Monday, October 13, 2003 2:01 AM > > Subject: Re: [PHP] newbie question > > > > > > > * Thus wrote Eugene Lee ([EMAIL PROTECTED]): > > > > On Sun, Oct 12, 2003 at 06:57:35PM +1000, Wang Feng wrote: > > > > : > > > > : If I get rid of the 0 and tried this: > > > > : > > > > : $price=.65; > > > > : $f_price=sprintf("%1.2f",$price); > > > > : > > > > : It displays "0.65" in my Mozilla browser correctly. What do you sa y > > then? > > > > > > > > I say, "I dunno". :-) It seems to follow C's printf(3) conversion > > > > specification. If a decimal point is needed for a float, it must also > > > > have a digit in front of the decimal point. This is kind of annoying if > > > > I want to print decimal-only values without preceding zeroes. Maybe > > > > money_format() is a better solution. > > > > > > yep, and even "%0.2f" yields 0.65 > > > > > > > > > Curt > > > -- > > > "My PHP key is worn out" > > > > > > PHP List stats since 1997: > > > http://zirzow.dyndns.org/html/mlists/ > > > > > > -- > > > 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 > > > > > -- > .. > | InterJinn Application Framework - http://www.interjinn.com | > :: > | An application and templating framework for PHP. Boasting | > | a powerful, scalable system for accessing system services | > | such as forms, properties, sessions, and caches. InterJinn | > | also provides an extremely flexible architecture for | > | creating re-usable components quickly and easily. | > `' > > -- > 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] mail() php in message
Hi, is there a way to create a mail (with the mail() function) that contains php in the message. Like: I WANT TO PUT SOME PHP IN HERE TO CREATE A TABLE IN THE MESSAGE: $columnbooks = mysql_list_fields($dbname,tmp,$mysql_link); $sqlbooks = "select isbn,books.title, writer, publisher from tmp,books where tmp.user=books.user"; $resultbooks = mysql_db_query($dbname,$sqlbooks); ?> while ($valuebooks = mysql_fetch_array($resultbooks)) { print ""; for($i=0; $i< 4; $i++ ) { $gebruikerbooks=$valuebooks[$i]; print " $gebruikerbooks "; } print ""; } mysql_free_result($resultbooks); THIS SHOULD BE THE END OF THE MESSAGE HERE I WILL DO THE MAILING mail($to,$subject,$message); ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem with session_destroy() don't work
Hi, I have a problem with destroing a session. I have made a login page and the login work ok. I register the things i want like that: I try to make the logout page like that: but it dont work. I have a.. PHP - 4.0.5 a.. MySQL - 3.23.32 a.. Apache - 1.3.14 a.. PHPMyAdmin - 2.1.0 a.. Perl - nsPerl 5.005_03 session.auto_start Off session.cache_expire 180 session.cache_limiter nocache session.cookie_domain no value session.cookie_lifetime 0 session.cookie_path / session.entropy_file no value session.entropy_length 0 session.gc_maxlifetime 1440 session.gc_probability 1 session.name PHPSESSID session.referer_check no value session.save_handler files session.save_path c:/php4/sessions session.serialize_handler php session.use_cookies On installed apache on win2000 The session is not destroyd. Session_unset dont work to. Can someone help me? thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mail() php in message
Hallo Onno, am Sonntag, 12. Oktober 2003 um 20:07 hast Du Folgendes gekritzelt: OK> Hi, OK> is there a way to create a mail (with the mail() function) that contains OK> php in the message. OK> Like: OK> $to = "[EMAIL PROTECTED]"; OK> $subject = "a subject"; OK> $message = OK> I WANT TO PUT SOME PHP IN HERE TO CREATE A TABLE IN THE MESSAGE: OK> $columnbooks = mysql_list_fields($dbname,tmp,$mysql_link); OK> $sqlbooks = "select isbn,books.title, writer, publisher from tmp,books OK> where tmp.user=books.user"; OK> $resultbooks = mysql_db_query($dbname,$sqlbooks); ?>> OK> > OK> while ($valuebooks = mysql_fetch_array($resultbooks)) OK> { print ""; OK> for($i=0; $i< 4; $i++ ) OK> { OK> $gebruikerbooks=$valuebooks[$i]; OK> print " $gebruikerbooks "; OK> } OK> print ""; OK> } OK> mysql_free_result($resultbooks); OK> THIS SHOULD BE THE END OF THE MESSAGE OK> HERE I WILL DO THE MAILING OK> mail($to,$subject,$message); ?>> You should know that php runs on a server, not on the client machine. So what do you want to do with php-code in a mail? You could put html (generated by php for example), so that the mail-reader can display a table. SvT -- Who is the ennemy? mailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
php-general Digest 12 Oct 2003 18:37:06 -0000 Issue 2351
php-general Digest 12 Oct 2003 18:37:06 - Issue 2351 Topics (messages 165880 through 165916): Re: Detecting devices i.e. PDA, Mobile 165880 by: Justin French 165885 by: Tom Rogers 165896 by: Justin French 165897 by: Raditha Dissanayake newbie question 165881 by: Wang Feng 165882 by: Eugene Lee 165883 by: Wang Feng 165890 by: Eugene Lee 165906 by: Curt Zirzow 165907 by: Wang Feng 165908 by: Robert Cummings 165913 by: Wang Feng Re: Age from date field? 165884 by: Eugene Lee 165902 by: Curt Zirzow I can't make 'read_tag.php' file 165886 by: Bas 165901 by: Manuel Vázquez Acosta 165904 by: Curt Zirzow https detection 165887 by: Rosen 165888 by: Tom Rogers 165889 by: Rosen 165891 by: Tom Rogers 165892 by: Eugene Lee 165893 by: Eugene Lee 165894 by: Tom Rogers 165895 by: Eugene Lee 165898 by: Tom Rogers 165905 by: Curt Zirzow xml in php5.0.0beta1 165899 by: Dennis Heuer 165903 by: Bertrand Moulard Re: PNG to GIF conversion 165900 by: Comex awful newbie question 165909 by: Paul Freedman 165910 by: Marek Kilimajer levenshtein - comparing strings? 165911 by: Duncan Output control - IE problem with flush() 165912 by: Duncan mail() php in message 165914 by: Onno Kuipers 165916 by: Matthias Wulkow Problem with session_destroy() don't work 165915 by: Kostas Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] -- --- Begin Message --- On Sunday, October 12, 2003, at 12:02 PM, Manuel Vázquez Acosta wrote: Take a look at what is printed by: var_dump($_SERVER); Maybe the HTTP_USER_AGENT can lead you to somewhere out of this problem. Manu. "Shaun" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hi, I have created an online system, and have created a WAP version, and am currently crreating a PDA version. What I wuold like to to do is give out the same URL instead of domain.com for normal use, domain.com/wap/ or domain.com/pda/. Is there a way of detecting what device is loading the site and redirect them accordingly? Thanks for your help Manuel, Shaun, $_SERVER['HTTP_USER_AGENT'] (just like anything else from the client side) can't be trusted to either exist, or to be correct. Some user agents don't set this value, and it's quite easy for it to be faked. More to the point, there's no way you can possibly account for all possible user agents out there... perhaps only the popular ones. So, $_SERVER['HTTP_USER_AGENT'] is a good starting point or method for guessing where to send people, but it's not fail safe AT ALL. I think the fail safe way is to create pages which are standards compliant (XHTML strict) and use CSS for all styling/presentation, which means your pages will accessible via the largest possible number of viewing devices, like PDA, WAP, text-to-speech, desktop browsers, Web TV, etc. The move away from table based layouts and poorly accessible webpages is a big one, but not THAT big :) Justin--- End Message --- --- Begin Message --- Hi, Sunday, October 12, 2003, 4:53:27 PM, you wrote: JF> On Sunday, October 12, 2003, at 12:02 PM, Manuel Vázquez Acosta wrote: >> Take a look at what is printed by: >> >> var_dump($_SERVER); >> >> Maybe the HTTP_USER_AGENT can lead you to somewhere out of this >> problem. >> >> Manu. >> >> "Shaun" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >>> Hi, >>> >>> I have created an online system, and have created a WAP version, and >>> am >>> currently crreating a PDA version. What I wuold like to to do is give >>> out >>> the same URL instead of domain.com for normal use, domain.com/wap/ or >>> domain.com/pda/. Is there a way of detecting what device is loading >>> the >> site >>> and redirect them accordingly? >>> >>> Thanks for your help JF> Manuel, Shaun, JF> $_SERVER['HTTP_USER_AGENT'] (just like anything else from the client JF> side) can't be trusted to either exist, or to be correct. Some user JF> agents don't set this value, and it's quite easy for it to be faked. JF> More to the point, there's no way you can possibly account for all JF> possible user agents out there... perhaps only the popular ones. JF> So, $_SERVER['HTTP_USER_AGENT'] is a good starting point or method for JF> guessing where to send people, but it's not fail safe AT ALL. JF> I think the fail safe way is to create pages which are standards JF> compliant (XHTML strict) and use CSS for all styling/presentation, JF> which means your pages will accessible via the largest possible number JF> of viewing devices, like
[PHP] Call object reference and member function in 1 step
I'm reading the References Explained section of php doc, and am a little confused on the Returning References section. I was wondering why you cannot get a reference to an object and call a member function all in one step like so: $result=(&$bar->getObj())->foo(); I've tried this in code, and get a parse error. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP uninstall/reinstall
Hi all, am a newbie to PHP so please spell your answers to my questions out in words of one syllable or less... I recently had PHP 4.2.1 installed on Windows 98 SE, then it suddenly stopped working for some reason - I don't know why or how, but I kept getting SErver 500 errors. Having tried to remove all traces of PHP from the Windows OS and tried to install the latest version (4.3.3), both with the ZIP manual installation and the EXE self-install program, I still get problems. Can anyone please please help, cause I really need PHP on my PC to finish development of my local dramatics society's website and the intermediary between me and the Society will puncture my jugular if I can't get it working within the next week. Ben Howarth P.S. Am running PWS/IIS 3 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can't find oci.h
In mail.php.general, Donahue, Peter <[EMAIL PROTECTED]> wrote: > I'm building Php (4.3.3) on Solaris and am including oci8 support. > Configure works fine. When I try to build, I get an error on the compilation > of ext/oci8/oci8.c - it can't find oci.h, and then I get tons of errors, > I suppose all stemming from this. Little late, I know - tho I just got it working myself (only to have to reformat and drop from Redhat9 to 7.3, so I can use Oracle 8.1.7 client instead of 9 - compat, etc :( ) You need to reinstall the Oracle client - but this time use the full Administrative Install. Then when you get to check the installed components look through and check "Oracle Call Interface". Install will go as before and this time you'll find an oci.h lurking in an obscure directory: find . -name oci.h -print should let you know where it is. Hope this helps. Paul. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Oracle - Win32
In mail.php.general, imran <[EMAIL PROTECTED]> wrote: [snip] > format like such: php_xxx. For Oracle DD, you'll need php_oracle.dll. Take > the oracle dll. Only use the oracle dll if you are using oracle 7 client libs. If you are using Oracle 8+ then you want the oci8 dll. Do not copy the php_oracle.dll and do not enable that extension in php.ini > THAT's it! > Save the php.ini. > > Now you can call Oracle functions You also have to ensure that you have installed the Oracle Client Library software. All php does is to convert the oracle calls to oracle's api and gets the Oracle client lib to do the work. Without this, you won't get too far. You can download the oracle client libs at otn.oracle.com (create a free account). Hope this helps. Paul. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mail() php in message
Matthias Wulkow wrote: Hallo Onno, am Sonntag, 12. Oktober 2003 um 20:07 hast Du Folgendes gekritzelt: OK> Hi, OK> is there a way to create a mail (with the mail() function) that contains OK> php in the message. OK> Like: OK> $to = "[EMAIL PROTECTED]"; OK> $subject = "a subject"; OK> $message = OK> I WANT TO PUT SOME PHP IN HERE TO CREATE A TABLE IN THE MESSAGE: OK> $columnbooks = mysql_list_fields($dbname,tmp,$mysql_link); OK> $sqlbooks = "select isbn,books.title, writer, publisher from tmp,books OK> where tmp.user=books.user"; OK> $resultbooks = mysql_db_query($dbname,$sqlbooks); ?>> OK> > OK> OK> while ($valuebooks = mysql_fetch_array($resultbooks)) OK> { print ""; OK> for($i=0; $i< 4; $i++ ) OK> { OK> $gebruikerbooks=$valuebooks[$i]; OK> print " $gebruikerbooks "; OK> } OK> print ""; OK> } OK> mysql_free_result($resultbooks); OK> THIS SHOULD BE THE END OF THE MESSAGE OK> HERE I WILL DO THE MAILING OK> mail($to,$subject,$message); ?>> You should know that php runs on a server, not on the client machine. So what do you want to do with php-code in a mail? You could put html (generated by php for example), so that the mail-reader can display a table. That is exactly what I want to do. I've got a mysql database. I want to generate a table with data from the database into the message of the mail. I know how the to put html in the message: $message = ' Here are the birthdays upcoming in August! PersonDayMonthYear Joe3rdAugust1970 Sally17thAugust1973 '; but I want to know how to put html generated by php in the message. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Age from date field?
On Sun, Oct 12, 2003 at 02:49:53PM +, Curt Zirzow wrote: : * Thus wrote Eugene Lee ([EMAIL PROTECTED]): : > On Sun, Oct 12, 2003 at 02:09:38AM +0200, DvDmanDT wrote: : > : : > : Does anyone have a good solution on how to get the age of someone from a : > : date column in mysql... This is what I have, but it's not really the : > : truth... What's the right way to do it? : > : : > : floor((time()-$a["born"])/(3600*24*365.25)) : > : : > : where $a["born"] is the timestamp of the birthdate... Current query: : > : > This should work for well-formed timestamps, i.e. they are not in the : > future: : > : > function age($ts) : > { : > list($y1, $m1, $d1) = explode(' ', date('Y m d', $ts)); : > list($y2, $m2, $d2) = explode(' ', date('Y m d', time())); : > $age = $y2 - $y1 - ((($m2 < $m1) || ($d2 < $d1)) ? 1 : 0); : : What happens if the month is the same but the day hasnt been : reached? : : Shouldnt this be: : $age = $y2 - $y1 - ((($m2 < $m1) || ($m2 == $m1 && $d2 < $d1)) ? 1 : 0); : : To account for it being the same month but not yet the day. You're right. I got lost trying to short-circuit the expression and forgot to explicitly test for same month. :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mail() php in message
message of the mail. I know how the to put html in the message: $message = ' in stead of print " $gebruikerbooks "; do $message .= " $gebruikerbooks "; A little clarification: * Just instead of echoing it directly to the browser, add it to your variable $message. * "$message.='bla';" is a shortcut for "$message.=$message . 'bla'; " * the . is the glue for strings. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie question
On Mon, Oct 13, 2003 at 03:23:53AM +1000, Wang Feng wrote: : : "1. An optional padding specifier that says what character will be used for : padding the results to the right string size. This may be a space character : or a 0 (zero character). The default is to pad with spaces. An alternate : padding character can be specified by prefixing it with a single quote ('). : See the examples below." : "3. An optional number, a width specifier that says how many characters : (minimum) this conversion should result in." : http://au.php.net/manual/en/function.sprintf.php : : Assume that $price=.65; then the "%0.2f" yields 0.65. : : If we follow what the manual says, then can you tell me what the 0 is used : for? Is it a (optional) paddinng spcifier OR is it a (optional) width : specifier OR both? And why does it yiled 0.65 rather than .65? : : (The manual doesn't explain things clear, man.) The PHP manual is vague in several sections. I wonder how bug reports get submitted for it? The optional specifiers to the left of the decimal place have a psuedo last-to-first precedence. For example: $price = .65; printf("'%8.2f'\n", $price); -> ' 0.65' This shows that there are 8 characters reserved for the number to the left of the decimal. Therefore, '8' is the width specifier. printf("'%-8.2f'\n", $price); -> '0.65 ' printf("'%08.2f'\n", $price); -> '.65' printf("'%0-8.2f'\n", $price); -> '0.65000' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] awful newbie question
On Sun, Oct 12, 2003 at 07:09:32PM +0200, Marek Kilimajer wrote: : : Paul Freedman wrote: : > : >In the php statement : >$q->qzml(); : >what is the symbol '->' called? What does it mean? : : It calls *member* function of object $q. [...] : >I have also come across the symbol '=>'. I assume it is not the same : >symbol. What is it, and what does it mean? : : It is used to assign values to keys in array() construct: : http://sk.php.net/manual/en/function.array.php But as for the first question, I don't know if '->' or '=>' have any specific *names* in PHP. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] levenshtein - comparing strings?
Actually I found out that php.net offers the source code for that part :) here it is: http://ca.php.net/source.php?url=/quickref.php ...and I was able to use it as a basis to fit my need. Duncan Burhan Khalid wrote: Duncan wrote: Hi, I am trying to add a function to my template system where the script will output a similar name to the one entered, e.g.: array('main','page1','testing','main_info'); user input: 'mai' then it should return 'main' & 'main_info' from the array as possible matches. (Ok, easy example, but it's supposed to work as well with worse typos) Anyway, so I stumbled upon the levenshtein funtion which seems to be the right thing to use for s.th. like that. However, how does on php.net the "search function" do it? Does it use a database match checking, or are they using some php function(s) to display matching function names? I don't know how the search function (or google for that matter) do it, but a way to do it via SQL is "WHERE field LIKE mai%" which will match main, mainly, mainstay, etc. I would sure like to know how google does it. Maybe they use aspell?
[PHP] Fixed problem with a script, but need to understand why it happened
Hello, I am a brand new subscriber to this list, and am fairly new to PHP as well. I started using it back in June to put together an online survey for my dissertation. Though I learned a few things the hard way, I have done mostly OK since then, until I changed an increasingly complex script to using functions. That's when my big problem started. Yes, I eventually figured out that global variables aren't accessible inside a function unless they are declared as such. Everything I have read tells me that $_SESSION is equally accessible both outside and inside functions. For a while today, I was beginning to doubt that, but then I realized that the problem I was experiencing was due to the placement of a particular statement within the script. This particular script calls three other scripts. One (background.php) should be called the first time a survey participant logs on. Whether or not the background had been collected yet was stored in a mysql table and was used to control whether background.php got called or not. Before the script was changed to use functions, calling background.php happened just as I expected, first thing each time a new user logged on. But when I changed the script to use functions, I could no longer get that background.php to get called -- UNLESS I placed echo statements after it to show the values in $_SESSION -- then it worked EVERY TIME. I spent countless hours today trying to figure out why the $_SESSION value which was controlling the call to background.php was apparently not accessible, only to realize that that wasn't the problem at all -- instead the problem was placement within the code of the call to background.php. Here's the basic question for those of you more experienced than I: Why was I able to call background.php just as I wanted to when the script didn't have functions, but not able to make the very same call when the script was changed to use functions? Some code snippets: 1) before code was changed to use functions (background.php was called as expected): //include DB connection include('./db.php'); //start session session_start(); $_SESSION["session_uid"]=$uid; //what person name pair will this user judge? $query="SELECT * FROM diss_pretesters WHERE uid='".$_SESSION["session_uid"]."'"; $result=mysql_db_query("$db","$query") or die(query_fail("$query")); //assign values from query to session variables $data=mysql_fetch_array($result); $_SESSION["session_set"]=$data['setid']; $_SESSION["session_sets_array_member"]=$data['last_setid']; $_SESSION["session_curr_array_member"]=$data['last_said_member_eval']; $_SESSION["session_background_info_recorded"]=$data['background_info_recorded']; $_SESSION["session_sets_assigned"]=$data['sets_assigned']; if($_SESSION["session_background_info_recorded"]=='N') { header("location: background.php"); //collect background information before any arrays are advanced } //create current array member if($_SESSION["session_curr_array_member"]=='') { $_SESSION["session_curr_array_member"]=0; } else { $_SESSION["session_curr_array_member"]++; } [snip some intervening code where some of the below values were set] $current_said_field = $_SESSION["session_curr_array_member"]+1; $current_said_fieldname = "said".$current_said_field; //Retrieve current said value from the randomized table $query="SELECT $current_said_fieldname FROM diss_user_set_randomize WHERE uid='$uid' AND setid='".$_SESSION["session_set"]."'"; //echo "QUERY: $query"; $result=mysql_db_query("$db","$query") or die(query_fail("$query")); //assign values from query to session variables $data=mysql_fetch_array($result); $current_said=$data[$current_said_fieldname]; $_SESSION["session_current_said"]=$current_said; if($_SESSION["session_curr_array_member"]<$_SESSION["session_set_size"]) { header("location: judgeFrameset.php"); //send user to relevant frameset } else { header("location: posttask.php"); } 2) Code from initial stab at functions, which didn't work in that background.php was never called -- unless followed immediately by uncommented echo statements; instead either judgeFrameset.php or posttask.php were called: / function GetBasicInfo () { global $db, $uid; $query="SELECT * FROM diss_pretesters WHERE uid='$uid'"; $result=mysql_db_query("$db","$query") or die(query_fail("$query")); $data=mysql_fetch_array($result); $_SESSION["ses
[PHP] Working with external images
I'm trying to write a script that can work with images as google does. I've got an image with some unknown width and height, and I want to be able to get this properties and use them to create a dynamic page with new size attributes. For example, if the image has 400x600 px, I want to display the line even if the script wasn't previosly told the image was 400x600 px. If the image is 500x800, I want to change it to 50x80. Can I do that with php? Regards, Voodoo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
php-general Digest 13 Oct 2003 06:55:39 -0000 Issue 2352
php-general Digest 13 Oct 2003 06:55:39 - Issue 2352 Topics (messages 165917 through 165929): Call object reference and member function in 1 step 165917 by: sturgis III PHP uninstall/reinstall 165918 by: Benjamin Howarth 165922 by: Shadow Re: Can't find oci.h 165919 by: Paul Gregg Re: Oracle - Win32 165920 by: Paul Gregg Re: mail() php in message 165921 by: Onno Kuipers 165924 by: Chris Hayes Re: Age from date field? 165923 by: Eugene Lee Re: newbie question 165925 by: Eugene Lee Re: awful newbie question 165926 by: Eugene Lee Re: levenshtein - comparing strings? 165927 by: Duncan Fixed problem with a script, but need to understand why it happened 165928 by: Mary D. Taffet Working with external images 165929 by: Voodoo Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] -- --- Begin Message --- I'm reading the References Explained section of php doc, and am a little confused on the Returning References section. I was wondering why you cannot get a reference to an object and call a member function all in one step like so: $result=(&$bar->getObj())->foo(); I've tried this in code, and get a parse error. --- End Message --- --- Begin Message --- Hi all, am a newbie to PHP so please spell your answers to my questions out in words of one syllable or less... I recently had PHP 4.2.1 installed on Windows 98 SE, then it suddenly stopped working for some reason - I don't know why or how, but I kept getting SErver 500 errors. Having tried to remove all traces of PHP from the Windows OS and tried to install the latest version (4.3.3), both with the ZIP manual installation and the EXE self-install program, I still get problems. Can anyone please please help, cause I really need PHP on my PC to finish development of my local dramatics society's website and the intermediary between me and the Society will puncture my jugular if I can't get it working within the next week. Ben Howarth P.S. Am running PWS/IIS 3 --- End Message --- --- Begin Message --- I don't remember much about IIS 3/4 but here are the instruction for installing under windows..http://www.php.net/manual/en/install.windows.php Shadow --- End Message --- --- Begin Message --- In mail.php.general, Donahue, Peter <[EMAIL PROTECTED]> wrote: > I'm building Php (4.3.3) on Solaris and am including oci8 support. > Configure works fine. When I try to build, I get an error on the compilation > of ext/oci8/oci8.c - it can't find oci.h, and then I get tons of errors, > I suppose all stemming from this. Little late, I know - tho I just got it working myself (only to have to reformat and drop from Redhat9 to 7.3, so I can use Oracle 8.1.7 client instead of 9 - compat, etc :( ) You need to reinstall the Oracle client - but this time use the full Administrative Install. Then when you get to check the installed components look through and check "Oracle Call Interface". Install will go as before and this time you'll find an oci.h lurking in an obscure directory: find . -name oci.h -print should let you know where it is. Hope this helps. Paul. --- End Message --- --- Begin Message --- In mail.php.general, imran <[EMAIL PROTECTED]> wrote: [snip] > format like such: php_xxx. For Oracle DD, you'll need php_oracle.dll. Take > the oracle dll. Only use the oracle dll if you are using oracle 7 client libs. If you are using Oracle 8+ then you want the oci8 dll. Do not copy the php_oracle.dll and do not enable that extension in php.ini > THAT's it! > Save the php.ini. > > Now you can call Oracle functions You also have to ensure that you have installed the Oracle Client Library software. All php does is to convert the oracle calls to oracle's api and gets the Oracle client lib to do the work. Without this, you won't get too far. You can download the oracle client libs at otn.oracle.com (create a free account). Hope this helps. Paul. --- End Message --- --- Begin Message --- Matthias Wulkow wrote: Hallo Onno, am Sonntag, 12. Oktober 2003 um 20:07 hast Du Folgendes gekritzelt: OK> Hi, OK> is there a way to create a mail (with the mail() function) that contains OK> php in the message. OK> Like: OK> $to = "[EMAIL PROTECTED]"; OK> $subject = "a subject"; OK> $message = OK> I WANT TO PUT SOME PHP IN HERE TO CREATE A TABLE IN THE MESSAGE: OK> $columnbooks = mysql_list_fields($dbname,tmp,$mysql_link); OK> $sqlbooks = "select isbn,books.title, writer, publisher from tmp,books OK> where tmp.user=books.user"; OK> $resultbooks = mysql_db_query($dbname,$sqlbooks); ?>> OK> > OK> OK> while ($valuebooks = mysql_fetch_array($resultbooks)) OK> { print ""; OK> for($i=0; $i< 4; $i++ ) OK> { OK>
[PHP] Re: PHP uninstall/reinstall
I don't remember much about IIS 3/4 but here are the instruction for installing under windows..http://www.php.net/manual/en/install.windows.php Shadow -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php