Re: [PHP] Testing
This is my first time using a list. Can anyone confirm I'm doing this correctly? N! You broke it! Happy Friday, Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing
On Mar 8, 2013, at 1:20 PM, Dustin L dustinlob...@gmail.com wrote: This is my first time using a list. Can anyone confirm I'm doing this correctly? Thanks, Dustin L. Oh, now you did it! There will be dogs and cats in the streets. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing gmail submission
On Thu, Mar 5, 2009 at 09:20, haliphax halip...@gmail.com wrote: Got tired of using Microsoft Outlook to sort the PHP list discussions... apparently a lot of people use GMail for this, so I figured I would hook it into my GMail account and see what happens. Boyd? -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing gmail submission
On Thu, Mar 5, 2009 at 8:56 AM, Daniel Brown danbr...@php.net wrote: On Thu, Mar 5, 2009 at 09:20, haliphax halip...@gmail.com wrote: Got tired of using Microsoft Outlook to sort the PHP list discussions... apparently a lot of people use GMail for this, so I figured I would hook it into my GMail account and see what happens. Boyd? -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1 Indeed, it is I! Now, if I can only figure out how to keep GMail from mangling quotes... ah, there's the Plain Text button! :) -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing gmail submission
On Thu, Mar 5, 2009 at 10:05, haliphax halip...@gmail.com wrote: Indeed, it is I! Now, if I can only figure out how to keep GMail from mangling quotes... ah, there's the Plain Text button! :) Yeah, and if only we could get a GreaseMonkey script to stop top-posting by default. Not to suggest that you did, of course, because you didn't but it's a pain in the ass to have to take the extra couple of seconds to set up the message at the bottom. Like George Jetson always complained: Another hard day at the office pushing the button. -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing gmail submission
On Thu, Mar 5, 2009 at 9:22 AM, Daniel Brown danbr...@php.net wrote: On Thu, Mar 5, 2009 at 10:05, haliphax halip...@gmail.com wrote: Indeed, it is I! Now, if I can only figure out how to keep GMail from mangling quotes... ah, there's the Plain Text button! :) Yeah, and if only we could get a GreaseMonkey script to stop top-posting by default. Not to suggest that you did, of course, because you didn't but it's a pain in the ass to have to take the extra couple of seconds to set up the message at the bottom. Like George Jetson always complained: Another hard day at the office pushing the button. -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1 I've started playing with GreaseMonkey quite a bit lately (making mods [1] for Urban Dead [2], a web-based zombie apocalypse MMORPG that helps cure my boredom)... I'm sure GMail's interface is probably built on-the-fly with some ridiculously obfuscated/minimized Javascript, but it may be worth tinkering with if I get some spare time after finals; because you're right--it bugs the hell out of me, too. (It also seems to be adding two lines of blank space at the end of my signature. Rrrgh.) Links: 1. http://sites.google.com/sites/udscripts 2. http://www.urbandead.com -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing a URL with regex
On Wed, 2009-01-07 at 20:24 +0800, Sn!per wrote: Let's say I have these URLs http://example.com/index.php?q=gallery http://example.com/index.php?q=galleryg2_itemId=81 http://example.com/index.php?q=galleryg2_itemId=100 I want to have a line of code that will extract just the http://example.com/index.php?q=gallery; part of the URL. I am never good with regex, please help. TIA. -- roger -- Sign Up for free Email at http://ureg.home.net.my/ Why do you need a regex here? All the URL's have the same foremost component, which is exactly 38 characters in length. Do you perchance need a regualr expression to parse other URL's? If you just need to extract everything before the first ampersand, then strpos and substr would be the best to use. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing a URL with regex
Then Ashley Sheridan a...@ashleysheridan.co.uk said: Why do you need a regex here? All the URL's have the same foremost component, which is exactly 38 characters in length. Do you perchance need a regualr expression to parse other URL's? If you just need to extract everything before the first ampersand, then strpos and substr would be the best to use. Ash www.ashleysheridan.co.uk Ashley and all, thank you for your assistance. -- roger -- Sign Up for free Email at http://ureg.home.net.my/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing for Current pointer position in array during iteration
Mark Weaver schreef: Hi All, Go figure... I sat down today to get some more work on my current project; I got to a certain point where I need to step through an array with a foreach loop. I found that I need to test for the current pointer position of the array, but I haven't a clue as to how this might be accomplished. I've been all over google and php.net, but I'm not finding anything that will help me do this. Basically all I want to do is something like this: if( current_arrayPointer_postition == n ){ ... do this }else{ ...do this } foreach isn't really like that. it uses (IIRC) an internal pointer of it's own leaving the userland pointer where ever it is. but: $n = 5; // make a new array with numeric keys starting at 0 $array = array_values(array); // loop it foreach ($array as $key = $val) { if ($key == $n) { echo I got five on it; } else { echo usual suspect; } } Anyone know of a built-in PHP function that can assist with this, or can you point me to a resource that could help me code a solution? thanks, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing for Current pointer position in array during iteration
On Fri, Aug 29, 2008 at 2:40 PM, Mark Weaver [EMAIL PROTECTED] wrote: Hi All, Go figure... I sat down today to get some more work on my current project; I got to a certain point where I need to step through an array with a foreach loop. I found that I need to test for the current pointer position of the array, but I haven't a clue as to how this might be accomplished. I've been all over google and php.net, but I'm not finding anything that will help me do this. Basically all I want to do is something like this: if( current_arrayPointer_postition == n ){ ... do this }else{ ...do this } Anyone know of a built-in PHP function that can assist with this, or can you point me to a resource that could help me code a solution? thanks, -- Mark It was good to be the fire... Better by far than to crawl and mew and suck and $h1t and die! 'Arthur C. Clarke' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php This may also help as well as Jochem's suggestion: http://us2.php.net/key -- -Dan Joseph www.canishosting.com - Plans start @ $1.99/month. Build a man a fire, and he will be warm for the rest of the day. Light a man on fire, and will be warm for the rest of his life.
Re: [PHP] Testing for Current pointer position in array during iteration
At 2:40 PM -0400 8/29/08, Mark Weaver wrote: Hi All, Go figure... I sat down today to get some more work on my current project; I got to a certain point where I need to step through an array with a foreach loop. I found that I need to test for the current pointer position of the array, but I haven't a clue as to how this might be accomplished. I've been all over google and php.net, but I'm not finding anything that will help me do this. Basically all I want to do is something like this: if( current_arrayPointer_postition == n ){ ... do this }else{ ...do this } Anyone know of a built-in PHP function that can assist with this, or can you point me to a resource that could help me code a solution? Try looking at current http://www.php.net/current Maybe that will help. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing for Current pointer position in array during iteration
Dan Joseph schreef: On Fri, Aug 29, 2008 at 2:40 PM, Mark Weaver [EMAIL PROTECTED] wrote: ... This may also help as well as Jochem's suggestion: http://us2.php.net/key not unless you wan't a headache (re-read the bit about foreach's internal pointer): php -r '$r = array(a,b,c); next($r); $K = key($r); foreach ($r as $k = $v) { echo $K , key($r), $k\n; }' outputs: 1 1 0 1 1 1 1 1 2 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing for Current pointer position in array during iteration
Jochem Maas wrote: Mark Weaver schreef: Hi All, Go figure... I sat down today to get some more work on my current project; I got to a certain point where I need to step through an array with a foreach loop. I found that I need to test for the current pointer position of the array, but I haven't a clue as to how this might be accomplished. I've been all over google and php.net, but I'm not finding anything that will help me do this. Basically all I want to do is something like this: if( current_arrayPointer_postition == n ){ ... do this }else{ ...do this } foreach isn't really like that. it uses (IIRC) an internal pointer of it's own leaving the userland pointer where ever it is. but: $n = 5; // make a new array with numeric keys starting at 0 $array = array_values(array); // loop it foreach ($array as $key = $val) { if ($key == $n) { echo I got five on it; } else { echo usual suspect; } } very nice... Thank you Jochem. That did the trick. -- Mark It was good to be the fire... Better by far than to crawl and mew and suck and shit and die! 'Arthur C. Clarke' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing for Current pointer position in array during iteration
tedd wrote: At 2:40 PM -0400 8/29/08, Mark Weaver wrote: Hi All, Go figure... I sat down today to get some more work on my current project; I got to a certain point where I need to step through an array with a foreach loop. I found that I need to test for the current pointer position of the array, but I haven't a clue as to how this might be accomplished. I've been all over google and php.net, but I'm not finding anything that will help me do this. Basically all I want to do is something like this: if( current_arrayPointer_postition == n ){ ... do this }else{ ...do this } Anyone know of a built-in PHP function that can assist with this, or can you point me to a resource that could help me code a solution? Try looking at current http://www.php.net/current Maybe that will help. Cheers, tedd Thanks all for the helpful suggestions. Actually Jochem's suggestion was just what I needed. I was stuck at just how to test where the pointer was and couldn't see a way out. I knew there had to be a simple, elegant solution, but apparently was over-thinking it. Jochem put things back into perspective for me. -- Mark It was good to be the fire... Better by far than to crawl and mew and suck and shit and die! 'Arthur C. Clarke' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing for Current pointer position in array during iteration
Mark Weaver schreef: tedd wrote: ... Try looking at current http://www.php.net/current Maybe that will help. not in the context of foreach() (I'll repeat the oneliner here because tedd's old and has a crap email client ;-): php -r '$r = array(a,b,c); next($r); $K = key($r); foreach ($r as $k = $v) { echo $K , key($r), $k\n; }' current() is akin to key() in that they both work on where the array pointer currently is. not that current() returns a key ;-) Jochem put things back into perspective for me. I'm having that printed on a T-Shirt :-P -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing for Current pointer position in array during iteration
At 11:10 PM +0200 8/29/08, Jochem Maas wrote: Mark Weaver schreef: Jochem put things back into perspective for me. I'm having that printed on a T-Shirt :-P Damn! You get more T-Shirts than me. :-) Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] testing my being subscribed
You are indeed. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Govinda wrote: am I subscribed? I had to check. The other (php-install) list just sent me emails (when I tried to post) saying I was abusing the system (even though I am sure I subscribed properly and received the email confirming that fact). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing HTTPS without certificate
just use a self-signed cert. there should be a lot of examples out there for that. On 4/23/08, Ken Kixmoeller [EMAIL PROTECTED] wrote: Hi - - - - -- I have a typical setup -- my development machine, a testing server and, of course, the production server. My development machine, of course, doesn't have a Secure certificate, yet I need to be able to test https pages here, before getting to the testing server. (Currently, the testing server doesn't have one either, but that will be remedied shortly.) I know how to test for the existance of HTTPS, and stuff like that. So: Can one test https on a local machine? Resources, anyone? I have Googled my fingers off. Environment: PHP 5.2.5 Win 2K IIS 5 - or, if I need to - Mac OS-X 10.4 Apache? (I haven't set up the Mac as a server) - or - Linux (Ubuntu) with Apache (I am moving this direction and haven't yet learned how to run Apache) 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
Re: [PHP] testing
PHP General Users Mailing List wrote: testing so I wasn't imagining things then? -- Mark - the rule of law is good, however the rule of tyrants just plain sucks! Real Tax Reform begins with getting rid of the IRS. == Powered by CentOS5 (RHEL5) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing people
Thats why I love this list... people share and help so unselfishly. Thanks Rich, sure didnt think of the way you wrote the solution till i read your code! Have a fab one! Richard Lynch [EMAIL PROTECTED] wrote: I thought of having a hidden text box everytime for each question... but that can be quite easily found out... any other suggestions? Don't send the correct answer to the browser at all. And don't tie the ABCD to the correct answer. $question[47] = Which animal flies around at night and sleeps in the day? $answer[13] = 'cat'; $answer[14] = 'dog'; $answer[15] = 'trout'; $answer[16] = 'bat'; $correct[47] = 'bat'; ? Your HTML could look like this: A [input] cat B [input] dog C [input] trout D [input] bat To test if the answer is correct: $q = $_REQUEST['q']; foreach($q as $index = $a){ if ($correct[$index] == $a) echo CORRECT; else echo INCORRECT: Correct is $correct[$index]; echo \n; } You could also use the index to $answer as the value with: $correct[47] = 16; [input] bat if ($correct[$index] == $a){ and all the other code the same. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) - Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less.
Re: [PHP] Testing people
Thanks! Will give it a look-see! Cheers! Dotan Cohen [EMAIL PROTECTED] wrote: It's not exactly what you describe, but you should take a look at: http://www.bigredspark.com/survey.html Dotan Cohen http://what-is-what.com 7 -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) - Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1cent;/min.
Re: [PHP] Testing people
On Thu, 2006-10-05 at 03:36 -0700, Ryan A wrote: Hey all, this is a two part question but I need just one solution: Done. Go to http://avoir.uwc.ac.za/ and download Kewl.NextGen. Then install it and use the moduleadmin to install MCQ (multiple Choice Questions) module. It does everything (and more) that you need. If you need help, join either (or both) the users list and the developers list. --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing people
how are you getting the answers? are they hard coded in html? are you pulling them from a database? if from a database, just order them randomly.. mysql_query(select answers from table where question = '10' ORDER BY RAND() ); i think this would randomize all of the results in the answer colum of the table. then you could use a while loop to display the answers with radio buttons on your test page. this may not be the best method and it will not work if your answers are html. - Original Message - From: Ryan A [EMAIL PROTECTED] To: php php php-general@lists.php.net Sent: Thursday, October 05, 2006 3:36 AM Subject: [PHP] Testing people Hey all, this is a two part question but I need just one solution: 1. Can you recommend a good testing software where the choices are multiple choice (cross a button or radio button) if nothing great out there... will make this myself so, on to point 2: 2. I have noticed if you are displaying 4 (a-d) choices and the answer for question 10 (for example) is always on choice B it kind of sticks in the head and students dont really read everything they just memorize the location of the answer (maybe unconsciously) and click that.. i have an idea of making the answers jump around for example: once the correct answer for question 10 is B, if you reload the page, it would be C, reload again and its A (chosen randomly...) (real) example 2: What has two legs: a: an elephant b: a dog c: a bird d: a cat C is the correct answer of course... but if you reload the page: a: a bird b: an elephant c: a dog d: a cat now A is the correct answer. I thought of having a hidden text box everytime for each question... but that can be quite easily found out... any other suggestions? Thanks! Ryan -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) - All-new Yahoo! Mail - Fire up a more powerful email and get things done faster. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing people
Thanks for replying guys. Paul, Will check out the links you sent me, If its really as good as you say... should save me a heck of a time coding it, thanks! Cheers! Ryan Paul Scott [EMAIL PROTECTED] wrote: On Thu, 2006-10-05 at 03:36 -0700, Ryan A wrote: Hey all, this is a two part question but I need just one solution: Done. Go to http://avoir.uwc.ac.za/ and download Kewl.NextGen. Then install it and use the moduleadmin to install MCQ (multiple Choice Questions) module. It does everything (and more) that you need. If you need help, join either (or both) the users list and the developers list. --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) - Get your own web address for just $1.99/1st yr. We'll help. Yahoo! Small Business.
Re: [PHP] Testing people
On Thu, October 5, 2006 5:36 am, Ryan A wrote: 2. I have noticed if you are displaying 4 (a-d) choices and the answer for question 10 (for example) is always on choice B it kind of sticks in the head and students dont really read everything they just memorize the location of the answer (maybe unconsciously) and click that.. i have an idea of making the answers jump around So put them out in random order. [shrug] I thought of having a hidden text box everytime for each question... but that can be quite easily found out... any other suggestions? Don't send the correct answer to the browser at all. And don't tie the ABCD to the correct answer. ?php $question[47] = Which animal flies around at night and sleeps in the day? $answer[13] = 'cat'; $answer[14] = 'dog'; $answer[15] = 'trout'; $answer[16] = 'bat'; $correct[47] = 'bat'; ? Your HTML could look like this: A input type=radio name=q[47] value=cat / cat B input type=radio name=q[47] value=dog / dog C input type=radio name=q[47] value=trout / trout D input type=radio name=q[47] value=bat / bat To test if the answer is correct: $q = $_REQUEST['q']; foreach($q as $index = $a){ if ($correct[$index] == $a) echo CORRECT; else echo INCORRECT: Correct is $correct[$index]; echo br /\n; } You could also use the index to $answer as the value with: $correct[47] = 16; input type=radio name=q[47] value=16 / bat if ($correct[$index] == $a){ and all the other code the same. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing people
It's not exactly what you describe, but you should take a look at: http://www.bigredspark.com/survey.html Dotan Cohen http://what-is-what.com 7 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] testing 234
On Fri, 2006-03-17 at 01:47, John Taylor-Johnston wrote: Are any of my posts getting through? They don't appear to be. This one only made it halfway :P Cheers, Rob. -- .. | 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
Re: [PHP] testing 234
Are any of my posts getting through? They don't appear to be. This one only made it halfway :P Yeah, it doesn't seem to accept my email from another address. Thanks Rob. I was trying to post something last night and it never got through. This email seems acceptable to the group Gods. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing
[EMAIL PROTECTED] wrote: I am conducting a test of my new e-mail address. This is only a test. If this were not a test you would be instructed to tune into your locale emergency sarcasm system. Please RTFM and Have a PHP Day! Dork. ;) -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] testing text body emails
If you have a linux box, use mutt or pine. Also, most Windows mail clients allow you to turn off HTML mail. Check your client documentation / help files. Brady -Original Message- From: Mark Steudel [mailto:[EMAIL PROTECTED] Sent: Monday, February 13, 2006 1:40 PM To: php-general@lists.php.net Subject: [PHP] testing text body emails Im using phpmailer to send emails, with htmlbody and an alternate textbody. Any suggestions on how to test the text only body? Thanks, Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] testing text body emails
Mark Steudel wrote: Im using phpmailer to send emails, with htmlbody and an alternate textbody. Any suggestions on how to test the text only body? Thanks, Mark Sure. Use a text-only MUA?* /rimshot But, seriously, most 'Nix gurus have access to text only mail if they care to. If you've a friend who's always preaching about open sores, you might call him up. Also, several web-mail solutions are text-only, or have that option, IIRC. Although it's been a while since I used hotmail or excite, etc., you might take a look. HTH, Kevin Kinsey *I'm not joking too much about the MUA, just the answer. I actually like mutt a good deal... -- The most winning woman I ever knew was hanged for poisoning three little children for their insurance money. -- Sherlock Holmes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] testing on a local server
[snip] i am new to PHP and web programming/management in general... Using Dreamweaver I am trying to preview .php files on the local server, but the page won't show up in a web browser. This is probably a stupid question, but does that just mean I need to install PHP on my computer? [/snip] You need to install PHP on your local server. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] testing on a local server
http://www.php.net/manual/en/tutorial.php#tutorial.requirements [EMAIL PROTECTED] wrote: i am new to PHP and web programming/management in general... Using Dreamweaver I am trying to preview .php files on the local server, but the page won't show up in a web browser. This is probably a stupid question, but does that just mean I need to install PHP on my computer? This message was sent using IMP, the Internet Messaging Program. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] testing on a local server
i am using a PC with Windows XP, i don't have Apache. i was looking at the downloads page on php.net - how do i know which one i need? i am new to PHP and web programming/management in general... Using Dreamweaver I am trying to preview .php files on the local server, but the page won't show up in a web browser. This is probably a stupid question, but does that just mean I need to install PHP on my computer? Sounds like it, yeah. What server? What kind of computer? May just be change apache config. -dg This message was sent using IMP, the Internet Messaging Program. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] testing on a local server
[snip] i am using a PC with Windows XP, i don't have Apache. i was looking at the downloads page on php.net - how do i know which one i need? [/snip] Go look at this http://www.devside.net/web/server/free/suite -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] testing on a local server
i'm not sure if my messages are getting through...but i'm trying to download the PHP installer - where it asks which type of http server i want to configure, how do i find out what i have? it would be one of the microsoft servers, but i have no idea which... Quoting [EMAIL PROTECTED]: i am new to PHP and web programming/management in general... Using Dreamweaver I am trying to preview .php files on the local server, but the page won't show up in a web browser. This is probably a stupid question, but does that just mean I need to install PHP on my computer? This message was sent using IMP, the Internet Messaging Program. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php This message was sent using IMP, the Internet Messaging Program. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] testing on a local server
Well Jay was showing you where you could pick up everything you needed. On Windows XP the IIS server is not installed by default you have to select it as a component to install, so I'm not sure if you would have IIS installed either. If you want a simple and quick solution go to the link that Jay sent and download that installer you'll get Apache/PHP/MySQL and some other tools for development. Good luck On 11/18/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: i'm not sure if my messages are getting through...but i'm trying to download the PHP installer - where it asks which type of http server i want to configure, how do i find out what i have? it would be one of the microsoft servers, but i have no idea which... Quoting [EMAIL PROTECTED]: i am new to PHP and web programming/management in general... Using Dreamweaver I am trying to preview .php files on the local server, but the page won't show up in a web browser. This is probably a stupid question, but does that just mean I need to install PHP on my computer? This message was sent using IMP, the Internet Messaging Program. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php This message was sent using IMP, the Internet Messaging Program. -- 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] Testing on the local server
[snip] I use Dreamweaver and I try to test the files on the local host, but the page doesn't even show up. This maybe a stupid question..but to test on a local server, would I just need to download PHP? [/snip] Deja Vu? Did you install the package on your server that I recommended? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Testing on the local server
allison not familiar with dreamweaver to know if it can act as a webserver. i strongly suspect that it's simply an editor, but not an actual server, that can be used to interpret/display php code. that said, you'll have to have access to a webserver. IIS is a webserver from msoft. apache is a webserver from the open source community. there are other servers as well you'll need to decide which, if any, you need/want to setup. you might be better served by telling the list just what you're trying to accomplish. do you already have a webserver where your dreamweaver files are being displayed? the other suggestions that you've gotten have been from people who've pointed you to all in one apps. this may/may not be the best solution for you. -bruce -Original Message- From: Allison [mailto:[EMAIL PROTECTED] Sent: Friday, November 18, 2005 9:03 AM To: php-general@lists.php.net Subject: [PHP] Testing on the local server First of all, I'm completely new to PHP and pretty new to web programming/management in general, so if you respond, try not to use any really complex terms or anything that I may not understand! right now I have an existing PHP site that I downloaded for editing. But I am having problems viewing/testing .php documents. This one may be just a more general question not necessarily PHP-related... The server contains a folder of includes that are on every page (e.g. the header and footer, navigation bar, etc) - and all of these files are in .php format. I try to view these .php files on the web server just to see what they look like, and it says Access Denied, even though I've set the properties to allow all users to read the files in this folder. How can I view these? I use Dreamweaver and I try to test the files on the local host, but the page doesn't even show up. This maybe a stupid question..but to test on a local server, would I just need to download PHP? -- 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] Testing on the local server
Coincidence On 11/18/05, Jay Blanchard [EMAIL PROTECTED] wrote: [snip] I use Dreamweaver and I try to test the files on the local host, but the page doesn't even show up. This maybe a stupid question..but to test on a local server, would I just need to download PHP? [/snip] Deja Vu? Did you install the package on your server that I recommended? -- 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] Testing a String for 'most' Capitalised
Image that there could be a string fred Fred FRED First of all I need to know that these are same which I can do with strtolower, but how could I tell that 'FRED' is 'most captilised? Iterate through the string and count the number of capitalised letters. You can do something like this (untested pseudocode) $myStr = Fred; $numOfCapLetters = 0; $curLetter = ''; for( $i = 0; $i = strlen( $myStr ); $i++ ) { $curLetter = $myStr{$i}; if( strtoupper( $curLetter ) == $curLetter ) { $numOfCapLetters++; } } then just compare the $numOfCapLetters for each string. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing a String for 'most' Capitalised
On 10/10/05, zzapper [EMAIL PROTECTED] wrote: Image that there could be a string fred Fred FRED First of all I need to know that these are same which I can do with strtolower, but how could I tell $a = array( 'fred', 'Fred', 'FRED' ); sort( $a ); echo $a[ 0 ]; -- Greg Donald Zend Certified Engineer MySQL Core Certification http://destiney.com/
Re: [PHP] Testing a String for 'most' Capitalised
Image that there could be a string fred Fred FRED It isn't hard to do. First of all I need to know that these are same which I can do with strtolower Also note strcasecmp for this task - http://uk2.php.net/manual/en/function.strcasecmp.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing a String for 'most' Capitalised
Greg Donald wrote: On 10/10/05, zzapper [EMAIL PROTECTED] wrote: Image that there could be a string fred Fred FRED First of all I need to know that these are same which I can do with strtolower, but how could I tell $a = array( 'fred', 'Fred', 'FRED' ); sort( $a ); echo $a[ 0 ]; cute - but it doesn't always work e.g.: $a = array( FrEDDie, fREDdIE, FReddie ); sort( $a ); echo $a[ 0 ]; // we want the 2nd item from the unsort array -- Greg Donald Zend Certified Engineer MySQL Core Certification http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing a String for 'most' Capitalised
On 10/10/05, Jochem Maas [EMAIL PROTECTED] wrote: cute - but it doesn't always work e.g.: $a = array( FrEDDie, fREDdIE, FReddie ); sort( $a ); echo $a[ 0 ]; // we want the 2nd item from the unsort array Works for the sample data you first posted. *shrug* -- Greg Donald Zend Certified Engineer MySQL Core Certification http://destiney.com/
Re: [PHP] Testing a String for 'most' Capitalised
On 10/10/05, zzapper [EMAIL PROTECTED] wrote: Hi, Image that there could be a string fred Fred FRED First of all I need to know that these are same which I can do with strtolower, but how could I tell that 'FRED' is 'most captilised? ?php $strings = array( 'fred', 'Fred', 'fRED', 'fReD' ); print array_reduce($strings, 'mostUpper'); function mostUpper($a, $b) { return strlen(preg_replace('/[^[:upper:]]/', '', $a)) strlen(preg_replace('/[^[:upper:]]/', '', $b)) ? $a : $b; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing a String for 'most' Capitalised
On 10/10/05, Jochem Maas [EMAIL PROTECTED] wrote: I AM NOT THE OP THANKS, I'm quite capable of solving such a problem without the help of people who don't bother to think beyond 'sample data' ... Yeah, everyone should read minds automatically, I agree. It's bloody obvious that the data in question (sample or not) will not be in an order that means the string with the most capital letters will be 'top of the list' after a sort(). No sense in getting your panties in a bloody wad. Did I say that right? I so rarely get to use 'bloody' in programming conversation. The code I posted works with the sample data provided. Sorry if it bothers you that I didn't test it with a full dictionary word list. *shrug* is rather blasee btw. http://dictionary.reference.com/search?q=blasee Blase? Why yes.. that's me in a nutshell. -- Greg Donald Zend Certified Engineer MySQL Core Certification http://destiney.com/
Re: [PHP] Testing a String for 'most' Capitalised
Greg Donald wrote: On 10/10/05, Jochem Maas [EMAIL PROTECTED] wrote: I AM NOT THE OP THANKS, I'm quite capable of solving such a problem without the help of people who don't bother to think beyond 'sample data' ... Yeah, everyone should read minds automatically, I agree. I guess reading the question was out of the question? and as for me not being the OP - might I suggest a decent new reader or mail client so you can actually view the thread structure? It's bloody obvious that the data in question (sample or not) will not be in an order that means the string with the most capital letters will be 'top of the list' after a sort(). No sense in getting your panties in a bloody wad. Did I say that right? I so rarely get to use 'bloody' in programming conversation. you didn't say that right IFAICT. try exchanging 'wad' for 'panties' - now you have an idiom. The code I posted works with the sample data provided. Sorry if it right. but it doesn't answer the question, so you have probably confused the OP (or the confusion will arise some four weeks after having implemented your suggestion when he realises _something_ is not working as it should) - although given the direction of this thread he has no more excuse for not knowing that your cute trick will get him into 'trouble'. bothers you that I didn't test it with a full dictionary word list. the oxford abridged version would have sufficed. ;-) *shrug* is rather blasee btw. http://dictionary.reference.com/search?q=blasee Blase? Why yes.. that's me in a nutshell. my point being that 'blase' is not a positive attribute for an engineer. we can agree to disagree on that one though! the blase NASA launch engineer didn't bother to check the fuel line all the way through because it had passed all the checks on a previous run. BOOM -- Greg Donald Zend Certified Engineer MySQL Core Certification http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing for an empty array (with null values)
zzapper wrote: Hi, I can use if (count($somearray) 0) to test for an empty array. why don't you test it. $a = array(); $b = array(null, null, null); $c = array(false, false); $d = array(1, 1, 1); echo array \$a: \n---\n; var_dump(empty($a), count($a), array_filter($a), array_values($a)); echo array \$b: \n---\n; var_dump(empty($b), count($b), array_filter($b), array_values($b)); echo array \$c: \n---\n; var_dump(empty($c), count($c), array_filter($c), array_values($c)); echo array \$d: \n---\n; var_dump(empty($d), count($d), array_filter($d), array_values($d)); It is possible to have an array with null values which is effectively empty but fails the above as it's count (I belive is greater than 0). look above. Any ideas plenty. hopefully the code above give you a few too :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing for an empty array (with null values)
Better use is empty(), which supports array as parameter: $test = array(); if(empty($test)) // true { // code... } else // false { } Emil Novak, Slovenia, EU -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing Response of A Proxy with PHP?
* and then Marek Kilimajer declared oookay... i think i understand the page, but how would i imlement that $fp = fsockopen (proxy.server.net, 8080, $errno, $errstr, 30); if (!$fp) { echo $errstr ($errno)br\n; } else { fputs ($fp, OPTIONS * HTTP/1.0\r\nMax-Forwards: 0\r\n\r\n); while (!feof($fp)) { echo fgets ($fp,128); } fclose ($fp); } You should get something like: HTTP/1.0 200 Ok Date: Sun, 26 Sep 2004 20:48:46 GMT Via: HTTP/1.1 proxy.server.net (Traffic-Server/4.0.18 [c s f ]) Allow: CONNECT, DELETE, GET, HEAD, OPTIONS, POST, PURGE, PUT, PUSH, TRACE Content-Length: 0 Well, it connects great! However, i get errors back about * being a bad url...? -- Nick W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing Response of A Proxy with PHP?
Nick Wilson wrote: hi again all, I cant find any functions that might help me test the response of a proxy server b4 attempting to use it. Do i need to use exec() with ping? Anyone know how to do that? (if that's the case...) mucho grassy arse.. What kind of response? If the server is alive, if the proxy is alive? If an url exists? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing Response of A Proxy with PHP?
* and then Marek Kilimajer declared I cant find any functions that might help me test the response of a proxy server b4 attempting to use it. Do i need to use exec() with ping? Anyone know how to do that? (if that's the case...) What kind of response? If the server is alive, if the proxy is alive? If an url exists? hehe, good point! Just if the server is alive i guess. I want to use the proxy and want to test if it's responsive b4 i attempt to use it... -- Nick W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing Response of A Proxy with PHP?
Nick Wilson wrote: * and then Marek Kilimajer declared I cant find any functions that might help me test the response of a proxy server b4 attempting to use it. Do i need to use exec() with ping? Anyone know how to do that? (if that's the case...) What kind of response? If the server is alive, if the proxy is alive? If an url exists? hehe, good point! Just if the server is alive i guess. I want to use the proxy and want to test if it's responsive b4 i attempt to use it... OPTIONS * HTTP/1.0 More at http://www.freesoft.org/CIE/RFC/2068/63.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing Response of A Proxy with PHP?
* and then Marek Kilimajer declared OPTIONS * HTTP/1.0 More at http://www.freesoft.org/CIE/RFC/2068/63.htm oookay... i think i understand the page, but how would i imlement that and what would be the difference in that and just pinging the server to see if it's responding? Thanks for the help.. -- Nick W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing Response of A Proxy with PHP?
Nick Wilson wrote: * and then Marek Kilimajer declared OPTIONS * HTTP/1.0 More at http://www.freesoft.org/CIE/RFC/2068/63.htm oookay... i think i understand the page, but how would i imlement that $fp = fsockopen (proxy.server.net, 8080, $errno, $errstr, 30); if (!$fp) { echo $errstr ($errno)br\n; } else { fputs ($fp, OPTIONS * HTTP/1.0\r\nMax-Forwards: 0\r\n\r\n); while (!feof($fp)) { echo fgets ($fp,128); } fclose ($fp); } You should get something like: HTTP/1.0 200 Ok Date: Sun, 26 Sep 2004 20:48:46 GMT Via: HTTP/1.1 proxy.server.net (Traffic-Server/4.0.18 [c s f ]) Allow: CONNECT, DELETE, GET, HEAD, OPTIONS, POST, PURGE, PUT, PUSH, TRACE Content-Length: 0 and what would be the difference in that and just pinging the server to see if it's responding? Even if the server is up that does not mean proxy is working. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing Response of A Proxy with PHP?
* and then Marek Kilimajer declared oookay... i think i understand the page, but how would i imlement that $fp = fsockopen (proxy.server.net, 8080, $errno, $errstr, 30); if (!$fp) { echo $errstr ($errno)br\n; } else { fputs ($fp, OPTIONS * HTTP/1.0\r\nMax-Forwards: 0\r\n\r\n); while (!feof($fp)) { echo fgets ($fp,128); } fclose ($fp); } Okay, thanks marek, i can take it from there ;-) Im tired, its past my bedtime, i'll check the manual in the morning and work on your code. Thanks very, very much! Even if the server is up that does not mean proxy is working. Yep, i get it. THanks.. -- Nick W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Testing if cookies are enabled
Martin Schneider wrote: I saw this on some pages and want to do the same: - On one page the user can login. Before that no cookie is set! - On the next page they set the cookie and show either the user data or a warning that the user has disabled cookies and should enable them. I wasn't able to set and text a cookie on the same page! How is it done? Probably wasn't done on the same page. Here's my guess at how these sites do that: (1) User visits login page, no cookie is set. (2) User enters username and password in the login page form, clicks the submit button, and the login page form posts back to itself. (3) The login page has logic at the top to check and see if the form has been posted...if so it verifies the user's credentials, sets a cookie, and then redirects to the first page of the application. (4) The first page of the application (main menu or whatever) checks to see if a cookie has been provided. If not, it displays the warning that the user has disabled cookies. So, the app sets the cookie and then immediately redirects to the page that checks the cookie. To the end user it would appear that the cookie was set and checked in the same page. HTH... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] testing array_search
What output do you get? I'm having a very hard time testing array_search. $j = array_search( $i, $errList ); echo j= . $j; if (($j != false) ($j = 0)) { -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] testing array_search
* Thus wrote Bob Lockie ([EMAIL PROTECTED]): I'm having a very hard time testing array_search. $j = array_search( $i, $errList ); echo j= . $j; if (($j != false) ($j = 0)) { snip mixed array_search ( mixed needle, array haystack [, bool strict]) Searches haystack for needle and returns the key if it is found in the array, FALSE otherwise. /snip When ever you see that a function that returns mixed with a possible FALSE Boolean value. You must always test your result as follows: if ($j !== FALSE) { // found an item } else { // no item found } Curt -- First, let me assure you that this is not one of those shady pyramid schemes you've been hearing about. No, sir. Our model is the trapezoid! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] testing array_search
On 06/11/04 17:17 Curt Zirzow spoke: * Thus wrote Bob Lockie ([EMAIL PROTECTED]): I'm having a very hard time testing array_search. $j = array_search( $i, $errList ); echo j= . $j; if (($j != false) ($j = 0)) { snip mixed array_search ( mixed needle, array haystack [, bool strict]) Searches haystack for needle and returns the key if it is found in the array, FALSE otherwise. /snip When ever you see that a function that returns mixed with a possible FALSE Boolean value. You must always test your result as follows: if ($j !== FALSE) { // found an item } else { // no item found } Ok, I supected it was a boolean thing. :-( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] testing ip filtering
Merlin wrote: Hi there, I am serving certain parts of my page only to specific countries (geotargeted advertisement). Now I am wondering how I could check how the page looks like from that country wihout traveling there :-) Is there a way to fool the system that one is in US instead of Germany? Thanx for any advice, Merlin You need to get around the way you find out the country, for example: if(DEBUG isset($_GET['country'])) { $country = $_GET['country']; } else { $country = get_country_from_ip($_SERVER['REMOTE_ADDR']); } Hope this code makes it clear ;-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing Pear install
On Wed, 2004-03-03 at 12:21, DAvid Jackson wrote: How can I test to see if and what portions of Pear are installed on a vhosted website? If you have access to the command line pear you can also check with a simple command: $ pear list -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] testing a variable
[snip] if ( !isset($var ) { echo do something;} [/snip] self answering questions, gotta' love 'em! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] testing a variable
From: Adam Williams [EMAIL PROTECTED] I need to test a variable to see if it contains a value or not, and if not, do something. [snip] if ( !isset($var ) { echo do something;} That's the correct way. What I am doing is checking a field in an sql table, and if the field is null, empty, etc... then do something. so what is the best way to check the field if its null, empty, etc...? The variable might be set, yet empty, though. So you may want to add if(!isset($var) || empty($var)) { echo do something; } ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] testing a variable
Adam Williams said the following on 11/12/2003 11:37 AM Hello, I need to test a variable to see if it contains a value or not, and if not, do something. My php is a little rusty, so which would be better? if ( !$var ) { echo do something;} or if ( !isset($var ) { echo do something;} or are both of those wrong, and if so, how hsoudl I check if a variable is false, null, doesn't contain a value, etc... What I am doing is checking a field in an sql table, and if the field is null, empty, etc... then do something. so what is the best way to check the field if its null, empty, etc...? if (!isset($var) or empty($var) ) { echo do something; } HTH R'twick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] testing a variable
--- Adam Williams [EMAIL PROTECTED] wrote: I need to test a variable to see if it contains a value or not, and if not, do something. My php is a little rusty, so which would be better? This is a good page for understanding how things like isset(), is_null(), and empty() work: http://www.blueshoes.org/en/developer/php_cheat_sheet Hope that helps. Chris = My Blog http://shiflett.org/ HTTP Developer's Handbook http://httphandbook.org/ RAMP Training Courses http://www.nyphp.org/ramp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Testing string length within FTP
[snip] for($i = 0; $i $countList; $i++){ $strDirName = substr($arrList[$i], 47, 8); if(strlen(chop($strDirName)) == 8){ echo $theDirectory.$strDirName.br; } } [/snip] Never mind. I am making them all 8 wide, just saw it. *slaps feverish forhead* -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing Variables
on 10/1/03 8:23 PM, Gerard Samuel at [EMAIL PROTECTED] wrote: I've noticed code written in this order - if (FALSE === $foo) { // yada yada } Is there a reason/benefit to test variables like that instead of - if ($foo === FALSE) { // yada yada } Thanks I think it's more to catch errors.. for example.. if I typed this: if ($foo = FALSE) You will not get an error since you are assigning $foo the value of FALSE while if you did this: if (FALSE = $foo) PHP will throw up an error because you can not assign FALSE the value of $foo :) That's the only reason that I can think of. Cheers! Rick You've got to stand for something or you will fall for anything - Unknown -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing Variables
* Thus wrote Richard Baskett ([EMAIL PROTECTED]): on 10/1/03 8:23 PM, Gerard Samuel at [EMAIL PROTECTED] wrote: I've noticed code written in this order - if (FALSE === $foo) { // yada yada } Is there a reason/benefit to test variables like that instead of - if ($foo === FALSE) { // yada yada } Thanks I think it's more to catch errors.. for example.. if I typed this: if ($foo = FALSE) You will not get an error since you are assigning $foo the value of FALSE while if you did this: if (FALSE = $foo) PHP will throw up an error because you can not assign FALSE the value of $foo :) That's the only reason that I can think of. Yep. Just make sure you dont start speaking english like that, people will look at you funny, or think your yoda :) if ('away' == $put_your_weapon) { $harm = false; } /* Away put your weapon, I mean you no harm */ or if ( 'help' == $you_can ) { hmm(); } /* Help you can, Hmm! */ Or more popular: if ($do || false == $do ) { try(); } /* Do, or do not. There is no try. */ Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing Variables
--- Curt Zirzow [EMAIL PROTECTED] wrote: if ($do || false == $do ) { try(); } /* Do, or do not. There is no try. */ Isn't there always try? :-) Chris = HTTP Developer's Handbook http://httphandbook.org/ RAMP Training Courses http://www.nyphp.org/ramp My Blog http://shiflett.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing Variables
* Thus wrote Chris Shiflett ([EMAIL PROTECTED]): --- Curt Zirzow [EMAIL PROTECTED] wrote: if ($do || false == $do ) { try(); } /* Do, or do not. There is no try. */ Isn't there always try? :-) Only in php5 :) Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing Variables
Curt Zirzow wrote: Yep. Just make sure you dont start speaking english like that, people will look at you funny, or think your yoda :) if ('away' == $put_your_weapon) { $harm = false; } /* Away put your weapon, I mean you no harm */ or if ( 'help' == $you_can ) { hmm(); } /* Help you can, Hmm! */ Or more popular: if ($do || false == $do ) { try(); } /* Do, or do not. There is no try. */ Definately funny :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing Variables
* Thus wrote Curt Zirzow ([EMAIL PROTECTED]): * Thus wrote Chris Shiflett ([EMAIL PROTECTED]): --- Curt Zirzow [EMAIL PROTECTED] wrote: if ($do || false == $do ) { try(); } /* Do, or do not. There is no try. */ Isn't there always try? :-) Only in php5 :) oops, you were pointing out the flaw in the logic, here I'll correct it: while ($do || false == $do ) have_fun(); try(); Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] testing for 0
See isset() and empty() -Original Message- From: Steve Buehler [mailto:[EMAIL PROTECTED] Sent: Friday, February 28, 2003 10:29 AM To: PHP Subject: [PHP] testing for 0 I have a form that has input for minutes. My problem is that I am trying to test to see if the field is blank or not and if they enter a 0 (zero), my test always show it as blank. I have tried !$timemb and !is_numeric($timemb). Thank You Steve -- 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] testing for 0
Try $timeb ''. Steve Buehler wrote: I have a form that has input for minutes. My problem is that I am trying to test to see if the field is blank or not and if they enter a 0 (zero), my test always show it as blank. I have tried !$timemb and !is_numeric($timemb). Thank You Steve -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] testing for 0
At 19:28 28.02.2003, Steve Buehler spoke out and said: [snip] I have a form that has input for minutes. My problem is that I am trying to test to see if the field is blank or not and if they enter a 0 (zero), my test always show it as blank. I have tried !$timemb and !is_numeric($timemb). [snip] How about some code? -- O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] testing for 0
There we go. Thank You so much. I also found that I had another error in my script and !is_numeric($timemb) did work after all. Steve At 10:41 AM 2/28/2003 -0800, you wrote: See isset() and empty() -Original Message- From: Steve Buehler [mailto:[EMAIL PROTECTED] Sent: Friday, February 28, 2003 10:29 AM To: PHP Subject: [PHP] testing for 0 I have a form that has input for minutes. My problem is that I am trying to test to see if the field is blank or not and if they enter a 0 (zero), my test always show it as blank. I have tried !$timemb and !is_numeric($timemb). Thank You Steve -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] testing for 0
On February 28, 2003 10:41 am, Leif K-Brooks wrote: Try $timeb ''. Well whatta ya know I learn something new every day.. I thought the only valid not equal operator was !=... I'm used to using only for SQL server stored procedures or VB.. leo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing if any of the items are false
--- [EMAIL PROTECTED] wrote: How can I do this to determine if one of the items is false if none are then I what it to print the first echo of there is one that is false then print the second echo Sorry, that makes no sense to me. $test1= YES; $test2= YES; $test3= YES; $test4= YES; $ftest1= YES; $ftest2= NO; $ftest3= YES; $ftest4= YES; if ($test1==$ftest1)or($test2==$ftest2)or($test3==$ftest3) or($test4==$ftest4){ echo all of the items are true; }else{ echo one of the items is false; } That code makes less sense. Are you wanting to see if each of your $test variables match their corresponding $ftest variable? Your current statement is true when any of the $test variables match their corresponding $ftest variable. Try using and instead of or if you want to require them all to be true. Just read it aloud, and it should make sense. if ($flavor == 'vanilla' || $flavor == 'chocolate') { eat('ice_cream'); } In this example, you would eat the ice cream if it was vanilla *or* chocolate. Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing..
working :) On Sun, 9 Feb 2003, Troy May wrote: Just a quick test. I just re-signed up for this list after a 3 week vacation and I haven't seen even one message yet. So, reply if you get it please so I know this is working. Thanks, Troy -- 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] testing for negative numbers
Please provide a complete test script. Are you perhaps not realizing that array indices along with all variables in PHP are case sensitive? $row[ID] and $row[id] are not the same thing. The trivial test of your example: $myArray[id] = -2; if ($myArray[id] 0) echo Negative; else echo Positive; Prints Negative as expected. -Rasmus On Thu, 6 Feb 2003, Robert Samuel White wrote: I realize this should be about the simplest thing in the world to do, but for this reason or that it's not working... I'm using PHP version 4.2.3 Whether I have a negative number in an array, for example: $myArray[ID] = -2 Or the number comes from the database, for example: $row[id] = -2 I cannot get this simple operation to work: if ($row[id] 0) Instead, positive or negative, it seems to think this expression is always true: if ($row[id] 0) It's like it takes the absolute value of the number (whether the number is 2 or -2, it thinks it is 2) I've tried many things, including type casting using (int) in front of the expression. Nothing has worked. Any ideas why in the world this is happening? Thanks. -- 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] testing for negative numbers
Hi Rasmus: Yes, I'm totally aware of case sensitivity...and basically the script you wrote here is exactly what I'm trying to doing. This is a problem I've been having with several scripts...always when the number is negative. I've also echoed my variables just to make sure they are in fact negative numbers. This is an odd thing I've been dealing with for a while now. This only happens when the value is negative. But anyway, here's the part of the script I'm encountering the problem at: $result = $Database-Query(SELECT * FROM .DBT__MATRIX_STRUCTURE_CONTENT. WHERE content_id = '.$tmpParentId.'); while ($row = $Database-FetchArray($result)) { $tmpArray[$tmpCount][ID-PARENT] = $row[parent_id]; $tmpArray[$tmpCount][ID-DIR]= $row[dir_id]; $tmpArray[$tmpCount][TYPE] = $row[content_type]; $tmpArray[$tmpCount][FILE] = $row[content_file]; $tmpArray[$tmpCount][TITLE] = $row[content_title]; $tmpArray[$tmpCount][VERSION] = $row[content_version]; if ($row[dir_id] 0) { $resultc = $Database-Query(SELECT * FROM .DBT__MATRIX_STRUCTURE_DIR. WHERE dir_id = '.$row[dir_id].'); while ($rowc = $Database-FetchArray($resultc)) { $tmpArray[$tmpCount][PATH] = $rowc[dir_path]; } $Database-FreeResult($resultc); } if ((int)$row[dir_id] 0) { $resultc = $Database-Query(SELECT * FROM .DBT__MATRIX_STRUCTURE_ROUTES. WHERE dir_id = '.$row[dir_id].'); while ($rowc = $Database-FetchArray($resultc)) { $tmpArray[$tmpCount][ALIAS] = $rowc[dir_alias]; $tmpArray[$tmpCount][PATH] = $rowc[dir_path]; echo xxx; exit(); } $Database-FreeResult($resultc); } Rasmus Lerdorf wrote: Please provide a complete test script. Are you perhaps not realizing that array indices along with all variables in PHP are case sensitive? $row[ID] and $row[id] are not the same thing. The trivial test of your example: $myArray[id] = -2; if ($myArray[id] 0) echo Negative; else echo Positive; Prints Negative as expected. -Rasmus On Thu, 6 Feb 2003, Robert Samuel White wrote: I realize this should be about the simplest thing in the world to do, but for this reason or that it's not working... I'm using PHP version 4.2.3 Whether I have a negative number in an array, for example: $myArray[ID] = -2 Or the number comes from the database, for example: $row[id] = -2 I cannot get this simple operation to work: if ($row[id] 0) Instead, positive or negative, it seems to think this expression is always true: if ($row[id] 0) It's like it takes the absolute value of the number (whether the number is 2 or -2, it thinks it is 2) I've tried many things, including type casting using (int) in front of the expression. Nothing has worked. Any ideas why in the world this is happening? Thanks. -- 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] testing for negative numbers
Well, I just tried your test script and that works just as it should, so I must be having some other issue. But that still doesn't explain why I can print out the results of $row[dir_id] and it shows it being -2, yet my script (as printed in the last email) never makes it to the correct conditional statement. Rasmus Lerdorf wrote: Please provide a complete test script. Are you perhaps not realizing that array indices along with all variables in PHP are case sensitive? $row[ID] and $row[id] are not the same thing. The trivial test of your example: $myArray[id] = -2; if ($myArray[id] 0) echo Negative; else echo Positive; Prints Negative as expected. -Rasmus On Thu, 6 Feb 2003, Robert Samuel White wrote: I realize this should be about the simplest thing in the world to do, but for this reason or that it's not working... I'm using PHP version 4.2.3 Whether I have a negative number in an array, for example: $myArray[ID] = -2 Or the number comes from the database, for example: $row[id] = -2 I cannot get this simple operation to work: if ($row[id] 0) Instead, positive or negative, it seems to think this expression is always true: if ($row[id] 0) It's like it takes the absolute value of the number (whether the number is 2 or -2, it thinks it is 2) I've tried many things, including type casting using (int) in front of the expression. Nothing has worked. Any ideas why in the world this is happening? Thanks. -- 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] testing for negative numbers
Is it possible that the value is actually -2 (with the space)? Robert Samuel White wrote: Well, I just tried your test script and that works just as it should, so I must be having some other issue. But that still doesn't explain why I can print out the results of $row[dir_id] and it shows it being -2, yet my script (as printed in the last email) never makes it to the correct conditional statement. Rasmus Lerdorf wrote: Please provide a complete test script. Are you perhaps not realizing that array indices along with all variables in PHP are case sensitive? $row[ID] and $row[id] are not the same thing. The trivial test of your example: $myArray[id] = -2; if ($myArray[id] 0) echo Negative; else echo Positive; Prints Negative as expected. -Rasmus On Thu, 6 Feb 2003, Robert Samuel White wrote: I realize this should be about the simplest thing in the world to do, but for this reason or that it's not working... I'm using PHP version 4.2.3 Whether I have a negative number in an array, for example: $myArray[ID] = -2 Or the number comes from the database, for example: $row[id] = -2 I cannot get this simple operation to work: if ($row[id] 0) Instead, positive or negative, it seems to think this expression is always true: if ($row[id] 0) It's like it takes the absolute value of the number (whether the number is 2 or -2, it thinks it is 2) I've tried many things, including type casting using (int) in front of the expression. Nothing has worked. Any ideas why in the world this is happening? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] testing for negative numbers
Okay, I'm an idiot. It *was* making it to the statement, but the row_id in the table matrix_structure_routes are actually positive numbers, so when it gets to that point I need to use the absolute value. The reason for using the negative and postive counterparts are to determine which type of directory it is (and therefore which table the meta information is stored in). Stupid me for not catching that first! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] testing if a query was successful
--- Sunfire [EMAIL PROTECTED] wrote: how would you use an if..else statement to test a query in mysql to see if it was successfull or not? Depends on what database server you are using. Here it is in MySQL: if (mysql_query($sql)) { echo Success; } else { echo Failure; } Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] testing if a query was successful
As quoted from the manual: A non-FALSE return value means that the query was legal and could be executed by the server. It does not indicate anything about the number of rows affected or returned. It is perfectly possible for a query to succeed but affect no rows or return no rows. Always test your query with the assumption that you will return a non-FALSE value. This is an important lesson to learn as it is more robust and can save you from quite a bit of frustration. For example.. $result = mysql_query(SELECT... ) or die(Invalid query: . mysql_error()); if (mysql_num_rows($result) == 0) { echo Query executed but no rows were selected.; exit; } $result = mysql_query(UPDATE or INSERT or DELETE... ) or die(Invalid query: . mysql_error()); if (mysql_affected_rows() == 0) { echo Query executed but no rows were affected; exit; } - Kevin - Original Message - From: Chris Shiflett [EMAIL PROTECTED] To: Sunfire [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, February 04, 2003 11:58 AM Subject: Re: [PHP] testing if a query was successful --- Sunfire [EMAIL PROTECTED] wrote: how would you use an if..else statement to test a query in mysql to see if it was successfull or not? Depends on what database server you are using. Here it is in MySQL: if (mysql_query($sql)) { echo Success; } else { echo Failure; } Chris -- 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] testing a query for success--code doesnt work
I believe as long as the update was successful (no errors) it will say 'message if successful'...I think you are wanting to know if rows were updated or not...not whether or not the query ran ok. Eddie -Original Message- From: Sunfire [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 04, 2003 3:51 PM To: [EMAIL PROTECTED] Subject: [PHP] testing a query for success--code doesnt work hi.. posted a message about what the code was to test an update query to see if it was successfull using mysql and i tested my code and for some reason even if none of the fields were updated it still reports the success message... heres the code i have: $query=mysql_query(update members set company=\$company\, ); if($query){ message if successfull... } else{ message if not or if failed..//never gets used } anybody know why this doesnt work if 0 records were changed? --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003 -- 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] testing a query for success--code doesnt work
I think you want to use mysql_affected_rows -Original Message- From: Sunfire [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 04, 2003 3:51 PM To: [EMAIL PROTECTED] Subject: [PHP] testing a query for success--code doesnt work hi.. posted a message about what the code was to test an update query to see if it was successfull using mysql and i tested my code and for some reason even if none of the fields were updated it still reports the success message... heres the code i have: $query=mysql_query(update members set company=\$company\, ); if($query){ message if successfull... } else{ message if not or if failed..//never gets used } anybody know why this doesnt work if 0 records were changed? --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003 -- 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] testing a query for success--code doesnt work
At 21:51 4-2-2003, you wrote: hi.. posted a message about what the code was to test an update query to see if it was successfull using mysql and i tested my code and for some reason even if none of the fields were updated it still reports the success message... heres the code i have: $query=mysql_query(update members set company=\$company\, ); if($query){ message if successfull... } else{ message if not or if failed..//never gets used } anybody know why this doesnt work if 0 records were changed? * if the update does not have anything to work on it does not mean it is a failure! except when you EXPECTED it to update something. * i'm not sure whether if ($query) is the proper way to check this. for trapping development errors i always suggest: $q=update members set company=\$company\, $query=mysql_query($q) or die ('hrDB update failed in '.__FILE__.' line '.__LINE__.'brQuery was:'.$q.'brmysql reported:'.mysql_error()); * for counting the affected rows use http://nl.php.net/manual/nl/function.mysql-affected-rows.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] testing a query for success--code doesnt work
yes that is what i needed.. how many rows were changed as well as how did the query run in general... i want the: if($query){ ok message } else{ fail message } but i also want a query test that goes something like this: if(0 rows were updated){ message saying nothing happened }else{ message saying the record was actually updated } if i can get some code example for that...it would help tnx - Original Message - From: Edward Peloke [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, February 04, 2003 3:46 PM Subject: RE: [PHP] testing a query for success--code doesnt work I believe as long as the update was successful (no errors) it will say 'message if successful'...I think you are wanting to know if rows were updated or not...not whether or not the query ran ok. Eddie -Original Message- From: Sunfire [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 04, 2003 3:51 PM To: [EMAIL PROTECTED] Subject: [PHP] testing a query for success--code doesnt work hi.. posted a message about what the code was to test an update query to see if it was successfull using mysql and i tested my code and for some reason even if none of the fields were updated it still reports the success message... heres the code i have: $query=mysql_query(update members set company=\$company\, ); if($query){ message if successfull... } else{ message if not or if failed..//never gets used } anybody know why this doesnt work if 0 records were changed? --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003 -- 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 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] testing a query for success--code doesnt work
FYI, I replied to a similar problem just a few threads down. Next time please consider searching before you post. You'll find you can answer your own question 9 out of 10 times. $result = mysql_query(UPDATE or INSERT or DELETE... ) or die(Invalid query: . mysql_error()); if (mysql_affected_rows() == 0) { echo Query executed but no rows were affected; exit; } - Kevin - Original Message - From: Sunfire [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, February 04, 2003 1:51 PM Subject: [PHP] testing a query for success--code doesnt work hi.. posted a message about what the code was to test an update query to see if it was successfull using mysql and i tested my code and for some reason even if none of the fields were updated it still reports the success message... heres the code i have: $query=mysql_query(update members set company=\$company\, ); if($query){ message if successfull... } else{ message if not or if failed..//never gets used } anybody know why this doesnt work if 0 records were changed? --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003 -- 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] testing a query for success--code doesnt work
Just grab your qu ? $affected_rows = mysql_affected_rows($query); if ($affected_rows==0){ print No rows updated; } else{ print $affected_rows. rows have beenupdated.; } ? or something along those lines...but also add in your check to see if the query ran without errors. Eddie -Original Message- From: Sunfire [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 04, 2003 4:03 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] testing a query for success--code doesnt work yes that is what i needed.. how many rows were changed as well as how did the query run in general... i want the: if($query){ ok message } else{ fail message } but i also want a query test that goes something like this: if(0 rows were updated){ message saying nothing happened }else{ message saying the record was actually updated } if i can get some code example for that...it would help tnx - Original Message - From: Edward Peloke [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, February 04, 2003 3:46 PM Subject: RE: [PHP] testing a query for success--code doesnt work I believe as long as the update was successful (no errors) it will say 'message if successful'...I think you are wanting to know if rows were updated or not...not whether or not the query ran ok. Eddie -Original Message- From: Sunfire [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 04, 2003 3:51 PM To: [EMAIL PROTECTED] Subject: [PHP] testing a query for success--code doesnt work hi.. posted a message about what the code was to test an update query to see if it was successfull using mysql and i tested my code and for some reason even if none of the fields were updated it still reports the success message... heres the code i have: $query=mysql_query(update members set company=\$company\, ); if($query){ message if successfull... } else{ message if not or if failed..//never gets used } anybody know why this doesnt work if 0 records were changed? --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003 -- 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 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003 -- 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] testing a query for success--code doesnt work
* if the update does not have anything to work on it does not mean it is a failure! except when you EXPECTED it to update something. Right, and the function doesn't care what you expect anyway. :-) * i'm not sure whether if ($query) is the proper way to check this. for trapping development errors i always suggest: $q=update members set company=\$company\, ... $query=mysql_query($q) or die ('hrDB update failed in '.__FILE__.' line '.__LINE__.'brQuery was:'.$q.'brmysql reported:'.mysql_error()); His way of trapping an error was fine, actually, though it is a bit more elegant to say: if (!mysql_query($sql)) { echo Error; } To die() on error is great for debugging, but it isn't very elegant in production (without some good custom error handling, in which case it is fine). Testing whether the function returned true or false allows you to take any action you desire. His logic was the only real problem. For some reason, quite a few people seem to not understand what an error is. Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] testing a query for success--code doesnt work
FYI unlike the other mysql result functions mysql_affected_rows() works on the last query *only* and does not accept a results pointer as input. So this will result in an error... $result = mysql_query(UPDATE.. whatever); $affected_rows = mysql_affected_rows($result); //== invalid identifier Simply leave the $result out of the function... $result = mysql_query(UPDATE.. whatever) or die(Invalid query.); $affected_rows = mysql_affected_rows(); if ($affected_rows == 0) echo font color=redThe query ran but no rows were updated./font; else echo font color=green.$affected_rows. were updated./font; -Kevin - Original Message - From: Edward Peloke [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, February 04, 2003 2:16 PM Subject: RE: [PHP] testing a query for success--code doesnt work Just grab your qu ? $affected_rows = mysql_affected_rows($query); if ($affected_rows==0){ print No rows updated; } else{ print $affected_rows. rows have beenupdated.; } ? or something along those lines...but also add in your check to see if the query ran without errors. Eddie -Original Message- From: Sunfire [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 04, 2003 4:03 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] testing a query for success--code doesnt work yes that is what i needed.. how many rows were changed as well as how did the query run in general... i want the: if($query){ ok message } else{ fail message } but i also want a query test that goes something like this: if(0 rows were updated){ message saying nothing happened }else{ message saying the record was actually updated } if i can get some code example for that...it would help tnx - Original Message - From: Edward Peloke [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, February 04, 2003 3:46 PM Subject: RE: [PHP] testing a query for success--code doesnt work I believe as long as the update was successful (no errors) it will say 'message if successful'...I think you are wanting to know if rows were updated or not...not whether or not the query ran ok. Eddie -Original Message- From: Sunfire [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 04, 2003 3:51 PM To: [EMAIL PROTECTED] Subject: [PHP] testing a query for success--code doesnt work hi.. posted a message about what the code was to test an update query to see if it was successfull using mysql and i tested my code and for some reason even if none of the fields were updated it still reports the success message... heres the code i have: $query=mysql_query(update members set company=\$company\, ); if($query){ message if successfull... } else{ message if not or if failed..//never gets used } anybody know why this doesnt work if 0 records were changed? --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003 -- 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 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003 -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] testing a query for success--code doesnt work
thanks!...my fault... I had never used it...been using mysql_num_rows so that is where I took the example. Thanks! Eddie -Original Message- From: Kevin Stone [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 04, 2003 4:53 PM To: Edward Peloke; [EMAIL PROTECTED] Subject: Re: [PHP] testing a query for success--code doesnt work FYI unlike the other mysql result functions mysql_affected_rows() works on the last query *only* and does not accept a results pointer as input. So this will result in an error... $result = mysql_query(UPDATE.. whatever); $affected_rows = mysql_affected_rows($result); //== invalid identifier Simply leave the $result out of the function... $result = mysql_query(UPDATE.. whatever) or die(Invalid query.); $affected_rows = mysql_affected_rows(); if ($affected_rows == 0) echo font color=redThe query ran but no rows were updated./font; else echo font color=green.$affected_rows. were updated./font; -Kevin - Original Message - From: Edward Peloke [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, February 04, 2003 2:16 PM Subject: RE: [PHP] testing a query for success--code doesnt work Just grab your qu ? $affected_rows = mysql_affected_rows($query); if ($affected_rows==0){ print No rows updated; } else{ print $affected_rows. rows have beenupdated.; } ? or something along those lines...but also add in your check to see if the query ran without errors. Eddie -Original Message- From: Sunfire [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 04, 2003 4:03 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] testing a query for success--code doesnt work yes that is what i needed.. how many rows were changed as well as how did the query run in general... i want the: if($query){ ok message } else{ fail message } but i also want a query test that goes something like this: if(0 rows were updated){ message saying nothing happened }else{ message saying the record was actually updated } if i can get some code example for that...it would help tnx - Original Message - From: Edward Peloke [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, February 04, 2003 3:46 PM Subject: RE: [PHP] testing a query for success--code doesnt work I believe as long as the update was successful (no errors) it will say 'message if successful'...I think you are wanting to know if rows were updated or not...not whether or not the query ran ok. Eddie -Original Message- From: Sunfire [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 04, 2003 3:51 PM To: [EMAIL PROTECTED] Subject: [PHP] testing a query for success--code doesnt work hi.. posted a message about what the code was to test an update query to see if it was successfull using mysql and i tested my code and for some reason even if none of the fields were updated it still reports the success message... heres the code i have: $query=mysql_query(update members set company=\$company\, ); if($query){ message if successfull... } else{ message if not or if failed..//never gets used } anybody know why this doesnt work if 0 records were changed? --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003 -- 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 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003 -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing smtp server
On Friday 13 December 2002 21:30, Max Clark wrote: I found the socket_create function that is listed as experimental and requires a re-compile of php. Is there a built in way to perform this kind of test? Based upon the second example on http://www.php.net/manual/en/ref.sockets.php : echo h2TCP/IP Connection/h2\n; /* Get the service for TCP-Port 25. */ $service_port = getservbyport (25, 'tcp'); /* Get the IP address for the target host. */ $address = gethostbyname ('www.example.com'); /* Create a TCP/IP socket. */ $socket = socket_create (AF_INET, SOCK_STREAM, 0); if ($socket 0) { echo socket_create() failed: reason: . socket_strerror ($socket) . \n; } else { echo OK.\n; } echo Attempting to connect to '$address' on port '$service_port'...; $result = socket_connect ($socket, $address, $service_port); if ($result 0) { echo socket_connect() failed.\nReason: ($result) . socket_strerror($result) . \n; } else { echo OK.\n; } johannes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] testing for empty array
I believe if(empty($keywords)) or even if(!$keywords) will check if they are empty Robbert van Andel -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, November 26, 2002 4:41 PM To: [EMAIL PROTECTED] Subject: [PHP] testing for empty array I have an array $keywords, how do I test to see if it is empty? $keywords == '' seems to throw out an error. -- 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] testing
just mail: [EMAIL PROTECTED] :) You succeded though :) -- Maxim Maletsky [EMAIL PROTECTED] [EMAIL PROTECTED] wrote... : not sure how to post -- 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