Re: [PHP] in_array breaks down for 0 as value
On 20 Nov 2008, at 23:09, Ashley Sheridan wrote: On Thu, 2008-11-20 at 09:25 +, Stut wrote: On 20 Nov 2008, at 06:55, Yashesh Bhatia wrote: I wanted to use in_array to verify the results of a form submission for a checkbox and found an interesting behaviour. $ php -v PHP 5.2.5 (cli) (built: Jan 12 2008 14:54:37) $ $ cat in_array2.php 'page', 'story' => 'story', 'nodereview' => 'abc', ); if (in_array('page', $node_review_types)) { print "page found in node_review_types\n"; } if (in_array('nodereview', $node_review_types)) { print "nodereview found in node_review_types\n"; } ?> $ php in_array2.php page found in node_review_types $ This works fine. but if i change the value of the key 'nodereview' to 0 it breaks down. $ diff in_array2.php in_array3.php 6c6 <'nodereview' => 'abc', --- 'nodereview' => 0, $ $ php in_array3.php page found in node_review_types nodereview found in node_review_types $ Any reason why in_array is returning TRUE when one has a 0 value on the array ? That's weird, 5.2.6 does the same thing. There's actually a comment about this on the in_array manual page from james dot ellis at gmail dot com... Be aware of oddities when dealing with 0 (zero) values in an array... This script: It seems in non strict mode, the 0 value in the array is evaluating to boolean FALSE and in_array returns TRUE. Use strict mode to work around this peculiarity. This only seems to occur when there is an integer 0 in the array. A string '0' will return FALSE for the first test above (at least in 5.2.6). So use strict mode and this problem will go away. Oh, and please read the manual before asking a question in future. -Stut -- http://stut.net/ What about using the === and !== comparisons to compare and make sure that 0 is not giving a false false. That's effectively what using strict mode does. RTFM please. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: reading XML
Angelo Zanetti wrote: What is the simplest way to accomplish this small challenge? you could give this a go if you like (one i made earlier): http://programphp.com/xmlparser.phps - class at the top, usage at the bottom. it simply turns xml into an associated array, using regex; just tested it again as it's a couple of years old and it's working on php 4.4.7 and php 5.2.5 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] user access/roles/privs functionality
bruce-60 wrote: > > Hi list... > > I need a way of managing users/teams/etc.. implementing roles/access > rights/privs,etc... Have a look at Zend_Acl: http://framework.zend.com/manual/en/zend.acl.html - http://devshed.excudo.net http://devshed.excudo.net -- View this message in context: http://www.nabble.com/user-access-roles-privs-functionality-tp20508624p20620446.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Anyway to simulate pcntl_fork() on Windows?
It's the function I need most and it's not available on Windows, and unfortunately that's what the client uses. Any suggestions for a workaround? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Anyway to simulate pcntl_fork() on Windows?
check this out ... http://in.php.net/manual/en/ref.pcntl.php#37369 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] store class zithin session
Hi Stut, On Thu, Nov 20, 2008 at 12:25 PM, Stut <[EMAIL PROTECTED]> wrote: > On 20 Nov 2008, at 11:01, Alain Roger wrote: > >> i have a class and i would like to store it zithin session. >> i was thinking to use serialize/unserialize but it does not work. >> >> any idea how to do it ? >> > > Alain, you've been on this list long enough to know that "it does not work" > is not enough information for people to be able to help you. > You're right and i feel sorry. i thought i paste my code just after the sentence. ok, anyway i solved my problem somehow :-) > > Firstly there is no need to serialise anything going into the session. > Secondly I assume you want to store objects not classes. yes. > Thirdly there is no reason why it should not work, but there are some > caveats you need to be aware of... > > * The class definition must have been loaded before session_start() is > called, otherwise you'll end up with an object of type stdClass rather than > your class. this was my mistake...i mean to not call the class file before starting the session :-( A.
[PHP] Re: reading XML
Hi Angelo, try this: http://pear.php.net/manual/en/package.structures.structures-datagrid.structures-datagrid-datasource.xml.php regards Carlos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Displaying information from table graphically
I have a PHP application that accesses data from MySQL. There is table called "rooms", and table called "beds". There is another table called "patients". Patients are being placed into beds, and beds are in the rooms. PHP application currently displays all information in textual mode via regular HTML tags. But I would like to have that information displayed in graphical mode instead of textual mode. Is there a way to display this information from the database graphically. Graphic would represent a room, and it would contain beds inside. You would be able to see visually which beds are occupied and which are free by looking at the graphics. User of the system wants pictures instead of text displayed via HTML tables as a list of entries. Anyone knows anything like this? Thanks, Dzenan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Model Web Site
hi... for what it's worth. the best approach might be to find a few sites that have the functionality/layout you like. there are probably a few of them that you'll run across that meet what you have in mind. use these as your basic guides. add additional features that you'd like. you now have (roughly speaking) the requirements/functions that you want your final site to have. from here, you can figure out which "scripts" you want to apply, and what you're still going to have to provide. keep in mind that you can't simply throw scripts together, but you can use them to get a sense of the underlying logic. you can also use them to see how to develop your look/feel of your site. looking at various scripts also gives you a chance to think about how you want to implement your security/setup, as well as the underlying database schema.. you can find plenty of apps/scripts on freshmeat.net/sourceforge.net as well. have fun! -Original Message- From: Stephen [mailto:[EMAIL PROTECTED] Sent: Thursday, November 20, 2008 2:17 PM To: PHP-General Subject: [PHP] Model Web Site My prime hobby is photography and the next is web site building. So now I have a young model (18+) asking me about getting a web site. The idea is members can see content, that will include, photos, her blog and a discussion forum. I like the idea of building it, but it includes a lot of things I have no experience in. Can someone point me to documentation/tutorials/scripts or anything that might help. I don't want a turnkey solution. I want to learn how to do this. Thank you! Stephen -- 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] Displaying information from table graphically
On 21 Nov 2008, at 17:55, [EMAIL PROTECTED] wrote: I have a PHP application that accesses data from MySQL. There is table called "rooms", and table called "beds". There is another table called "patients". Patients are being placed into beds, and beds are in the rooms. PHP application currently displays all information in textual mode via regular HTML tags. But I would like to have that information displayed in graphical mode instead of textual mode. Is there a way to display this information from the database graphically. Graphic would represent a room, and it would contain beds inside. You would be able to see visually which beds are occupied and which are free by looking at the graphics. User of the system wants pictures instead of text displayed via HTML tables as a list of entries. There's a couple of ways you can do this with differing qualities. 1) Use GD or ImageMagick to composite images together to represent the room. This would allow you to create the best looking images. You can either store images for rooms with 1, 2, 3, 4, ..., n beds and overlay markers to indicate occupied beds, or you could composite the whole thing. 2) Slice images up such that you can build a room using positioned divs. This would be a lot easier but you'd be limited in what type of textures and looks you can give the rooms. On the other hand this could turn out to be more flexible as you could arrange it to allow rooms of any dimensions with any number of beds. Personally I'd opt for 2 based on the KISS principle, but you could potentially run into browser compatibility issues depending on your target platforms. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Displaying information from table graphically
[EMAIL PROTECTED] wrote: I have a PHP application that accesses data from MySQL. There is table called "rooms", and table called "beds". There is another table called "patients". Patients are being placed into beds, and beds are in the rooms. PHP application currently displays all information in textual mode via regular HTML tags. But I would like to have that information displayed in graphical mode instead of textual mode. Is there a way to display this information from the database graphically. Graphic would represent a room, and it would contain beds inside. You would be able to see visually which beds are occupied and which are free by looking at the graphics. User of the system wants pictures instead of text displayed via HTML tables as a list of entries. Anyone knows anything like this? Thanks, Dzenan general idea: in mysql you have marked beds with 0 not occupied and 1 occupied. then you have two images: bed_occupied_0.gif and bed_occupied_1.gif and, depending on record from mysql different image should be shown. same with number of beds in room. for example. there is 4 beds maximum per room. you have 5 images no_of_beds_0.gif (actually, this is a transparent 1x1 gif) images no_of_beds_1.gif images no_of_beds_2.gif images no_of_beds_3.gif images no_of_beds_4.gif $query = mysql_qurey("select no_of_beds from beds where room=123"; $result = mysql_fetch_assoc($query); echo "border=0 />"; something like that. -afan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Displaying information from table graphically
[EMAIL PROTECTED] wrote: I have a PHP application that accesses data from MySQL. There is table called "rooms", and table called "beds". There is another table called "patients". Patients are being placed into beds, and beds are in the rooms. PHP application currently displays all information in textual mode via regular HTML tags. But I would like to have that information displayed in graphical mode instead of textual mode. Is there a way to display this information from the database graphically. Graphic would represent a room, and it would contain beds inside. You would be able to see visually which beds are occupied and which are free by looking at the graphics. User of the system wants pictures instead of text displayed via HTML tables as a list of entries. Anyone knows anything like this? Thanks, Dzenan Sure, you just need to make PHP draw the graphics. You can do that using the GD library[1], imagemagick[2], or in some cases even do it manually (eg. SVG, but that's not supported at all by IE). [1] http://www.php.net/manual/en/book.image.php [2] http://www.php.net/manual/en/book.imagick.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: phpDesigner 2008?
All in one--is the other better? On 11/18/08, Nathan Rixham <[EMAIL PROTECTED]> wrote: > Waynn Lue wrote: >> I know the IDE wars spring up occasionally, but looking through the >> archives, I haven't seen any discussions pro or con for phpDesigner 2008 ( >> http://www.mpsoftware.dk/phpdesigner.php). Anyone had a chance to use it >> and think it's good or not? >> >> I just installed PDT + Eclipse today, and I'm still getting used to the >> integration. I'm used to Eclipse + Java, so it somewhat throws me for a >> loop in trying to figure out what works in what scope. I do wish I could >> have it do some kind of analysis of my files plus dependencies so any >> problems could be discovered at compile time, rather than run time. >> >> Thanks, >> Waynn >> > > php isn't pre-compiled though.. > > did you go for ganymede with pdt 2 or the all in one? > > -- > 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] in_array breaks down for 0 as value
On Fri, 2008-11-21 at 09:11 +, Stut wrote: > On 20 Nov 2008, at 23:09, Ashley Sheridan wrote: > > On Thu, 2008-11-20 at 09:25 +, Stut wrote: > >> On 20 Nov 2008, at 06:55, Yashesh Bhatia wrote: > >>> I wanted to use in_array to verify the results of a form submission > >>> for a checkbox and found an interesting > >>> behaviour. > >>> > >>> $ php -v > >>> PHP 5.2.5 (cli) (built: Jan 12 2008 14:54:37) > >>> $ > >>> > >>> $ cat in_array2.php > >>> >>> $node_review_types = array( > >>> 'page' => 'page', > >>> 'story' => 'story', > >>> 'nodereview' => 'abc', > >>> ); > >>> > >>> if (in_array('page', $node_review_types)) { > >>> print "page found in node_review_types\n"; > >>> } > >>> if (in_array('nodereview', $node_review_types)) { > >>> print "nodereview found in node_review_types\n"; > >>> } > >>> > >>> ?> > >>> $ php in_array2.php > >>> page found in node_review_types > >>> $ > >>> > >>> This works fine. but if i change the value of the key > >>> 'nodereview' to > >>> 0 it breaks down. > >>> > >>> $ diff in_array2.php in_array3.php > >>> 6c6 > >>> <'nodereview' => 'abc', > >>> --- > 'nodereview' => 0, > >>> $ > >>> > >>> $ php in_array3.php > >>> page found in node_review_types > >>> nodereview found in node_review_types > >>> $ > >>> > >>> Any reason why in_array is returning TRUE when one has a 0 value on > >>> the array ? > >> > >> That's weird, 5.2.6 does the same thing. There's actually a comment > >> about this on the in_array manual page from james dot ellis at gmail > >> dot com... > >> > >> > >> > >> Be aware of oddities when dealing with 0 (zero) values in an array... > >> > >> This script: > >> >> $array = array('testing',0,'name'); > >> var_dump($array); > >> //this will return true > >> var_dump(in_array('foo', $array)); > >> //this will return false > >> var_dump(in_array('foo', $array, TRUE)); > >> ?> > >> > >> It seems in non strict mode, the 0 value in the array is evaluating > >> to > >> boolean FALSE and in_array returns TRUE. Use strict mode to work > >> around this peculiarity. > >> This only seems to occur when there is an integer 0 in the array. A > >> string '0' will return FALSE for the first test above (at least in > >> 5.2.6). > >> > >> > >> > >> So use strict mode and this problem will go away. Oh, and please read > >> the manual before asking a question in future. > >> > >> -Stut > >> > >> -- > >> http://stut.net/ > >> > > What about using the === and !== comparisons to compare and make sure > > that 0 is not giving a false false. > > That's effectively what using strict mode does. RTFM please. > > -Stut > Hey, chill. If you offer advice, don't be so offensive to everyone. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Displaying information from table graphically
On Fri, 2008-11-21 at 16:55 -0100, [EMAIL PROTECTED] wrote: > I have a PHP application that accesses data from MySQL. There is table > called "rooms", and table called "beds". There is another table called > "patients". Patients are being placed into beds, and beds are in the > rooms. PHP application currently displays all information in textual mode > via regular HTML tags. But I would like to have that information displayed > in graphical mode instead of textual mode. > > Is there a way to display this information from the database graphically. > Graphic would represent a room, and it would contain beds inside. You > would be able to see visually which beds are occupied and which are free > by looking at the graphics. > > User of the system wants pictures instead of text displayed via HTML > tables as a list of entries. > > Anyone knows anything like this? > Thanks, > Dzenan > > > This sounds a lot like a school/college/uni project that you're too lazy to research... Correct me if I'm wrong. The other guys who have answered are all spot on when they say you need to look at the GD library. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] gethostbyaddr and IPv6
Hello, Does gethostbyaddr actually work for anyone while looking up an IPv6 address? I can't seem to get it to work. For example: echo gethostbyaddr ( '2001:470:0:64::2' ); should return "ipv6.he.net" but instead I get the following error: [21-Nov-2008 22:43:37] PHP Warning: gethostbyaddr() [function.gethostbyaddr]: Address is not in a.b.c.d form in C:\www\tests\saved\host.php on line 7 Google has not been my friend in this matter... Any insight? Thanks, Glen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gethostbyaddr and IPv6
2008/11/21 Glen C <[EMAIL PROTECTED]>: > Hello, > > Does gethostbyaddr actually work for anyone while looking up an IPv6 > address? I can't seem to get it to work. For example: > > echo gethostbyaddr ( '2001:470:0:64::2' ); > > should return "ipv6.he.net" but instead I get the following error: > > [21-Nov-2008 22:43:37] PHP Warning: gethostbyaddr() > [function.gethostbyaddr]: > Address is not in a.b.c.d form in C:\www\tests\saved\host.php on line 7 > > Google has not been my friend in this matter... > > Any insight? > Thanks, > Glen Hi Glen, Works for me. IPv6 support was added in 2001. You didn't say what version of PHP you are having this problem with, so it's hard to say why yours doesn't have support for it. Perhaps it was configured with --disable-ipv6 for some reason, or compiled on a system without the necessary libraries installed (which would be somewhat surprising). Torben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] in_array breaks down for 0 as value
On 22 Nov 2008, at 00:06, Ashley Sheridan wrote: On Fri, 2008-11-21 at 09:11 +, Stut wrote: On 20 Nov 2008, at 23:09, Ashley Sheridan wrote: On Thu, 2008-11-20 at 09:25 +, Stut wrote: On 20 Nov 2008, at 06:55, Yashesh Bhatia wrote: I wanted to use in_array to verify the results of a form submission for a checkbox and found an interesting behaviour. $ php -v PHP 5.2.5 (cli) (built: Jan 12 2008 14:54:37) $ $ cat in_array2.php 'page', 'story' => 'story', 'nodereview' => 'abc', ); if (in_array('page', $node_review_types)) { print "page found in node_review_types\n"; } if (in_array('nodereview', $node_review_types)) { print "nodereview found in node_review_types\n"; } ?> $ php in_array2.php page found in node_review_types $ This works fine. but if i change the value of the key 'nodereview' to 0 it breaks down. $ diff in_array2.php in_array3.php 6c6 <'nodereview' => 'abc', --- 'nodereview' => 0, $ $ php in_array3.php page found in node_review_types nodereview found in node_review_types $ Any reason why in_array is returning TRUE when one has a 0 value on the array ? That's weird, 5.2.6 does the same thing. There's actually a comment about this on the in_array manual page from james dot ellis at gmail dot com... Be aware of oddities when dealing with 0 (zero) values in an array... This script: It seems in non strict mode, the 0 value in the array is evaluating to boolean FALSE and in_array returns TRUE. Use strict mode to work around this peculiarity. This only seems to occur when there is an integer 0 in the array. A string '0' will return FALSE for the first test above (at least in 5.2.6). So use strict mode and this problem will go away. Oh, and please read the manual before asking a question in future. -Stut -- http://stut.net/ What about using the === and !== comparisons to compare and make sure that 0 is not giving a false false. That's effectively what using strict mode does. RTFM please. -Stut Hey, chill. If you offer advice, don't be so offensive to everyone. I don't believe I was being offensive, you're clearly a very delicate little flower. The way I saw it you made a suggestion without understanding how to use the function in question. In my opinion RTFM is a perfectly reasonable response to that. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gethostbyaddr and IPv6
2008/11/21 Glen Carreras <[EMAIL PROTECTED]>: > > > On 11/22/2008 12:10 AM, Lars Torben Wilson wrote: >> >> Hi Glen, >> >> Works for me. IPv6 support was added in 2001. You didn't say what >> version of PHP you are having this problem with, so it's hard to say >> why yours doesn't have support for it. Perhaps it was configured with >> --disable-ipv6 for some reason, or compiled on a system without the >> necessary libraries installed (which would be somewhat surprising). >> >> >> Torben >> >> > > Thanks for the confirmation that it works Torben, > > This is version 5.2 (Windows binaries) and according to phpinfo ipv6 is > enabled. > Hmmm well, at least I now know for sure that it works for someone else > and > I can start exploring other avenues. I'm starting to think this is another > problem > resulting from Microsofts poor implementation of IPv6 on XP. > > Glen Hi Glen, I suspect that you may be correct--I generally don't run Windows (certainly not as a server) so I can't be sure; someone with more knowledge of Windows internals will have to field that one for you. With any luck you might find something in the user notes which leads you to a way to solve your problem using some other function or idea. Just for future reference, if you're having problems it will help people to answer your questions if you specify your PHP version and OS etc (where 'etc' means 'and all other relevant information, which of course won't be obvious--hehe) when writing the original question. I ain't tryin' to be some kind of netiquette freak here--just trying to help out. :) Anyway, good luck on your quest. Regards, Torben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php