[PHP] Re: Email Antispam
"David Mehler" wrote in message news:CAPORhP5Cuzd0Hb9gBFLESNe5LofDODN64S2UOAuMWCb=zoh...@mail.gmail.com... > Hello, > > I'm working on a site that has email addresses on it. I am not wanting > to use mailto links so as to avoid spam harvesters, I'd like another > solution so that mailto links would work but would not work with > spammers. I've tried several javascript-based solutions, but am not > able to get them to be consistent. It seems like once they're used > they revert to coded links. If anyone has any solutions I'd appreciate > it. I'm not sure I can do this in php, generate email addresses > dynamically then pass them to the client, it would be the same as the > spammer hitting the page. I'd prefer something self-hosted and > preferably light on the resources. > > Thanks. > Dave. Why not just put the contact's name/info on screen and then use the database behind it all to go get the email address and build the mail? Assuming that the site is using a db to hold these addresses already. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Email Antispam
"Ross McKay" wrote in message news:b4vro79ftp9423k74bnj41o1o9e3dk9...@4ax.com... > On Tue, 17 Apr 2012 16:04:19 -0400, David Mehler wrote: > >>I'm working on a site that has email addresses on it. I am not wanting >>to use mailto links so as to avoid spam harvesters, I'd like another >>solution so that mailto links would work but would not work with >>spammers. I've tried several javascript-based solutions, but am not >>able to get them to be consistent. It seems like once they're used >>they revert to coded links. If anyone has any solutions I'd appreciate >>it. I'm not sure I can do this in php, generate email addresses >>dynamically then pass them to the client, it would be the same as the >>spammer hitting the page. I'd prefer something self-hosted and >>preferably light on the resources. > > I don't like this sort of thing, but I have a client who needs it. What > I did for them was to put the email address on the page encoded with > base64, and use client-side script to decode it. i.e. the encoded data > is replaced with the decoded data, once on page load. Hook up the decode > function on the browser-side to your page load scripts. No jQuery > required :) > > https://gist.github.com/2409958 > -- > Ross McKay, Toronto NSW Australia > "All we are saying > Is give peas a chance" - SeedSavers So - does that mean you building the site from information contained in a database? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Email Antispam
"Ross McKay" wrote in message news:795so7t0avn28a5m8i373h9tursk15c...@4ax.com... > On Tue, 17 Apr 2012 21:11:45 -0400, Jim Giner wrote: > >>So - does that mean you building the site from information contained in a >>database? > > Yes. Client wanted email addresses on the website, but not available to > SPAM harvesters. And not all addresses are "in the database" as > structured data, many are embedded in page content (I have a WordPress > shortcode that encodes the email address for those). > -- > Ross McKay, Toronto, NSW Australia > "Faced with a choice between the survival of the planet > and a new set of matching tableware, most people would > choose the tableware" - George Monbiot He literally wants the "addresses" visible on the sight? Or just an using the person's name that would then generate the email by referencing the data table? This is basic contact form methodology as mentioned by an earlier post. As for the missing ones, use that WP thingie to extract them and post them to a speicifc email addr field in your table. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: No error reporting on
Just my $.02, but don't you need: ini_set('display_errors', '1'); as well? "Dotan Cohen" wrote in message news:CAKDXFkMOH63=hnlekxugampqwrhvvet2x4iw-42soqkisrg...@mail.gmail.com... > Given this code: > > error_reporting(-1); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: No error reporting on
Sounds like a very good reason to me? It's a development tool. Add it now, remove it later. "Dotan Cohen" wrote in message news:cakdxfkn+6mn9chuqdwevx5ap0km-rkls0q+carbf5hktvuo...@mail.gmail.com... On Mon, Apr 23, 2012 at 16:53, Jim Lucas wrote: >> Possibly, thanks. I actually don't have access to that! >> > > That line should be placed in your script. not the php.ini file > Yes, I'm working on a functions file that is include()ed by the main script. I'm not supposed to touch the main script without a very good reason. -- Dotan Cohen http://gibberish.co.il http://what-is-what.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] url string being split
I"m no expert, but why would you expose a query to the world thru the use of a GET? Why not just collect the params and build the string in your code? That is how people hack into your database - via a re-formed query. You're giving someone an open invitation. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] undefined offset
Sorry - can't seem to find anything that explains this on google. I'm using a List command to break out an array into distinct field names. I keep getting these errors as I go thru my loop:: Notice: Undefined offset: 10 in (.) on line 151 Notice: Undefined offset: 9 in (.) on line 151 Notice: Undefined offset: 8 in (.) on line 151 Notice: Undefined offset: 7 in (.) on line 151 Notice: Undefined offset: 6 in (.) on line 151 Notice: Undefined offset: 5 in (.) on line 151 Notice: Undefined offset: 4 in (.) on line 151 Notice: Undefined offset: 3 in (.) on line 151 Notice: Undefined offset: 2 in (.) on line 151 Notice: Undefined offset: 1 in (.) on line 151 The array is loaded with while ($line = fgetcsv($hdlin)) My trouble line of code is: list($LastName, $FirstName,$MI, $Eventcode,$Event_Partner_Ln, $Event_Partner_Fn, $Event_Partner_MI,$t,$u,$v,$Draw_pos) = $line; I've confirmed that I have a field name for each element in my rows. All the rows are the same size naturally. So - what is it telling me? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] undefined offset
Thanks. That was it -my last line was null. - Original Message - From: "Stuart Dallas" To: "Jim Giner" Cc: Sent: Thursday, April 26, 2012 4:21 PM Subject: Re: [PHP] undefined offset On 26 Apr 2012, at 21:20, Jim Giner wrote: Sorry - can't seem to find anything that explains this on google. I'm using a List command to break out an array into distinct field names. I keep getting these errors as I go thru my loop:: Notice: Undefined offset: 10 in (.) on line 151 Notice: Undefined offset: 9 in (.) on line 151 Notice: Undefined offset: 8 in (.) on line 151 Notice: Undefined offset: 7 in (.) on line 151 Notice: Undefined offset: 6 in (.) on line 151 Notice: Undefined offset: 5 in (.) on line 151 Notice: Undefined offset: 4 in (.) on line 151 Notice: Undefined offset: 3 in (.) on line 151 Notice: Undefined offset: 2 in (.) on line 151 Notice: Undefined offset: 1 in (.) on line 151 The array is loaded with while ($line = fgetcsv($hdlin)) My trouble line of code is: list($LastName, $FirstName,$MI, $Eventcode,$Event_Partner_Ln, $Event_Partner_Fn, $Event_Partner_MI,$t,$u,$v,$Draw_pos) = $line; I've confirmed that I have a field name for each element in my rows. All the rows are the same size naturally. So - what is it telling me? For every iteration of the loop or just once? If it's just once then you're not handling the possibility of a blank line. If more than once then the file doesn't contain what you think it contains. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] FPDF ?
For those of you with FPDF experience. I've just begun using it and have figured out how it works I think. I am still having trouble with the bottom of the page tho. Seems that if I get too close to the bottom margin and my data line exceeds the amount of available space, my MultiCell elements print some of their contents and then my Footer gets printed and then I go to a new page where some small amount of the remaining data for that line gets printed and then a new page is output and repeat. This can go on for 3-4 pages before things work out and my report continues until it gets a full page again and then it all happens again. I know it sounds complicated, but I'm hoping someone else has experienced this kind of learning curve and can give me a clue as to what I'm doing wrong, or at least what's happening. Even better would be an algorithm for detecting how much space I have left so I can avoid these split lines and perhaps solve my entire problem. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Array_diff problems
"Rick Dwyer" wrote in message news:0c0e6cc9-089d-4938-8b50-c9e12dfb3...@earthlink.net... Hello all. I have two arrays and when compared against each other via array_diff, I do not get any output: $myarray1 = Array ( [0] => Array ( [id] => 1 [Funding_Type] => Federal [Amount] => 10 [Frequency_Description] => Total [Other_Funding] => ) [1] => Array ( [id] => 2 [Funding_Type] => Trust [Amount] => 20 [Frequency_Description] => Per Year [Other_Funding] => ) [2] => Array ( [id] => 3 [Funding_Type] => Other Funding [Amount] => 30 [Frequency_Description] => Other [Other_Funding] => some )) $myarray2 = Array ( [0] => Array ( [id] => 1 [Funding_Type] => Federal [Amount] => 10 [Frequency_Description] => Total [Other_Funding] => ) [1] => Array ( [id] => 2 [Funding_Type] => Trust [Amount] => 20 [Frequency_Description] => Per Year [Other_Funding] => ) [2] => Array ( [id] => 3 [Funding_Type] => Other Funding [Amount] => 50 [Frequency_Description] => Other [Other_Funding] => none )) $arraydifferences = (array_diff($myarray1,$myarray2)); I need $arraydifferences to record the differences between the two. Any help is appreciated. Thanks, --Rick Are these arrays nested in an array? In that case the manual says you have to do the compare differently. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: function
""Ron Piggott"" wrote in message news:499A66F0FB394E1DB44F7E0C011CF11C@RonPiggottPC... I need to access a FUNCTION I programmed within a different FUNCTION. Are these able to be passed like a variable? Or are they able to become like a $_SESSION variable in nature? How am I able to do this? Why not just separate the functions? Then you won't have any problem like that. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP & Database Problems -- Code Snippets - Any more Ideas?
I don't think posting the same voluminous code is going to generate any better responses. The suggestion to start over and make your insert/retrieve queries fool proof before starting to write some logic into your code was a very good one. Why don't you work on that so that any requests for help can focus on just that instead of the 100+ lines of code you are posting? Reading some documentation on sql and some html/php relationships would be VERY beneficial to your long-term success as a programmer as well. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP & Database Problems -- Code Snippets - Any more Ideas?
Nor will posting to multiple lists.(Sorry to the rest of you - didn't realize it until now.) ""Jim Giner"" wrote in message news:c6.f8.38082.efae3...@pb1.pair.com... >I don't think posting the same voluminous code is going to generate any >better responses. > > The suggestion to start over and make your insert/retrieve queries fool > proof before starting to write some logic into your code was a very good > one. Why don't you work on that so that any requests for help can focus > on just that instead of the 100+ lines of code you are posting? Reading > some documentation on sql and some html/php relationships would be VERY > beneficial to your long-term success as a programmer as well. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] function
But the OP says "function is defined inside a different function". Your theories to a solution don't fit that problem. "tamouse mailing lists" wrote in message news:cahuc_t-416_-lpcn3mo8qqxwrh4pnq5fmwouhwpdk+hmkgh...@mail.gmail.com... On Thu, May 3, 2012 at 9:12 PM, Ron Piggott wrote: Where is name_of_a_different_function defined? If it is somewhere in the same file as name, that shouldn't be a problem, provided it is defined in the same namespace/scope as name. If it is defined in a different file, you need to include that file before you make the echo statement. For example: function func1 ($flag1, $flag2) { # blah blah echo func2($flag1, $flag2); } function func2 ($flag1, $flag2) { #blah blah return "some string value"; } in the same file should be just fine. It doesn't really matter what order func1 and func2 are declared in. However, if func2 is defined in some_other_file.php, you need to include it in this_file.php (where func1 is defined) first: this_file.php: include('some_other_file.php'); function func1 ($flag1, $flag2) { #blah blah echo func2 ($flag1, $flag2); } some_other_file.php: function func2 ($flag1, $flag2) { #blah blah return "some string value"; } If func2 is a method for an object/class, you'll have to access it that way in func1: this_file.php: include('MyClass.php'); function func1 ($flag1, $flag2) { # blah blah, instantiate object? $myobj = new MyClass(); echo $myobj->func2 ($flag1, $flag2); } MyClass.php: class MyClass { function func2 ($flag1, $flag2) { #blah blah return "some string value"; } } But the OP says "function is defined inside a different function". Your theories to a solution don't fit that problem. (Sorry you all had to read thru so much stuff just to get to my one-line response.) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] I'm missing something
I have a discrepancy in the number of elements in my arrays and can't see why. Here is some code: Note the lines with the *** *** $plyrs = 0; unset($plyrnames_ar); unset($js_names); unset($js_seeds); *** $rows = mysql_num_rows($qrslts); ***echo "in mysql there are $rows rows"; while ($row = mysql_fetch_array($qrslts)) { // build the name value here $mi = ($row['MI']=='') ? '' : " ".$row['MI']; $nm = $row['LastName'].", ".$row['FirstName'].$mi; if ($row['srtdbls']=='X') { $mi = ($row['partMI']=='') ? '' : " ".$row['partMI']; $nm .= "/".$row['partLN'].", ".$row['partFN'].$mi; } *** $plyrs++; $plyrnames_ar[$nm] = $row['Draw_pos']; } *** echo "before sort there are ".count($plyrnames_ar)." in plyrsnames_ar"; ksort($plyrnames_ar); foreach ($plyrnames_ar as $nm=>$sd) { $js_names[] = $nm; $js_seeds[] = $sd; } *** echo "plyrs is $plyrs and there are ".count($js_names)." entries in js_rnames and ".count ***($plyrnames_ar)." entries in plyrnames_ar and ".count($js_seeds)." in js_seeds"; exit(); The problem is that my $plyrs field comes up 18, while in truth there are only 17 rows of data in my database. All of the other array-size counts echo out as being only 17, but my $rows and $plyrs fields come up as 18. I was having problems with my javascript showing an undefined array element and took a bit o time to determine what it was and where it was happening. Questions - does mysql_num_rows return a extra row that somehow doesn't get processed in the while loop? And if it does how come the counter ($plyrs) that I put into the loop comes up higher than it should.? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I'm missing something
My guess would be that you end up with 2 rows having the same $nm, overwriting the value that's already in $plyrnames_ar. - Matijn Genius at work! Thanks - I'll look into that. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I'm missing something
Yup that was it! Something I knew would happen during my design, but forgot to code for now. ""Jim Giner"" wrote in message news:e2.dc.30075.c6ea5...@pb1.pair.com... > > > My guess would be that you end up with 2 rows having the same $nm, > overwriting the value that's already in $plyrnames_ar. > > - Matijn > > Genius at work! Thanks - I'll look into that. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Variables via url
""Ashley M. Kirchner"" wrote in message news:4fad9d8b.4020...@pcraft.com... > > Can someone point me at examples or directions on how I can pass a > variable via a URL in the following way: > > http://server.domain.com//script///variable/ > > I will only be passing one single /variable/. And I want the > /script/ to use that. > > I don't want to see what the script is, for example I don't want it > to say 'script.php' or 'script.html' ... > > Is this possible through PHP only, or do I have to write a rewrite > directive in Apache to accomplish this? > A URL has to point to a script - how will your server know what to do with the incoming URL if it doesn't point to something? That said - format your URL as a GET string and there's your variable. Ex.: http://server.domain.com/(scriptname)?variable&anothervariable&anothervariable Or - if this url is coming from an already running script, you could post the var to a session var and then send a url without the script name and let your server's default document (index.php ?) receive it and look up the session var, but that's a pretty silly way to handle things just to hide the scriptname. Of course, someone here with much more knowledge than I could very soon make me look stupid :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] regexp novice
ok - finally had to come up with my own regexp - and am failing. Trying to validate an input of a time value in the format hh:mm, wherein I'll accept anything like the following: hmm hhmm h:mm hh:mm in a 12 hour format. My problem is my test is ok'ing an input of 1300. Here is my test: if (0 == preg_match("/([0][1-9]|[1][0-2]|[1-9]):[0-5][0-9]/",$t)) return true; else return false; Can someone help me correct my regexp? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: regexp novice
OOPS FORGOT to mention that I modify the string to add a colon if it is entered without one, so my regexp always expects a ":" to be in the middle. So in actuality - my regexp is 'passing' a value of 13:00 as legitimate, when it should not be. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regexp novice
"Yared Hufkens" wrote in message news:4fb5667d.7020...@yahoo.de... > Try this: > /(0?[1-9]|[12][0-9]):?[0-5][0-9]/ > > FYI: ? is equal to {0,1}, and [1-9] to [123456789] (and therefore [1-2] > to [12]). > > > Am 17.05.2012 22:37, schrieb Jim Giner: >> ok - finally had to come up with my own regexp - and am failing. >> >> Trying to validate an input of a time value in the format hh:mm, wherein >> I'll accept anything like the following: >> hmm >> hhmm >> h:mm >> hh:mm >> >> in a 12 hour format. My problem is my test is ok'ing an input of 1300. >> >> Here is my test: >> >> if (0 == preg_match("/([0][1-9]|[1][0-2]|[1-9]):[0-5][0-9]/",$t)) >> return true; >> else >> return false; >> >> Can someone help me correct my regexp? >> >> >> Nope - that didn't work. Tested it against 1900, 1300 and 13:00 and all came thru as OK. Also - I don't understand at all the following: > FYI: ? is equal to {0,1}, and [1-9] to [123456789] (and therefore [1-2] > to [12]). I know (?) that [1-9] validates any digit from 1 to 9 - I was already using that. And your point about [1-2] doesn't make sense to me since I need to validate 10:00 which [1-2] in my usage would cause 10:00 to fail. And I don't know what ? means at all. FWIW - I couldn't find much in the way of tutorials on the meanings of the various chars in regexp's. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regexp novice
Thank you ! "Govinda" wrote in message news:3e5dce87-29c1-4679-ad3a-53326435f...@gmail.com... > > FWIW - I couldn't find much in the way of tutorials on the meanings of the > various chars in regexp's. this helps alot: http://www.gskinner.com/RegExr/ you can paste your pattern (needle) in the top input, and hover over each char to see what it means in grep land. Paste your haystack in the big box (input), under that, to see where all your needle will be found. > > > > -- > 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] regexp novice
"Jim Lucas" wrote in message news:4fb5b89e.8050...@cmsws.com... > On 5/17/2012 1:57 PM, shiplu wrote: >> On Fri, May 18, 2012 at 2:37 AM, Jim >> Ginerwrote: >> >>> ok - finally had to come up with my own regexp - and am failing. >>> >>> Trying to validate an input of a time value in the format hh:mm, wherein >>> I'll accept anything like the following: >>> hmm >>> hhmm >>> h:mm >>> hh:mm >>> >>> in a 12 hour format. My problem is my test is ok'ing an input of 1300. >>> >>> Here is my test: >>> >>> if (0 == preg_match("/([0][1-9]|[1][0-2]|[1-9]):[0-5][0-9]/",$t)) >>> return true; >>> else >>> return false; >>> >>> Can someone help me correct my regexp? >>> >>> >>> >> I can not correct your regexp. But I must tell you that trying to tweak a >> regex for hours is surely **not productive**. If you got any type of text >> processing dont always go for regular expression. This problem can be >> solved just by simple string parsing. >> Here I have done that for you. >> >> >> function valid_time($time){ >> $m = (int) substr($time, -2); >> $h = (int) substr($time, 0, -2); >> return ($h>=0&& $h<13&& $m>=0&& $m<60); >> } >> >> > > That won't work, it doesn't account for the possibility of a single digit > hour field. > > I would do something like this: > > > $times = array( > '100', # valid > '1100', # valid > '1300', # invalid > '01:00',# valid > '12:59',# valid > '00:01',# valid > '00:25pm', # invalid > '', # valid > 'a00', # invalid > '00', # invalid > ); > > foreach ( $times AS $time ) > echo "{$time} is ".(valid_date($time)?'valid':'invalid')."\n"; > > function valid_date($time) { > if ( ( $c_time = preg_replace('|[^\d:]+|', '', $time) ) !== $time ) > return false; > > if ( ( $pos = strpos($c_time, ':') ) !== false ) { > list($hour, $minute) = explode(':', $c_time, 2); > } else { > $break = (strlen($c_time) - 2); > $hour = substr($c_time, 0, $break); > $minute = substr($c_time, $break, 2); > } > $hour = (int)$hour; > $minute = (int)$minute; > > if ( strlen($c_time) <= 2 ) > return false; > > if ( > ( $hour >= 0 && $hour <= 12 ) && > ( $minute >= 0 && $minute <= 59 ) > ) { > return true; > } > return false; > } > > It seems overly complicated, but it does check and error for the various > things that I could think of for possible input. > > Give it a try and let us know. > > See it in action here. > http://cmsws.com/examples/php/testscripts/shiplu@gmail.com/pt.php > http://cmsws.com/examples/php/testscripts/shiplu@gmail.com/pt.phps > > Jim Lucas Thanks for the work you did, but I really wanted to try to solve this using the more "elegant" way, which from my readings over the last year as a new php developer, seemed to be the regexp methodology. I'm so close - it's only the 1300,1400,etc. time values that are getting by my expression. And thank you Shiplu also for your simple, but non-regexp, solution. Yes - it works and I had something similar that was just missing one more check when I decided to explore the regexp method. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regexp novice
"Jim Lucas" wrote in message news:4fb5decc.20...@cmsws.com... > On 5/17/2012 9:52 PM, Jim Lucas wrote: >> >> How about this instead? >> >> > >> $times = array( >> '100', # valid >> '1100', # valid >> '1300', # invalid >> '01:00', # valid >> '12:59', # valid >> '00:01', # valid >> '00:25pm', # invalid >> '', # valid >> 'a00', # invalid >> '00', # invalid >> ); >> >> foreach ( $times AS $time ) >> echo "{$time} is ".(valid_date($time)?'valid':'invalid')."\n"; >> >> function valid_date($time) { >> >> if ( ( $c_time = preg_replace('|[^\d\:]+|', '', $time) ) != $time ) >> return false; >> >> preg_match('#^(?P\d{1,2}):?(?P\d{2})$#', $time, $m); >> >> if ( >> $m && >> ( 0 <= (int) $m['hour'] && 12 >= (int) $m['hour'] ) && >> ( 0 <= (int) $m['minute'] && 59 >= (int) $m['minute'] ) >> ) { >> return TRUE; >> } >> >> return false; >> >> } >> >> Let me know. >> > > I optimized it a little... > > http://www.cmsws.com/examples/php/testscripts/shiplu@gmail.com/pt_regex.php > http://www.cmsws.com/examples/php/testscripts/shiplu@gmail.com/pt_regex.phps > > > $times = array( > '100', # valid > '1100', # valid > '1300', # invalid > '01:00',# valid > '12:59',# valid > '00:01',# valid > '00:25pm', # invalid > '', # valid > 'a00', # invalid > '00', # invalid > ); > > foreach ( $times AS $time ) > echo "{$time} is ".(valid_time($time)?'valid':'invalid')."\n"; > > function valid_time($time) { > if ( > preg_match('#^(\d{1,2}):?(\d{2})$#', $time, $m) && > ( 0 <= (int) $m[1] && 12 >= (int) $m[1] ) && > ( 0 <= (int) $m[2] && 59 >= (int) $m[2] ) > ) { > return TRUE; > } > return FALSE; > } > I'll have to study your regexp - a lot of stuff I don't understand yet in play there. Thanks for the sample! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regexp novice
"Jim Lucas" wrote in message news:4fb5decc.20...@cmsws.com... > On 5/17/2012 9:52 PM, Jim Lucas wrote: >> >> How about this instead? >> >> > >> $times = array( >> '100', # valid >> '1100', # valid >> '1300', # invalid >> '01:00', # valid >> '12:59', # valid >> '00:01', # valid >> '00:25pm', # invalid >> '', # valid >> 'a00', # invalid >> '00', # invalid >> ); >> >> foreach ( $times AS $time ) >> echo "{$time} is ".(valid_date($time)?'valid':'invalid')."\n"; >> >> function valid_date($time) { >> >> if ( ( $c_time = preg_replace('|[^\d\:]+|', '', $time) ) != $time ) >> return false; >> >> preg_match('#^(?P\d{1,2}):?(?P\d{2})$#', $time, $m); >> >> if ( >> $m && >> ( 0 <= (int) $m['hour'] && 12 >= (int) $m['hour'] ) && >> ( 0 <= (int) $m['minute'] && 59 >= (int) $m['minute'] ) >> ) { >> return TRUE; >> } >> >> return false; >> >> } >> >> Let me know. >> > > I optimized it a little... > > http://www.cmsws.com/examples/php/testscripts/shiplu@gmail.com/pt_regex.php > http://www.cmsws.com/examples/php/testscripts/shiplu@gmail.com/pt_regex.phps > > > $times = array( > '100', # valid > '1100', # valid > '1300', # invalid > '01:00',# valid > '12:59',# valid > '00:01',# valid > '00:25pm', # invalid > '', # valid > 'a00', # invalid > '00', # invalid > ); > > foreach ( $times AS $time ) > echo "{$time} is ".(valid_time($time)?'valid':'invalid')."\n"; > > function valid_time($time) { > if ( > preg_match('#^(\d{1,2}):?(\d{2})$#', $time, $m) && > ( 0 <= (int) $m[1] && 12 >= (int) $m[1] ) && > ( 0 <= (int) $m[2] && 59 >= (int) $m[2] ) > ) { > return TRUE; > } > return FALSE; > } > OK - I don't yet understand how this works, but it seems to work for almost all cases. The one erroneous result I get is from a value of 0040 (which I convert to 00:40 before hitting the regexp). It comes thru as Ok. If you have a fix for that I'd appreciate it - otherwise I'll have to devote some book-time to mastering this string and come up with a fix myself. Thanks again!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regexp novice
"Stuart Dallas" wrote in message news:cc22e241-c1df-48e9-bf06-8a638a356...@3ft9.com... On 18 May 2012, at 14:32, Jim Giner wrote: > OK - I don't yet understand how this works, but it seems to work for > almost > all cases. The one erroneous result I get is from a value of 0040 (which > I > convert to 00:40 before hitting the regexp). It comes thru as Ok. If you > have a fix for that I'd appreciate it - otherwise I'll have to devote some > book-time to mastering this string and come up with a fix myself. Based on your requirements, 00:40 is completely valid. Why do you think it should be invalid? -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ Don't know how you write the time, but I've never used a time of 00:40. Yes, I realize that my shorthand time string is missing a key ingredient of am/pm, but 12:40 would be the time in my mind regardless of the status of the sun. In my speccific use of this code, all times would be 'daylight' times so 40 minutes after minute would be a) not practical and b) still not a recognized time in a 12-hour format. Yes - in 24-hour formats, 00:40 is correct, but my initial post did reference my need of a 12-hour format solution. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regexp novice
times so 40 minutes after minute would be a) not practical and b) still not I meant to say "40 minutes after MIDNIGHT". -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regexp novice
"Stuart Dallas" wrote in message news:79538829-bfc4-43a4-a413-72247b145...@3ft9.com... On 18 May 2012, at 14:41, Jim Giner wrote: > "Stuart Dallas" wrote in message > news:cc22e241-c1df-48e9-bf06-8a638a356...@3ft9.com... >> On 18 May 2012, at 14:32, Jim Giner wrote: >> >>> OK - I don't yet understand how this works, but it seems to work for >>> almost >>> all cases. The one erroneous result I get is from a value of 0040 >>> (which >>> I >>> convert to 00:40 before hitting the regexp). It comes thru as Ok. If >>> you >>> have a fix for that I'd appreciate it - otherwise I'll have to devote >>> some >>> book-time to mastering this string and come up with a fix myself. >> >> Based on your requirements, 00:40 is completely valid. Why do you think >> it >> should be invalid? >> > Don't know how you write the time, but I've never used a time of 00:40. > Yes, I realize that my shorthand time string is missing a key ingredient > of > am/pm, but 12:40 would be the time in my mind regardless of the status of > the sun. In my speccific use of this code, all times would be 'daylight' > times so 40 minutes after minute would be a) not practical and b) still > not > a recognized time in a 12-hour format. Yes - in 24-hour formats, 00:40 is > correct, but my initial post did reference my need of a 12-hour format > solution. Sounds daft to me, but they're your requirements. The "fix" is simple ( 0 <= (int) $m[1] && 12 >= (int) $m[1] ) && becomes ( 1 <= (int) $m[1] && 12 >= (int) $m[1] ) && -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/= Daft is a little harsh. :) 00:40 is just not a time value that is generally accepted. As for you patch thought - THAT is generally accepted. Works great now. Thank you. Now all I have to do is read up on this stuff so I can understand how it works. But first - golf! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regexp novice
"Stuart Dallas" wrote in message news:aba011df-8cdf-4492-be4d-51c2b54c4...@3ft9.com... On 18 May 2012, at 14:50, Jim Giner wrote: > Daft is a little harsh. :) 00:40 is just not a time value that is > generally accepted. It may appear harsh, but as far as I'm concerned it is daft to make assumptions like that. You've essentially disallowed 12:nn am, but allowed 1:nn am, 2:nn am, 3:nn am, etc, because you're not validating the data in a non-ambiguous way. I have no idea what you're developing, but you're making a big assumption about the data that you're getting, which may appear reasonable to you, but to me it's daft. Nothing personal, just my opinion, which is all I have to offer. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ Ok - here's the use. This feature is the scheduling portion of my application. The scheduling only pertains to basically daytime hours, typically 8:00am to 6:00pm. The information is used for display purposes mostly - there is no "calculating" going on with the data. Consequently, there is no need to be all-inclusive on my allowed times since they will never be used. I just want to validate the entries to be sure that a valid time has been entered for that period of a day. Noone is going to schedule anything for a midnight hour, not even a time after 8:00pm. Therefore I can be very specific about my editing criteria and can limit the entry of data that fits within that schedule. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Read dynamic variable from HTML form into PHP
"Govinda" wrote in message news:72497398-3a6c-4faa-89f2-565c18fd2...@gmail.com... On 2012-06-05, at 10:54 PM, Devangnp wrote: > I know how to pass variable but having difficulties when I use the dynamic > form field in HTML that add more boxes as per user require. > >>> Hi All, >>> >>> I am a basic user of PHP and I have need of reading the dynamic HTML >>> form >>> field as a variable in PHP so it will be great if someone can share some >>> good link or snip for quick understanding. >>> >>> Thanks, >>> Devang >> >> >> http://lmgtfy.com/?q=how+to+pass+and+receive+a+PHP+variable >> >> When just starting out, "Google is your friend". >> >> Or did I misunderstand your question? >> >> -Govinda Devang, Please keep replies on-list. Please post your replies at the bottom, past the older (snipped) content. Many here will be glad to help.. but you'll need to make your question more clear.. at least for me to be able to help anyway. First of all, what do you mean exactly, by, "the dynamic form field in HTML"? And by "boxes" do you mean form inputs of 'text' type? If so, then do you mean to suggest that input by the end user should determine the number of text inputs that should display in a second HTML form? Please spend more time describing what you are trying to do.. and also please show any code you attempt(ed) to accomplish this. If you are unable to write any code, then try pseudo code - meaning write in successive lines of prose what you want code to do, and post that here. -Govinda= I thought he meant previously generated "array" type fields, that use the same name. I've never done it myself, but I thought the method of handling this kind of input included placing a hidden field with the count on the form to be retriieved later and used in processing the dynamic fields in a loop. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Read dynamic variable from HTML form into PHP
"Maciek Sokolewicz" wrote in message news:4fcf23af.7040...@php.net... > On 06-06-2012 05:11, Jim Giner wrote: >> "Govinda" wrote in message >> news:72497398-3a6c-4faa-89f2-565c18fd2...@gmail.com... >> >> On 2012-06-05, at 10:54 PM, Devangnp wrote: >> >>> I know how to pass variable but having difficulties when I use the >>> dynamic >>> form field in HTML that add more boxes as per user require. >>> >> >>>>> Hi All, >>>>> >>>>> I am a basic user of PHP and I have need of reading the dynamic HTML >>>>> form >>>>> field as a variable in PHP so it will be great if someone can share >>>>> some >>>>> good link or snip for quick understanding. >>>>> >>>>> Thanks, >>>>> Devang >>>> >>>> >>>> http://lmgtfy.com/?q=how+to+pass+and+receive+a+PHP+variable >>>> >>>> When just starting out, "Google is your friend". >>>> >>>> Or did I misunderstand your question? >>>> >>>> -Govinda >> >> >> Devang, >> >> Please keep replies on-list. >> Please post your replies at the bottom, past the older (snipped) content. >> >> Many here will be glad to help.. but you'll need to make your question >> more >> clear.. at least for me to be able to help anyway. >> First of all, what do you mean exactly, by, "the dynamic form field in >> HTML"? And by "boxes" do you mean form inputs of 'text' type? If so, >> then >> do you mean to suggest that input by the end user should determine the >> number of text inputs that should display in a second HTML form? >> Please spend more time describing what you are trying to do.. and also >> please show any code you attempt(ed) to accomplish this. If you are >> unable >> to write any code, then try pseudo code - meaning write in successive >> lines >> of prose what you want code to do, and post that here. >> >> -Govinda= >> >> I thought he meant previously generated "array" type fields, that use the >> same name. I've never done it myself, but I thought the method of >> handling >> this kind of input included placing a hidden field with the count on the >> form to be retriieved later and used in processing the dynamic fields in >> a >> loop. >> >> > > A possible answer to a possible question that he might have (yes, the > question is very vaguely described, as Govinda already explained) would be > the following: > > Assuming you have an HTML form, which may contain a variable number of > fields, you want to somehow access their passed-through values in PHP > without prior knowledge of the exact number of those fields. > > There are essentially 2 ways: > 1. All POSTed data is present in the $_POST superglobal array. So you > could just loop over that, ignore the fields you already knew were there, > and the data remaining is then essentially the data you seek. The keys in > the $_POST array are the fieldnames you are looking for. > > 2. There's a special trick in PHP, when you name a field "name[]" in HTML > and then POST it to a PHP script, it will turn into an array field. So > will then end up > in: > $_POST = [ >'a' => [ > 0 => '1', > 1 => '2' >] > ] > > If you had not added the square-brackets, you would have: > ending up in: > $_POST = [ >'a' => '2' > ] > Thus not ever seeing the value '1'. > > I hope this answers part of your question; and if not, PLEASE explain in > more detail what your problem is, what you tried, why it didn't work, and > what you want to know exactly. Your current question is very very short > and vague enough to easily cause misunderstanding. > > - Tul Thank you Tul for your eloquent post. Now I understand how to handle those kinds of "array" inputs myself! And - I do think from his vague description that the OP is looking for this kind of help. If not, then it was REALLY vague! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] global array
Yes - PHP is very picky. Hence I never capitalize anything! I use underscores to make varnames more understandable, as in $inv_req -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] global array
"Al" wrote in message news:6b.c0.39100.4ef1a...@pb1.pair.com... > > > On 6/14/2012 12:49 PM, Jim Giner wrote: >> Yes - PHP is very picky. Hence I never capitalize anything! I use >> underscores to make varnames more understandable, as in $inv_req >> >> > > There is another nice custom e.g. $invReg it's easy to read and it doesn't > conflict with PHP syntax for some functions e.g., in_aray(). and defines > DOCUMENT_ROOT And what is that custom? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] global array
See - I didn't even notice he used camel-case - I thought he typed the same thing that got the OP in trouble. See how difficult that custom is? That's why for any case sensitive syntax, I stick to all lower case to avoid just that kind of bug-a-boo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php form action breaks script
Hear, Hear for heredocs. The only way to code up your html. Took me a few months to discover it and haven't looked back since. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] phpinfo
When one executes a phpinfo call, the display of info broken into the various sections mostly makes sense. The $_SERVER vars are listed with a _SERVER name, the environment ones show _ENV, and so on. But I question what are the duplicate ones that dont' have a prefix name. My concern is the PHP_AUTH_PW setting, which I was able to remove from the ENV and SERVER sections, but not from the section titled "Environment". How does one do this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] phpinfo
"Matijn Woudt" wrote in message news:cac_gtumpirenkswm2-lucwhbycmxdgg3a+hwr1aoqwiyz40...@mail.gmail.com... On Sun, Jun 17, 2012 at 10:22 PM, Jim Giner wrote: > When one executes a phpinfo call, the display of info broken into the > various sections mostly makes sense. The $_SERVER vars are listed with a > _SERVER name, the environment ones show _ENV, and so on. But I question > what are the duplicate ones that dont' have a prefix name. > > My concern is the PHP_AUTH_PW setting, which I was able to remove from the > ENV and SERVER sections, but not from the section titled "Environment". > How > does one do this? > Those are the ones returned from getenv [1] or apache_getenv [2], and you can set them using putenv [3] resp. apache_setenv [4]. - Matijn #1 - getenv does return the value that I expect #2 - apache_getenv is not recognized by my php It's in the php.net manual, but my editor doesn't like it and php errors out on it. ?? #3 - I tried putenv to set the value to something like '' and then I did a phpinfo - now I have two names - one with a password and one with '' in it. [1] www.php.net/getenv [2] www.php.net/apache_getenv [3] www.php.net/putenv [4] www.php.net/apache_setenv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] phpinfo
oops - read the notes for PUTENV. Did the 'delete' properly and now I have no entries for php_auth_pw. For those reading along - to remove the variable use putenv("varname") NOT putenv("varname= '' "); Thanks Martijn!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] slicing and dicing strings
"Stuart Dallas" wrote in message news:d889b8e1-2eab-4f36-83cb-8a52b5ec6...@3ft9.com... WARNING: May contain traces of sarcasm. If it would really take you 4 hours to find this out via the manual or Google then I think it would be 4 hours well spent: 3 hours 55 minutes learning how to use the manual / Google effectively, and 5 minutes to then get the answer you seek. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ hear hear! Or is it here here!? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php form action breaks script
"Tim Dunphy" wrote in message news:caozy0em5duhby-qv+y1u-e+c5yd7g5utauhomoyu3z7jma-...@mail.gmail.com... Notice: Undefined index: subject in /Library/WebServer/Documents/examples/ch03/final/makemeelvis/sendemail.php on line 23 Notice: Undefined index: elvismail in /Library/WebServer/Documents/examples/ch03/final/makemeelvis/sendemail.php on line 24 Notice: Undefined index: [PHP_SELF in /Library/WebServer/Documents/examples/ch03/final/makemeelvis/sendemail.php on line 62 [Wed Jun 27 20:13:42 2012] [error] [client 127.0.0.1] PHP Notice: Undefined index: [PHP_SELF in /Library/WebServer/Documents/examples/ch03/final/makemeelvis/sendemail.php on line 62, referer: http://localhost/elvis/ You're missing an input (POST) for the field named 'subject'. Something change in your html? As in you no longer have a 'subject' input field? Same for the other field named. As for the missing PHP_SELF - did you start a session? I could be way off on this. The errors are even giving you the line number so it shouldn't be hard to find! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Depreciation message I can't make out....
"Gary Lebowitz" wrote in message news:cafbvbik1ga9eyxkstpshxk+ddfax0fqoy-gnpdymfl_26_g...@mail.gmail.com... > Hi, > > I am running Moodle 2.2.3 and using PHP 5.3 on a Linux server with GoDaddy > and am getting the message about "depreciation" after having typed the > following command into their cron job manager: > /web/cgi-bin/php5_3 "$HOME/html/moodle223a/admin/cli/cron.php" > > PHP Deprecated: Comments starting with '#' are deprecated in > /web/conf/php5.ini on line 1256 in Unknown on line 0 > PHP Deprecated: Comments starting with '#' are deprecated in > /web/conf/php5.ini on line 1257 in Unknown on line 0 > > Deprecated: Directive 'magic_quotes_gpc' is deprecated in PHP 5.3 > and greater in Unknown on line 0 > Content-type: text/html > > GoDaddy says that I am using a command that is not adapted to version 5.3 > of PHP, but they suggested I contact you to fix it. Also, I do not believe > I have access to php5.ini; only they do. But I would need to tell them how > to fix this issue. And no one at Moodle.org seems to be able to help. > Perhaps it's a Moodle thing; perhaps not, but I thought it wise to contact > you. By the way, this message is only sent to me when using version 5.3 of > PHP; I have another Moodle site using 5.2 and things go perfectly well, > without this message. > > Regards, > It's "deprecated", not depreciated. That said - magic quotes were marked for "deprecation" a while ago, so you should be prepared to stop expecting them in your appls. As for the # sign, apparently it is no longer a valid char for comments (deprecated). Remove the magci quotes setting and change your # chars to // or whatever pleases you for your comments. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP session variables
On 8/8/2012 11:24 AM, Ansry User 01 wrote: I am setting the _SESSION variables in one of my file, but whenever I leave the php page session variables are not accessible. Not sure what I need to do additionally other then defining _SESSION[]. Any pointer. You must make it a habit to start each script with session_start(); so that any thing you did in the last script is returned for use in the new script. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Need to have form protection techniques
On 8/17/2012 12:05 AM, Ansry User 01 wrote: I need to know the forms validity techniques for Php. Really? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cost of redirect and site domain switch? Good Practice/ Bad Practice / Terrible Practice
On 8/17/2012 7:16 PM, Jim Lucas wrote: On 08/17/2012 01:09 PM, Tristan wrote: Sebastian, I'll check into 307 I haven't used that before but, this really is a permanent redirect. They are going to a shorter domain. About the SEO part of it though. Would it be good to find replace all internal links from somedomain.com to somenewdomain.com or will it follow the 301 with no punishment or cause any other weirdnesses you can think of. Thanks, T On Fri, Aug 17, 2012 at 1:56 PM, Sebastian Krebswrote: If you need to change the domain completely, choose "301". - Crawler will recognize it and will update their indexes quite soon. Especially you avoid "duplicate content"-punishments, because you say yourself, that the content originally comes from another domain, that isn't anymore (Like "It's not a duplicate, it's _the_ content, but under a different address"). - The delay is negliable. Also as soon as every index were updated no "new" visitor should enter your site via the old domain. Browser should (don't know wether they do, or not) recognize "301" too and redirect any further request to the url on their own (think of it as "they cache the redirect permanently"). If this change is only temporary I would recommend using "307" to avoid duplicate contents. I would even say, that a 307-redirect from somenewdomain.com to somedomain.com is more appropiate, but that depends. Regards, Sebastian You could simply remove all full domain+path URL links and replace them with absolute path urls only. turn http://www.somedomain.com/path/to/my/webpage.html into /path/to/my/webpage.html This would work with either domain. Those would be "relative paths", ..o? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cost of redirect and site domain switch? Good Practice/ Bad Practice / Terrible Practice
On 8/20/2012 12:19 AM, Jim Lucas wrote: On 8/17/2012 6:35 PM, Jim Giner wrote: On 8/17/2012 7:16 PM, Jim Lucas wrote: You could simply remove all full domain+path URL links and replace them with absolute path urls only. turn http://www.somedomain.com/path/to/my/webpage.html into /path/to/my/webpage.html This would work with either domain. Those would be "relative paths", ..o? No. Quick Google search turns up this: http://www.uvsc.edu/disted/decourses/dgm/2120/IN/steinja/lessons/06/06_04.html I have three description or types of paths that I use normally. I feel the first two generally get grouped together by most persons. Full or complete path: http://www.cmsws.com/index.php";>Home Absolute Path: Home Relative: Home -- Jim Lucas http://cmsws.com Anything that does not "absolutely" define something, is "relative" to the current context. In this case since your href does not mention the sitename, in my book that equates to something relative. Count me as one person who would never lump the first two ex. into one. The simple device of using the leading slash to start the href indicates its "relativity" to the the home folder of the site. The lack of a leading slash indicates its "relativity" to the current folder. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: get question
On 8/27/2012 3:17 PM, Jack S wrote: Hello All, Trying to figure out why when I include the page that contains this code, I'm not able to get the $calling_page populated with any values. Any help appreciated... "; } elseif ($calling_page == "index") { $title = "Title 2 - $calling_page"; $body = ""; # Non Specified Page -- } else { $title = "Title 3 - $calling_page"; $body = ""; } echo "".$title.""; ?> Since this code does nothing other than assign a value to $calling_page based upon the content of a GET variable, what do you mean by "not able to get the $calling_page populated with any values.". Are you simply saying that "$calling_page does not have a value assigned to it"? And if that is what you meant to say, then the answer is that your GET array does not contain an index of 'page'. Of course, even if that were true, you would in fact have a value in $calling_page and it would be simply: "Title 1 - ". -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: get question
On 8/27/2012 7:21 PM, Ashley Sheridan wrote: On Mon, 2012-08-27 at 18:54 -0400, Jack S wrote: OK yes, wrote: On Mon, 2012-08-27 at 16:37 -0400, Jack S wrote: > > How are you including this in your code? GET data won't be passed in a > > call like require("some_file.php?page=page"); > > -- > > Thanks, > > Ash > > http://www.ashleysheridan.co.uk > > > > > > Hi Ash, > > The index.php file has an include statement like so: > > > The code snipet is at the top of the header file. > I have done this before and it worked, just can't seem to figure out > what is wrong here. > > Thanks! > > > > > Do you have errors and notices set to display, or have you checked the error logs for anything? It could be that some change in configuration is causing a problem with the include itself. -- Thanks, Ash http://www.ashleysheridan.co.uk -- Thanks! Jack Are you passing a page parameter through the URL? The error is basically complaining that you're not. So - is this INDEX.PHP script being called by a form on the client screen that has a field with the name of 'page'? And is the script (INDEX.PHP) being called via a GET method (and not a POST) in the tag of the currently displayed page? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] The end of "mysql"
So with the announced end of the mysql functions (and switching to a different extension), one would think that my isp/hoster would be a bit more interested in my dilemma. I tried today to create my first mysqli-based test script and found that I didn't have that extension. A series of emails with my tech support told me that the shared server farm does not get "mysqli" - only their business servers. Since I dont' have a need for and want to pay more for a 'business server', I'm told I'm s... outta luck. Any idea on the approximate date when mysql truly goes away - ie, when is the proposed (next) update that will completely refuse to recognize it? Might be ammunition for me. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] The end of "mysql"
Nope. No PDO as yet either jg On Sep 7, 2012, at 11:22 PM, Adam Richardson wrote: > On Fri, Sep 7, 2012 at 9:58 PM, Jim Giner > wrote: >> So with the announced end of the mysql functions (and switching to a >> different extension), one would think that my isp/hoster would be a bit more >> interested in my dilemma. I tried today to create my first mysqli-based >> test script and found that I didn't have that extension. A series of emails >> with my tech support told me that the shared server farm does not get >> "mysqli" - only their business servers. Since I dont' have a need for and >> want to pay more for a 'business server', I'm told I'm s... outta luck. > > What about PDO? Is that available? > > Adam > > -- > Nephtali: A simple, flexible, fast, and security-focused PHP framework > http://nephtaliproject.com > > -- > 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] The end of "mysql"
On 9/8/2012 10:40 AM, Bastien wrote: Change hosts. They are not keeping up That's not entirely true. They have kept up to date with most things for the 10 years I've been with them. I think they just have to get their heads around the idea that the PHP community is moving ahead on something and they'll come around. Plus - I've just found that they do have PDO_mysql extension. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] The end of "mysql"
On 9/8/2012 9:54 AM, Jim Giner wrote: Nope. No PDO as yet either jg On Sep 7, 2012, at 11:22 PM, Adam Richardson wrote: On Fri, Sep 7, 2012 at 9:58 PM, Jim Giner wrote: So with the announced end of the mysql functions (and switching to a different extension), one would think that my isp/hoster would be a bit more interested in my dilemma. I tried today to create my first mysqli-based test script and found that I didn't have that extension. A series of emails with my tech support told me that the shared server farm does not get "mysqli" - only their business servers. Since I dont' have a need for and want to pay more for a 'business server', I'm told I'm s... outta luck. What about PDO? Is that available? Adam -- Nephtali: A simple, flexible, fast, and security-focused PHP framework http://nephtaliproject.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Actually - I was incorrect. A quick run of "get_loaded_extensions" reveals that my hoster does provide something named: pdo_mysql as the very last item. Guess I'll have to go with that ext rather than mysqli. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Programmers and developers needed
On 9/13/2012 3:45 AM, agbo onyador wrote: Hello there! We are looking for programmers and developers to create a world wide system. Your comments are welcome. really?? A "world wide system"? And this is how you advertise it? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] tricky code problem
This is a tricky one but let's see if I can explain it. 1 - using a menu screen I have a link that calls a js function that opens a popup with a form in it; 2 - the form receives some user input (a login) and then the user clicks a submit button; 3 - the button has an onclick that calls a js func that does an xmlhttprequest to a php script using a GET with some parms; 4 - the php script called above returns a true/false value back to the js function; 5 - the js function returns the true/false value back to the html tag that triggered it; 6 - the form in the html containing the input tag gets submitted if the return was true, calling a different php script with a POST and definitely no parms in the action value of the tag. What shows up on my address bar (ie) is a composite of the script name called in item 6 along with the parms (ie, GET values) from the js xmlhttprequest string in item 3 appended to it. Now all of my scripts have a header that eliminates caching, so that's not it afaik. I've actually closed my session and come back an hour later and this still occurs. Can anyone see how this can possibly be happening? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Programmers and developers needed
How naive you are to think that technology will promote world peace. People promote world peace and all the technology in the world cannot help them. You want world peace - stop chasing the "easy solution" and go do something. Look at the great "social networks" of today - they amount to picture sharing , boring recitations of a day's activities and character bashing. This great evolution of social networking that you wish to develop will do nothing more than improve upon that. On 9/18/2012 12:58 PM, Volmar Machado wrote: I guess that social structures didn't changed so much the last 10k years. I also guess if we want peace at all. The people just need to fight for something. Homogeneous world don't would bring heterogeneous ideas. Anyway I hope that you could do this, and become a great great genius, that will ever shine in the history and future generations. 2012/9/18 Matijn Woudt : On Tue, Sep 18, 2012 at 8:52 AM, agbo onyador wrote: The growing power of the internet and global networks. (on the world's politics, economies and even on daily life of ordinary people) Programmers and developers needed: Thanks I still cannot figure out if this is a joke or if you're really looking for world peace.. If you're serious, you might want to stop and take a look at Newton's third law, I quote from wikipedia: "When a first body exerts a force F1 on a second body, the second body simultaneously exerts a force F2 = -F1 on the first body. This means that F1 and F2 are equal in magnitude and opposite in direction.", or simplified "To every action there is always an equal and opposite reaction." It fits also easily on humans, take one step into peace, and it will have an effect in opposite direction elsewhere. Also, why do you think you can make a better social network than the already existing ones? Even the big internet giant Google can't seem to make it's social network a big success, and you (without even an concrete idea) can do that better? You might as well just open a simple website with a 'Like' button and ask everyone to like that page, so we end up with peace!:) - Matijn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Joining a team, where no wiki or docs are available
On 9/24/2012 10:05 AM, AmirBehzad Eslami wrote: Hi, i'm going to join a mid-size company with a few PHP-driven projects written in procedural PHP, million years old. At the moment, they don't have a wiki or any documentation about their projects. For me, the first challenge in probation period is to understand how their code works. * Considering that there is no wiki or docs, How can I see the Big Picture?* i'm sure this is a common problem for programmers everywhere. What approach do you use in a similar situation? Is there a systematic approach for this? Is there reverse-engineering technique to understand the design of code? Please share your experience and thoughts. -Thanks in advance, Behzad If you really are joining a team, I would expect that the teammates would be guiding you through their systems. If only to ensure that you are becoming productive. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP as Application Server
On 9/26/2012 5:58 AM, Maciej Liżewski wrote: Hi, Maybe this topic have been already on board, but I could not find nothing in google, so my question to PHP maintaneers (and other users too) is: Why there is no possibility to run PHP in "application server" way among other SAPI modules and other possibilities to run PHP? PHP would encounter great performance boost and became more "enterprise" :) Just look at Ruby which is slow as hell compared even with PHP. By "application server" I mean scenario when there is statefull application on server side not only by session mechanizms but all classes definitions maintained in memory (no need to load class definition on every request), static class members (and their changes) persistent, background threads, etc. This way any op-code cachers won't be necessary... sounds great, huh? others have it already, so why doesn't PHP? are there any cons? problems too hard to solve (one can be memory leaks, thread safe coding, etc)? I mean it - I am realy curious why there is no such possibility and is there any hope we could get it? TIA for any answers on this topic. Thirty+ years as a professional application designer, developer and manager and I don't have a clue about what you are proposing. I must have been in a different world. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP as Application Server
On 9/26/2012 11:23 AM, Maciej Liżewski wrote: Well.. many things changed during last 30 years. Cobol is not mainstream, we have got OOP, Java, Python, Ruby, Google and other great things :) I am talking about stateful application server. There are plenty examples in other programming languages: Java has Jetty, Tomcat, Ruby On Rails, Python and Passenger WSGI. All of them have one common thing: application persist in memory between requests. Even for interpreted languages (such Ruby) - this has advantage of loading sources only once, parse it only once and initialize memory structures for those definitions only once. On the opposite - PHP loads EVERY single resource on every request. This is why it needs op-code cachers, accelerators etc. Another advantage of using stateful application servers is that you can simply keep gloabal state of your application (global variables, static object properties) in memory. It simplifies many tasks which in PHP require sessions, writing files with serialized data and deserialize them on every request... Just imagine such scenarios: now PHP acts like this on every request: 1. locate resources (source files in this case), parse and load them (possibly with op-code cache) 2. initialize global context ($_SERVER, $GLOBALS, $_POST, $_GET, etc) 3. run code 4. destroy all resource and free memory for next request persistent application servers load resources only on startup (or when needed) and keep them in memory until programatically freed or until end of application (server shutdown). So every request looks like this: 1. initialize global context 2. run already parsed code is that makes whole thing clear? Another nice example - simple counter. In PHP you have to: 1. read file with counter 2. increment value 3. write serialized value to file ...on every request. in Java (for example) you just write class: class Counter { static private counter = 0; public void increment() { this.counter++; } } and because class definition persists in application server - static member is maintained between requests and whole things works as expected... 2012/9/26 Jim Giner : On 9/26/2012 5:58 AM, Maciej Liżewski wrote: Hi, Maybe this topic have been already on board, but I could not find nothing in google, so my question to PHP maintaneers (and other users too) is: Why there is no possibility to run PHP in "application server" way among other SAPI modules and other possibilities to run PHP? PHP would encounter great performance boost and became more "enterprise" :) Just look at Ruby which is slow as hell compared even with PHP. By "application server" I mean scenario when there is statefull application on server side not only by session mechanizms but all classes definitions maintained in memory (no need to load class definition on every request), static class members (and their changes) persistent, background threads, etc. This way any op-code cachers won't be necessary... sounds great, huh? others have it already, so why doesn't PHP? are there any cons? problems too hard to solve (one can be memory leaks, thread safe coding, etc)? I mean it - I am realy curious why there is no such possibility and is there any hope we could get it? TIA for any answers on this topic. Thirty+ years as a professional application designer, developer and manager and I don't have a clue about what you are proposing. I must have been in a different world. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Sounds to me like you'd need more hardware to support such a concept. I realize that memory can be mapped to disk to avoid the need to have HUGE amounts of ram in your server(S!) but with ever-increasing processor speed, is it really necessary to go this route? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] about lock some codes.
On 9/27/2012 7:05 AM, Maciek Sokolewicz wrote: On 27-09-2012 11:31, lx wrote: Hello: I have a question now.the code is: $ftemp = fopen("$fdoc_tmp/temp_proxy", 'w'); fwrite($ftemp, $content); fclose($ftemp); exec("/usr/local/bin/gdnsproxy -a -f $fdoc_tmp/temp_proxy 1>$fdoc_tmp/dout 2>$fdoc_tmp/derr", $data, $ex_result); echo "ret=".$ex_result; As you see, If a process run these,this is right.But two processes run this codes. the order maybe is: 1.process 1 create the temp_proxy1 2.process 2 create the temp_proxy2 3.process 1 exec temp_proxy2 4.process 2 exec temp_proxy2 The temp_proxy1 can't exec. So,I want to know how to solve it. Thank you. Well, there are basically 2 ways: 1. introduce locking; you can lock the file and have the other script check if the file is locked. If so > have it usleep() and check again. 2. If you can run gdnsproxy in parallel, you could instead change the script to make $fdoc_tmp/temp_proxy unique for that script. So instead of just writing, you first check if the file exists, if so, create a file with a different (non-existent) name and then try again. Otherwise, use the first name. Then pass the 'unique' name to gdnsproxy. Even simpler - use the 'tempnam' or 'tmpfile' functions to always have a unique name and avoid having to check for an existing file. Amazing what the php Manual has in it... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Here's my rounding
On 9/28/2012 2:11 AM, Simon J Welsh wrote: On 28/09/2012, at 6:08 PM, Chris Payne wrote: $test2 = '253177'; echo $tes2 . " rounded to: "; $rounded_number = round($test2,-3); echo $rounded_number; Is it SUPPOSED to happy a number is sent to this little system and it's SUPPOSED to round the number up. So if the number was 144035 the system should look at it and say "Hey uo, we need to round this up" So basicially I need it to convert in thousands. Even if the total is a fraction over it still needs to ne calculated as the next thousand up. Sprru of o'm confusing you, i'm very tired. So basically, just make the last 4 numbers always round up. 255000 would be correct - 255590 would beINSORERECT as it should display 255600. Hope that helped someone to help me :-) xxx Chris I would use something similar to $rounded_number = ceil($test2/1000)*1000; --- Simon Welsh Admin of http://simon.geek.nz/ From my days as a math major, rounding doesn't always go up - it goes to the nearest level that you have indicated. As Simon shows you, you want to ceil to always go up, and floor to always go down. Neat function names actually... :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php can't insert data mysql table
On 10/1/2012 12:32 AM, Tim Dunphy wrote: Hello list, I'm trying to learn and get comfortable with HTML forms in PHP. In one example I am trying to include a file upload in one of the forms. I can connect to the database but for some reason the MySQL query string is bad. I've been over this for a while now and I think the problem is with the form. I was hoping to get the esteemed opinion of the list in where I may be going wrong. This code: http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en"> Guitar Wars - Add Your High Score Guitar Wars - Add Your High Score Thanks for adding your new high score!'; echo 'Name: ' . $name . ''; echo 'Score: ' . $score . ''; echo '<< Back to high scores'; // Clear the score data to clear the form $name = ""; $score = ""; mysqli_close($dbc); } else { echo 'Please enter all of the information to add your high score.'; } } ?> Name: Score: Screenshot: Results in this output: Guitar Wars - Add Your High Score Cannot insert query Thanks again for your help. This is an awesome list! Tim You should have your error settings set to show everything. I include these three lines in all my development work: error_reporting(E_ALL); ini_set('display_errors', '1'); set_time_limit(2); In this case, I do think that your insert statement is incorrect - I could be wrong. I think the VALUES clause s/b just 'VALUE'. Also if you added MYSQLI_ERROR to your error handling you should get a very helpful message. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php can't insert data mysql table
On 10/1/2012 9:12 AM, Tommy Pham wrote: On Mon, Oct 1, 2012 at 6:03 AM, Jim Giner wrote: In this case, I do think that your insert statement is incorrect - I could be wrong. I think the VALUES clause s/b just 'VALUE'. Also if you added MYSQLI_ERROR to your error handling you should get a very helpful message. VALUES also work. See http://dev.mysql.com/doc/refman/5.5/en/insert.html Yeah - I just saw it in one of my scripts. So - adding the error handling and the call to mysqli_error should help the OP diagnose his problem. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php can't insert data mysql table
On 10/1/2012 12:32 AM, Tim Dunphy wrote: Hello list, I'm trying to learn and get comfortable with HTML forms in PHP. In one example I am trying to include a file upload in one of the forms. I can connect to the database but for some reason the MySQL query string is bad. I've been over this for a while now and I think the problem is with the form. I was hoping to get the esteemed opinion of the list in where I may be going wrong. This code: http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en"> Guitar Wars - Add Your High Score Guitar Wars - Add Your High Score Thanks for adding your new high score!'; echo 'Name: ' . $name . ''; echo 'Score: ' . $score . ''; echo '<< Back to high scores'; // Clear the score data to clear the form $name = ""; $score = ""; mysqli_close($dbc); } else { echo 'Please enter all of the information to add your high score.'; } } ?> Name: Score: Screenshot: Results in this output: Guitar Wars - Add Your High Score Cannot insert query Thanks again for your help. This is an awesome list! Tim ON second glance - your table seems to have 4 fields: id,date,id,name,screenshot. Your insert has 5 values: VALUES (0, NOW(), '$name', '$score', '$screenshot') That right there is going to throw an error. BTW - You're saving the name of the screen shot file but are you actually saving the uploaded file somewhere else in your code? Didn't see it here and just wondered. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php can't insert data mysql table
oops - I added a an extra "id" field. There were only 4 in OP's DESCRIBE email. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php can't insert data mysql table
On 10/1/2012 12:20 PM, Tim Dunphy wrote: hey thanks guys adding debugging info worked. Actually it was mysqli_error() providing me with a specific error of where the problem was. Cannot insert query:Duplicate entry '0' for key 'PRIMARY' This is the data in the table mysql> select * from guitarwars; ++-+---+---+---+ | id | date| name | score | screenshot| ++-+---+---+---+ | 0 | 2012-10-01 11:55:45 | Tommy Tutone | 2442 | bg_titlestrip.jpg | | 1 | 2012-10-01 08:34:18 | Dunphy| 2 | proof.jpg | | 2 | 2012-10-01 00:25:53 | ray davies| NULL | 2241 | | 3 | 2008-04-22 14:37:34 | Paco Jastorius| NULL | NULL | | 4 | 2008-04-22 21:27:54 | Nevil Johansson | NULL | NULL | | 5 | 2008-04-23 09:12:53 | Belita Chevy | NULL | NULL | | 6 | 2008-04-23 14:09:50 | Kenny Lavitz | NULL | NULL | | 7 | 2008-04-24 08:13:52 | Phiz Lairston | NULL | NULL | | 8 | 2008-04-25 07:22:19 | Jean Paul Jones | NULL | NULL | | 9 | 2008-04-25 11:49:23 | Jacob Scorcherson | NULL | NULL | ++-+---+---+---+ This was the query I was using: $query = "INSERT INTO guitarwars (date, name, score, screenshot) VALUES (NOW(), '$name', '$score', '$screenshot')"; It seems to be inserting a default value of 0 since the id is not being specified and that's when I realized that I had failed to auto_increment the id column. D'oh! So once I did that everything worked like a charm. @Ken First -- NEVER post code with your database username/password. Since you did, change your db password immediately. Well actually I did not. Did you really think 'secretsauce' was my password? :) But I guess you're right in that this may be a little ambiguous when seeking advice in lists so from now on I will take your advice on making login information unambiguously fake in the form of user='' and password='xxx'. @Stuart But take note of what everyone else is saying. You should be getting the error message when this happens which will tell you exactly what the problem is, above and beyond "Cannot insert query" (which, btw, makes no sense at all :)). Ok well I'm using an 'insert' query so I'm not sure why you say that this makes no sense at all. :)) If you don't mind giving this n00b advice what would be a better/more accurate error message? They take away from this for me was.. don't skimp on the error messages! The one I got was so clear that fixing the problem was easy at that point. But thanks again guys.. this list has been an indispensable source source of wisdom on my journey in learning PHP. Tim Thanks again guys, Tim I think the comment about your "cannot insert query" was because it really did not make sense. Once truly cannot "insert a query". Since you ask tho, a more approp message might be "Insert query failed to execute.Error returned was " . mysqli_error() . "Query was $q" As for your index issue - you are using an autoincrement(?) field as the primary key. Is this related to another record in your db? If not, why even have the primary key? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Differences
On 10/3/2012 8:48 PM, David McGlone wrote: Hi everyone, I have been playing around with some code the list helped me with a while back and I'm not grasping the concept between return and echo and the PHP manual doesn't answer this, unless I'm missing something. There is an example at the very bottom of PHP's return manual, but it's confusing. So now I'm left wondering why return will only give me the first result in an array, but echo will give me all the results of the array. Using stuart's example he had sent me a while back I've messed around with it and modified it to better understand it: function filename($prefix) { $matches = glob('images/property_pics/'.$prefix.'*'); foreach($matches as $filename){ return $filename; } } echo completeImageFilename($row['MLS_No']); With the above code I only get the first image of each picture name, but when I change return to echo, it groups and displays all the pics that have the same picture name. -- David M. I've read thru 9 responses to the OP and not one of you mentioned that the code presented is problematic in itself. Very forgiving, but perhaps someone should have suggested that he post "actual code" when looking for help in the future, and not some typing that is supposed to represent the problem. In this case, I"m looking for the function he called "completeImageFilename" :):) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Differences
On 10/4/2012 7:08 PM, David McGlone wrote: On Thursday, October 04, 2012 06:06:50 PM Jim Giner wrote: On 10/3/2012 8:48 PM, David McGlone wrote: Hi everyone, I have been playing around with some code the list helped me with a while back and I'm not grasping the concept between return and echo and the PHP manual doesn't answer this, unless I'm missing something. There is an example at the very bottom of PHP's return manual, but it's confusing. So now I'm left wondering why return will only give me the first result in an array, but echo will give me all the results of the array. Using stuart's example he had sent me a while back I've messed around with it and modified it to better understand it: function filename($prefix) { $matches = glob('images/property_pics/'.$prefix.'*'); foreach($matches as $filename){ return $filename; } } echo completeImageFilename($row['MLS_No']); With the above code I only get the first image of each picture name, but when I change return to echo, it groups and displays all the pics that have the same picture name. -- David M. I've read thru 9 responses to the OP and not one of you mentioned that the code presented is problematic in itself. Very forgiving, but perhaps someone should have suggested that he post "actual code" when looking for help in the future, and not some typing that is supposed to represent the problem. In this case, I"m looking for the function he called "completeImageFilename" :):) Uh Oh, we're in trouble ;-) Sorry about that Jim, I accidently typed the wrong function name. Here's the corrected code. Everybody's answer was spot on and I learned a great deal about return and echo. :-) function completeImageFilename($prefix) { $matches = glob('images/property_pics/'.$prefix.'*'); foreach($matches as $filename){ return $filename; } } echo completeImageFilename($row['MLS_No']); Hopefully you got my point tho - don't post code that is not THE ACTUAL CODE that you are running. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: building upon the code RE: Differences
On 10/4/2012 10:15 PM, David McGlone wrote: I hope I'm not being a pest. I've played with the return and echo so much today I've finally realized I'm going in circles. But I can say I understand it more than ever. Now whats on my mind is breaking out of this circle and doing more with this code. What I am trying to do now is instead of having ALL the images display, I want to try and group them by their name. If I were using SQL I'd simply use a where clause and be done with it, but I'm not sure what would acomplish the same thing or similiar to a where clause in php. I dont' see how a where clause in sql provides you with a result that organizes the images by name. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: building upon the code RE: Differences
On 10/4/2012 10:15 PM, David McGlone wrote: I hope I'm not being a pest. I've played with the return and echo so much today I've finally realized I'm going in circles. But I can say I understand it more than ever. Now whats on my mind is breaking out of this circle and doing more with this code. What I am trying to do now is instead of having ALL the images display, I want to try and group them by their name. If I were using SQL I'd simply use a where clause and be done with it, but I'm not sure what would acomplish the same thing or similiar to a where clause in php. ok - your idea of using where implies that you would do multiple queries to get all of the files, one group at a time. I see that now. In your case, with the data just being filenames and not table records, you should look at the myriad of functions under 'array' in the manual. A handy thing that manual :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: building upon the code RE: Differences
On 10/5/2012 8:09 AM, David McGlone wrote: On Thursday, October 04, 2012 10:41:17 PM Jim Giner wrote: On 10/4/2012 10:15 PM, David McGlone wrote: I hope I'm not being a pest. I've played with the return and echo so much today I've finally realized I'm going in circles. But I can say I understand it more than ever. Now whats on my mind is breaking out of this circle and doing more with this code. What I am trying to do now is instead of having ALL the images display, I want to try and group them by their name. If I were using SQL I'd simply use a where clause and be done with it, but I'm not sure what would acomplish the same thing or similiar to a where clause in php. I dont' see how a where clause in sql provides you with a result that organizes the images by name. All the images I have that go together have the same name. 12345_1.jpg 12345_2.jpg 12345_3.jpg So by using a where clause in a MySQL select statement and some php, I'd be able to grab the result set with the same name. -- David M. True dat. So why don't you just change the "prefix" value coming into your function? Or - run it once for all prefixes, build a 2nd array of the unique ones, sort them, display them, let the user pick one, then re-run it for that prefix alone. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: limiting
On 10/8/2012 11:11 PM, David McGlone wrote: Hi all, is there any other way to limit this code to only displaying 1 image other than using return. When I use return, I can't get the other images to display in lightbox, but when I use echo, all 5 of the images will correctly display in lightbox, but they are also displaying on the page. $result = mysql_query("SELECT * FROM properties"); $row = mysql_fetch_array($result); $matches = glob('images/property_pics/212006966/' .$prefix. '*'); foreach($matches as $match){ echo ""; I'm not even sure if this is possible, but thought I'd ask before I scrapped the idea. I've been at this code since last thursday trying to learn as much as I can about it and I just keep going in circles and I'm starting to feel like glob() is what is limiting me. I've tried various code blocks with things like where(), str_repeat, basename, scandir, sort etc with no luck. :-/ I hate to sound condescending, but you are showing some serious deficiencies in your programming ability. I have to say that you are tackling some very complex processes without the basic understanding of programming that one needs. What I base this opinion on is that since you first revealed your lack of understanding of Return and echo in php, you have spent another 3 days and STILL don't understand? Really? As for the code above - once again it looks like you have posted a re-typing of some code you have tried to execute. I say that because you have a query and a fetch of one record of the results THAT HAS NOTHING TO DO WITH THE REST OF THE CODE! Also - you have an array being used as part of the Rel tag? What's up with that? (I think you meant to use $match - but that further verifies that this is NOT the code you ran.) Finally - the code is (from your description) doing exactly what it is designed to do (the running code that is). All the (repeated) "echo" statements are going to put something on your web page. The question you have is (apparently) how to hide them, since I believe Lightbox is going to have to have them present in order to do its thing. And so - in parting - I think you need to develop some html knowledge to facilitate that "hiding" part and some immediate skills in the general area of programming and learning to locate and read the right manuals. "Glob" is the least of your concerns. Yes - I'm being rough (I say this to you David as well as the rest of the community that is still interested in this post) but somebody has to make you realize that you are seriously in over your head and don't even know it. Have you read a book on php and perhaps one on CSS to help with your "hiding" problem? (BTW - that last was a hint.) AND PLEASE - don't post supposed "code snippets" again. Let us see what you really ran if you want us to help. Or do you not know how to copy and paste either? I/we can't help you if we can't see it. Sorry to be so blunt. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: limiting
PLEASE SEE MY COMMENTS INTERSPERSED AND BELOW. (yes this is a top post) On 10/9/2012 3:18 PM, David McGlone wrote: On Tuesday, October 09, 2012 12:18:06 PM Jim Giner wrote: On 10/8/2012 11:11 PM, David McGlone wrote: Hi all, is there any other way to limit this code to only displaying 1 image other than using return. When I use return, I can't get the other images to display in lightbox, but when I use echo, all 5 of the images will correctly display in lightbox, but they are also displaying on the page. $result = mysql_query("SELECT * FROM properties"); $row = mysql_fetch_array($result); $matches = glob('images/property_pics/212006966/' .$prefix. '*'); foreach($matches as $match){ echo ""; I'm not even sure if this is possible, but thought I'd ask before I scrapped the idea. I've been at this code since last thursday trying to learn as much as I can about it and I just keep going in circles and I'm starting to feel like glob() is what is limiting me. I've tried various code blocks with things like where(), str_repeat, basename, scandir, sort etc with no luck. :-/ I hate to sound condescending, but you are showing some serious deficiencies in your programming ability. I have to say that you are tackling some very complex processes without the basic understanding of programming that one needs. What I base this opinion on is that since you first revealed your lack of understanding of Return and echo in php, you have spent another 3 days and STILL don't understand? Really? I was afraid when I first posted that question, it would give that impression. I've known what echo does, but not very much about return. Also a part of me has always wondered when I'm studying code from things like wordpress I don't think I have seen any echo statements. If I did it was very very few. (hint: why I asked about templeting systems about a month ago.) As for the code above - once again it looks like you have posted a re-typing of some code you have tried to execute. I say that because you have a query and a fetch of one record of the results THAT HAS NOTHING TO DO WITH THE REST OF THE CODE! The query is geting a number out of the database and putting the value in $prefix. NOT IN THIS SCRIPT!! Also - you have an array being used as part of the Rel tag? What's up with that? (I think you meant to use $match - but that further verifies that this is NOT the code you ran.) I tried using $match and $matches because I got confused there for a bit and changed it. $MATCH WOULD WORK; $MATCHES WOULD NOT. It's suppose to be a 'name' - so why would you put an array reference in the Rel attribute? Finally - the code is (from your description) doing exactly what it is designed to do (the running code that is). It sure is, and I found out what my whole problem was this morning before I went to work. My problem was lightbox was not putting all the images in $match. but I never suspected it until Matijn and Marco, posted an example of code and It turned my attention to the piece of code... put a bunch of images in a folder and try running the code. You'll see what I'm talking about. THATS' CAUSE YOU DIDN'T LABEL THEM WITH $MATCH! All the (repeated) "echo" statements are going to put something on your web page. Yes I was getting stuff on the page, and then when I'd try and build onto the idea, and things broke, I'd try something else, and something else, until finally I'm all confused with it. for example I'd forget to terminate something and get a blank screen and imediately suspect it was the new code I introduced. After the millionith time I started realizing when I get a blank screen, I forgot my semicolon at the end of a line somewhere. The question you have is (apparently) how to hide them, since I believe Lightbox is going to have to have them present in order to do its thing. That's part of it. the other part is that lighbox is supposed to do that automatically and it should, and that's another reason I was getting confused. like I said earlier run the code and you'll see what I'm saying. I HAVE USED LB - IT DOESN'T HIDE THINGS. IT DISPLAYS THINGS. THINGS THAT YOU PROVIDE - WHETHER YOU HAVE THEM HIDDEN OR NOT. Feel free to check out a site I developed - voorheesvilefd.org. This site uses plenty of php and LB to display random photos drawn from folders across the site. And so - in parting - I think you need to develop some html knowledge to facilitate that "hiding" part and some immediate skills in the general area of programming and learning to locate and read the right manuals. "Glob" is the least of your concerns. Yes - I'm being rough (I say this to you David as well as the rest of the community that is still interested
Re: [PHP] Re: limiting
On 10/9/2012 3:46 PM, Matijn Woudt wrote: On Tue, Oct 9, 2012 at 9:18 PM, David McGlone wrote: On Tuesday, October 09, 2012 12:18:06 PM Jim Giner wrote: Sorry to be so blunt. It's fine I kinda figured I'd be either ignored, or yelled at when I asked and I now know that I need to be a professional to ask questions here so there went my confidence. -- David M. David, You really don't need to be a professional here to ask questions, but you can imagine that we're not going to write code for you. Some people expect professional support here (like they paid for it), and that's clearly not the case. We are all volunteers with our (limited) spare time. Therefore, you're expected to figure out most things out yourself (reading PHP manual, google, etc), and only ask here if you really can't figure things out. Then you can post what you have tried, and what you think it should do. For example your previous post, you could have just looked up what the 'echo' and 'return' statements do in the PHP manual, and they are probably explained pretty OK in those books you own too. You probably could have answered the questions you posted here yourself, after reading PHP manual carefully. - Matijn Matijn - well said. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RES: [PHP] Re: limiting
On 10/9/2012 4:54 PM, Samuel Lopes Grigolato wrote: I don't know if it has any value, but here's my 2 cents: People here expect tricky questions. Of course "to be tricky" is subjective and is based on your knowledge level. When posting, please try to write every bit of effort you had so far trying to solve your problem. Besides that, please, don't feel sad or ignored or whatsoever if the answers you've got wasn't satisfactory or doesn't came at all. As Matijn said, this list isn't meant to be a "hand holding" professional support and it may happen that the ones with the knowledge simply doesn't got the time to help. Remember that any answer is given with nothing in return, so, read carefully and follow the wise advices provided by the ones that learned the hard way and are here today "softening" the path for the newcomers. Everything should be interpreted as directions and hints, and not as yells or other bad things, doesn't matter how bad the words appear to be. Good luck in your path. -Mensagem original- De: Jim Giner [mailto:jim.gi...@albanyhandball.com] Enviada em: terça-feira, 9 de outubro de 2012 17:07 Para: php-general@lists.php.net Assunto: Re: [PHP] Re: limiting On 10/9/2012 3:46 PM, Matijn Woudt wrote: On Tue, Oct 9, 2012 at 9:18 PM, David McGlone wrote: On Tuesday, October 09, 2012 12:18:06 PM Jim Giner wrote: Sorry to be so blunt. It's fine I kinda figured I'd be either ignored, or yelled at when I asked and I now know that I need to be a professional to ask questions here so there went my confidence. -- David M. David, You really don't need to be a professional here to ask questions, but you can imagine that we're not going to write code for you. Some people expect professional support here (like they paid for it), and that's clearly not the case. We are all volunteers with our (limited) spare time. Therefore, you're expected to figure out most things out yourself (reading PHP manual, google, etc), and only ask here if you really can't figure things out. Then you can post what you have tried, and what you think it should do. For example your previous post, you could have just looked up what the 'echo' and 'return' statements do in the PHP manual, and they are probably explained pretty OK in those books you own too. You probably could have answered the questions you posted here yourself, after reading PHP manual carefully. - Matijn Matijn - well said. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php And your 2 cents are very well spent too! Not all questions need to be tricky. Sometimes a new user just hasn't got something quite right and doesn't see it. Ask away in that case and the simple error will be pointed out. There are always roadblocks in the development of a project as well as the development of a programmer. jg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: limiting
On 10/10/2012 10:07 AM, Floyd Resler wrote: On Oct 10, 2012, at 9:12 AM, Andy McKenzie wrote: Have you read a book on php and perhaps one on CSS to help with your "hiding" problem? (BTW - that last was a hint.) I've read plenty of PHP books I own at least 5 and ALL of them I've read hardly ever explain anything at all. They just throw some code in there and say "this is what it does" and gives a picture of the finished product. Total waste of my money! Also, how am I going to learn PHP if I've got to mix it all up with CSS. It's just going to make things harder and more confusing on me. I only threw lightbox in there because I knew I didn't have to do or learn anything special and to put a smile on my face if it worked. After all, if it can't be fun, why do it? I rarely post anything to this list, because almost everything asked is above my level of understanding. But, speaking as a relative beginner, I have a few comments here. 1) Books. I, too, have read a lot of PHP books. In the end, the ones I've found most useful were by WROX press. Their "Beginning PHP4" by Choi, Kent, Lea, Prasad, and Ullman was one of the best "intro to programming" type books I've found for the way I learn. It's now obsolete, but the core information is still good. I haven't read through the Beginning PHP 5.3 version as thoroughly, but it also seems to be pretty good. You might also want to check with local community colleges to see if someone offers a basic course -- PHP, C, C++, something like that. The language may be different, but the concepts remain the same. 2) "They just throw some code in there and say "this is what it does" and gives a picture of the finished product. Total waste of my money! Also, how am I going to learn PHP if I've got to mix it all up with CSS." This one's harder. These days CSS is part of the web, and you're stuck with it if you want to do anything complex. So here's my advice: Find something simple to experiment with. Don't start with a complex project, start with something that doesn't actually do anything useful. When I start trying to understand a function I haven't used before, I build a new page called something like "foo_test", where foo is the name of the function. These days it might be ip2long_test, or something like that, but I still have some in my test folder with names like "echo_test.php" where I was trying to figure out how that function worked. Start there. Do something simple. Lightbox may be too complex. Maybe build a fortune cookie webpage, where every time you click a button it reloads with a new fortune. Learn to pull fortunes out of a file and out of a database. Once you've got the hang of that, start using CSS to change how it looks. Once THAT's working right, figure out how to use JavaScript (you're going to need it sooner or later!) and AJAX to make it reload the fortune without reloading the whole page. Yeah, it's a boring project. But it's a stepping stone to doing what you really want to do. The alternative is to do what I did: start with a big project, and accept that you're going to rewrite it dramatically later. I started with a book inventory system. First I built a login and authentication system -- that builds a form, and queries the database to see if the userid and password are correct. Then I built a system to list what was in the book table for the database. Around the time I finished that, I realized I needed more granularity in user logins, so I went back and rebuilt the login tool. Then I realized I didn't actually have a way to add stuff to the DB, so I built that tool and so on. It ended up taking me something like a year, because I'd never looked at PHP before, and I've now scrapped the entire project and rebuilt it. Why? Because I did just about everything wrong. It just plain wasn't practical to try to fix it. I'd never learned the basics, I just threw myself at a big project to see what would happen. Good luck! -Andy McKenzie Excellent advise! When learning any language, those small steps you suggest is how I've always learned the language. A few years ago I ran across someone who didn't know a thing about programming but wanted to learn. The first project he wanted to tackle was to write his own online role playing game. You know, like World of Warcraft! Uh, yeah. I steered him away from that! Take care, Floyd All great advice but alas, I fear that my long-winded response that began all these succeeding advice columns has steered our OP away from this list. He thinks we're above his level (we are) and that he needs to start somewhere else, which means he'll probably repeat the mistakes that have been mentioned here. Oh, well you can only help those who ask for it, and only if they know what to do with it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: limiting
On 10/10/2012 1:19 PM, David McGlone wrote: With that said, I just may leave the list. After all if this is all I'm going to get out of it, it's not worth it! -- David M. This list has given you some very good advice, much of it from others. It may not have solved your understanding of 'glob' (which is just another function - how could it alone mess up your project?) but it has felt your pain and offered you some ways to get up to speed. Don't leave - take the advice with the sentiment it was given and learn. This list is all about learning. Just don't tackle the Tour de France until you get your training wheels off! :) BTW - in any of your other computer languages didn't they utilize a 'return' statement? PHP's is no different. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: limiting
On 10/10/2012 2:36 PM, Tim Streater wrote: On 10 Oct 2012 at 19:17, David McGlone wrote: BTW - in any of your other computer languages didn't they utilize a 'return' statement? PHP's is no different. back in like '85, I learned Pascal that's the only language I learned and I don't recall if it used return. Mmmm. There's the problem. Pascal doesn't *have* a return statement. In Pascal, implicitly, you return when execution reaches the end of a function. In fact the same is true of PHP and JavaScript, but in those languages you can return early just by saying return. IMO, this is a major limitation of Pascal. I use returns wherever I feel like it - if I detect there's nothing more for the function to do, I return. Purists object to this; they say you should enter a function at one place and leave at one place. Well, that's a point of view. But more often that not it just leads to convoluted code in order to achieve that. The one time I *had* to use Pascal as that was the only option, I simply put a 999: label at the end of the function and did goto 999 wherever I wanted to do a return. Simples! -- Cheers -- Tim Now you went and gave our OP something else to think about! :(:( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: limiting
On 10/10/2012 4:27 PM, Matijn Woudt wrote: On Wed, Oct 10, 2012 at 10:26 PM, Ashley Sheridan wrote: On Wed, 2012-10-10 at 14:53 -0400, David McGlone wrote: On Wednesday, October 10, 2012 07:36:00 PM Tim Streater wrote: On 10 Oct 2012 at 19:17, David McGlone wrote: BTW - in any of your other computer languages didn't they utilize a 'return' statement? PHP's is no different. back in like '85, I learned Pascal that's the only language I learned and I don't recall if it used return. Mmmm. There's the problem. Pascal doesn't *have* a return statement. In Pascal, implicitly, you return when execution reaches the end of a function. In fact the same is true of PHP and JavaScript, but in those languages you can return early just by saying return. IMO, this is a major limitation of Pascal. I use returns wherever I feel like it - if I detect there's nothing more for the function to do, I return. Purists object to this; they say you should enter a function at one place and leave at one place. Well, that's a point of view. But more often that not it just leads to convoluted code in order to achieve that. The one time I *had* to use Pascal as that was the only option, I simply put a 999: label at the end of the function and did goto 999 wherever I wanted to do a return. Simples! goto was the thing that got on my nerves. Even to this day I hate that word with a passion. I think most people do, all but BASIC purists! Not really, goto can safe you a mess. In some situations it's much easier and cleaner to use something like goto cleanup; at each error case, instead of duplicating the cleanup code all over again (Closing sockets, or in languages like C, freeing memory). - Matijn haven't used a goto or go in 30 years. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP The Right Way (website)
On 10/14/2012 1:10 AM, tamouse mailing lists wrote: This just dropped in my inbox the other day from Smashing #69: 2. PHP The Right Way If you are developing for the Web, the chances are high that you have to deal with PHP on a regular basis. However, once you've stumbled upon a problem that you have to solve, finding a good solution among thousands and thousands of (partly outdated) PHP tutorials out there can be quite a nightmare — especially if you are relatively new to PHP. Where would you go to learn about the current best practices in PHP? PHP The Right Way Perhaps PHP The Right Way. The site is an easy-to-read, quick reference for the best practices in PHP, accepted coding standards, and links to authoritative tutorials around the Web. Josh Lockhart has worked together with a dozen of well-respected members of the PHP community to create a useful, up-to-date resource for everybody to use. I've just been perusing it, and it offers some good advice. Anyone here work on it / read it? Thoughts? Sounds like a good idea, but as for me - if I was a newbie I'd have a problem with their very first instructions. It says right off the start to type in the following: php -5 localhost:8000 which when I do (from a dos prompt) gives me a nice description of the command, but fails to do anything else for me. So how does this (as it says) "help me learn with the hassle of configureing and installing a full-fledged web server"? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP The Right Way (website)
On 10/14/2012 12:06 PM, tamouse mailing lists wrote: On Sun, Oct 14, 2012 at 10:48 AM, Jim Giner wrote: On 10/14/2012 1:10 AM, tamouse mailing lists wrote: This just dropped in my inbox the other day from Smashing #69: 2. PHP The Right Way If you are developing for the Web, the chances are high that you have to deal with PHP on a regular basis. However, once you've stumbled upon a problem that you have to solve, finding a good solution among thousands and thousands of (partly outdated) PHP tutorials out there can be quite a nightmare — especially if you are relatively new to PHP. Where would you go to learn about the current best practices in PHP? PHP The Right Way Perhaps PHP The Right Way. The site is an easy-to-read, quick reference for the best practices in PHP, accepted coding standards, and links to authoritative tutorials around the Web. Josh Lockhart has worked together with a dozen of well-respected members of the PHP community to create a useful, up-to-date resource for everybody to use. I've just been perusing it, and it offers some good advice. Anyone here work on it / read it? Thoughts? Sounds like a good idea, but as for me - if I was a newbie I'd have a problem with their very first instructions. It says right off the start to type in the following: php -5 localhost:8000 which when I do (from a dos prompt) gives me a nice description of the command, but fails to do anything else for me. So how does this (as it says) "help me learn with the hassle of configureing and installing a full-fledged web server"? Are you running 5.4+? First thing it says is "Use the current stable version (5.4)". The PHP server (-S) is not available in anything earlier. I'm not running anything. It says to type a command and I did. That's my point - it's kind of misleading in it's introduction. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP The Right Way (website)
On 10/14/2012 12:12 PM, Daniel Brown wrote: On Sun, Oct 14, 2012 at 11:48 AM, Jim Giner wrote: Sounds like a good idea, but as for me - if I was a newbie I'd have a problem with their very first instructions. It says right off the start to type in the following: php -5 localhost:8000 That should be a capital S, not a five. hmmm, that does make a difference. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] foreach
On 10/15/2012 8:39 PM, Jim Lucas wrote: On 10/15/2012 05:16 PM, David McGlone wrote: I've been sitting here playing around with foreach() and I'm wondering why I am getting these results. here's what I've been fooling around with. the code has no perticular meaning, but I noticed if the script fails, I get the sentence "Too expensive I'm going home LOL" 6 times because there are 6 words in the sentence. I also have a database that looks like this: product_idproductprice 1Milk2.59 2bread1.05 And when $row is equal to 0 the output I get is 1 1 Milk Milk 2.59 2.59 Which is printed to the screen according to how many rows are in the db I belive. So my question is why this behavior? I was expecting something like a while loop. Code please. You want code? IF it's anything like what he showed already, who cares? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Table help needed
On 10/20/2012 8:26 AM, Maciek Sokolewicz wrote: On 20-10-2012 07:52, tamouse mailing lists wrote: Surprised no one else has jumped on the "Don't use mysql anymore" thing here. Quick and dirty PDO implementation: https://gist.github.com/3922192 I'm actually more surprised that the OP hasn't even bothered to check the standard HTML syntax for and find out himself. If you don't know how to make a table with 3 columns, that indicates you have no clue how to make an HTML table in the first place. So my advice to the OP: go learn some HTML first, before acting as-if you were a PHP expert. - Tul exactly! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] cron job problem
I have a php script that has been triggered by my hoster's cron process(?) to run once a day since last March. It's been running fine - and I've made no changes to it. Suddenly in the last couple of days it is running twice it seems. The whole process sends an email at its conclusion and the receipient tells me today that she's getting two emails only a minute apart. Any ideas on why this might happen? I haven't contact my host company yet - thought I'd ask around first. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] cron job problem
On 10/23/2012 4:56 PM, Daniel Brown wrote: On Tue, Oct 23, 2012 at 4:48 PM, Jim Giner wrote: I have a php script that has been triggered by my hoster's cron process(?) to run once a day since last March. It's been running fine - and I've made no changes to it. Suddenly in the last couple of days it is running twice it seems. The whole process sends an email at its conclusion and the receipient tells me today that she's getting two emails only a minute apart. Any ideas on why this might happen? I haven't contact my host company yet - thought I'd ask around first. Though not really a PHP question, there are several reasons this could happen, including a race condition that is being encountered due to a slowdown of the host system or changes to the system's environment. Are the emails she's receiving identical? Yes - same msg same time -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] cron job problem
On 10/23/2012 6:18 PM, David OBrien wrote: On Tue, Oct 23, 2012 at 5:31 PM, Daniel Brown wrote: On Tue, Oct 23, 2012 at 5:34 PM, Ashley Sheridan wrote: Crontab is the daemon which runs cron jobs, and some distros have set up special files called cron.daily (or daily.cron I don't recall), cron.hourly, etc to make it easier to schedule jobs. Quick clarification and correction here: The cron *daemon* is crond, while the *script* that is batch-processed by cron is called the crontab. When it is executed, it is referred to as a cron job. That said, Ash is right about the rest. Different OS flavors (BSD, Linux, UNIX, SunOS/Solaris, HP-UX, et cetera) often use different path and file standards. Linux, in general, uses a command `crontab` which opens the local user's environment-configured editor to modify the user's crontab in the spool. -- Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php script runs ntp updates server time script runs again? But why now? This process has been running just fine for months. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] cron job problem
On 10/23/2012 6:57 PM, Ashley Sheridan wrote: On Tue, 2012-10-23 at 18:36 -0400, Jim Giner wrote: On 10/23/2012 6:18 PM, David OBrien wrote: On Tue, Oct 23, 2012 at 5:31 PM, Daniel Brown wrote: On Tue, Oct 23, 2012 at 5:34 PM, Ashley Sheridan wrote: Crontab is the daemon which runs cron jobs, and some distros have set up special files called cron.daily (or daily.cron I don't recall), cron.hourly, etc to make it easier to schedule jobs. Quick clarification and correction here: The cron *daemon* is crond, while the *script* that is batch-processed by cron is called the crontab. When it is executed, it is referred to as a cron job. That said, Ash is right about the rest. Different OS flavors (BSD, Linux, UNIX, SunOS/Solaris, HP-UX, et cetera) often use different path and file standards. Linux, in general, uses a command `crontab` which opens the local user's environment-configured editor to modify the user's crontab in the spool. -- Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php script runs ntp updates server time script runs again? But why now? This process has been running just fine for months. Have you tried removing the job entirely from cron and re-adding it? It might be enough to kick-start the process into behaving. Yes my host asked me to do that earlier. And nope - no better. I have told them it's gotta be something on their end because I tested the script from a browser displaying what it was doing and it ran fine. Removed my debug settings and ran it from a browser and again it ran fine. Re-scheduled the cron task and it ran wrong. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Date comparison going wrong, wrong, wrong
On 11/11/2012 1:30 PM, Terry Ally (Gmail) wrote: Hi all, I am having a problem with comparing time. I am using the following: $todaydate = date("D, M jS, Y g:i:s a"); $showenddate = date("D, M jS, Y g:i:s a", strtotime($showsRecord['end_date'])); if ($todaydate > $showenddate): echo "The date of the show has not yet arrived"; else: echo "The show has ended"; endif; The problem that I am encountering is that PHP is rendering the reverse of the equation. For example: If today's date is *11 Nov 2012* and the show's end date is *18 Nov 2012*, the message that I am getting is *the show has ended* which is wrong. A test example is at http://www.lakesidesurrey.co.uk/test.php. You can also me what I am doing wrong? Thanks Terry Besides the minor fact that the code has syntax errors, the problem with it is your if is backwrads. The facts are: today is less than end date, so your if should show "The show has ended" since you are asking if today IS GREATER than the end date. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Date comparison going wrong, wrong, wrong
BTW - this is the code I used to test out your process: $showenddate) echo "The date of the show has not yet arrived"; else echo "The show has ended"; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Switch - Case Statement Questions
On 11/16/2012 12:38 PM, Tim Streater wrote: On 16 Nov 2012 at 12:10, Omar Muhsin wrote: Hello, I was just wondering after writting the code in version 2 here below, it turns out in testing that it actually PHP is not validating the expressions instead always I get the first case. 1.Using nested if statement {THE INTENDED BEHAVIOR}: if ($count > 14) $boxes = 3; elseif($count > 7 && $count <= 14) You don't need the count<=14 part as you will *only* get there if $count<=14. $boxes = 2; else $boxes = 1; 2. Using Switch {ALWAYS FIRST CASE!!!} //$boxes = 1; //switch ($count) { //case ($count > 14): //$boxes = 3; //break; //case ($count > 7 && $count <= 14): //$boxes = 2; //break; //case ($count <= 7): //default : //$boxes = 1; //break; //} Does anyone know the answer why using the Switch it always execute the first case ? As has been pointed out you need switch(true). That's a strange way of writing a switch, IMO. You should be using the if version. -- Cheers -- Tim Maybe I'm way out of touch, but when I look at php.net for the syntax of the switch statement I see: switch($var){ case (value): (do something) case (other value): (do something else) } IN your example, you are using a switch syntax that is nothing like that. I think that your "case " statements are not actually evaluating the value of $count, but are themselves evaluating to a true value that has nothing to do with $count. Here's the manual reference: http://us.php.net/manual/en/control-structures.switch.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Switch - Case Statement Questions
On 11/16/2012 8:33 PM, Iñigo Medina wrote: On Fri, 16 Nov 2012, Jim Giner wrote: On 11/16/2012 12:38 PM, Tim Streater wrote: On 16 Nov 2012 at 12:10, Omar Muhsin wrote: Hello, I was just wondering after writting the code in version 2 here below, it turns out in testing that it actually PHP is not validating the expressions instead always I get the first case. 1.Using nested if statement {THE INTENDED BEHAVIOR}: if ($count > 14) $boxes = 3; elseif($count > 7 && $count <= 14) You don't need the count<=14 part as you will *only* get there if $count<=14. $boxes = 2; else $boxes = 1; 2. Using Switch {ALWAYS FIRST CASE!!!} //$boxes = 1; //switch ($count) { //case ($count > 14): //$boxes = 3; //break; //case ($count > 7 && $count <= 14): //$boxes = 2; //break; //case ($count <= 7): //default : //$boxes = 1; //break; //} Does anyone know the answer why using the Switch it always execute the first case ? As has been pointed out you need switch(true). That's a strange way of writing a switch, IMO. You should be using the if version. -- Cheers -- Tim Maybe I'm way out of touch, but when I look at php.net for the syntax of the switch statement I see: switch($var){ case (value): (do something) case (other value): (do something else) } IN your example, you are using a switch syntax that is nothing like that. I think that your "case " statements are not actually evaluating the value of $count, but are themselves evaluating to a true value that has nothing to do with $count. That `switch` is evaluating to true each case. It's an alternative of using if-elseif structure. iñ Here's the manual reference: http://us.php.net/manual/en/control-structures.switch.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php My point was that the OP is using a widely different syntax for a Switch statement, one that I don't understand at all. According to the Manual his statement should be: >>>> //switch ($count) { >>>> //case (> 14): >>>> //$boxes = 3; >>>> //break; >>>> //case (> 7): >>>> //$boxes = 2; >>>> //break; >>>> //default : >>>> //$boxes = 1; >>>> //break; >>>> //} To answer Iñigo's comment - the OP's version is very much like an If-ElseIF structure, and nothing like a Switch. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PDO question
On 11/28/2012 3:58 PM, ad...@buskirkgraphics.com wrote: Guys, I am not quiet sure what is happening but every time i try to connect to a remote host it refers back to localhost. $pdo = new PDO('mysql:host=171.16.23.44;dbname=test', 'user','password'); ERROR: Access denied for user 'user'@'localhost' (using password: YES) in /var/www/html/text.php Any clue as to WHY it keeps referring back to localhost when i clearly set the host parameter to another server. I checked the /etc/hosts records to see if there was a referral for that domain back to it's self there is NOT. Just a WAG from a guy who's never tried to do this. Could the localhost in question actually be the server you are failing to connect to, and not your client machine? You are sure about your uid/pswd? dbname? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PDO question
On 11/28/2012 4:18 PM, ad...@buskirkgraphics.com wrote: On November 28, 2012 at 4:11 PM Jim Giner wrote: On 11/28/2012 3:58 PM, ad...@buskirkgraphics.com wrote: Guys, I am not quiet sure what is happening but every time i try to connect to a remote host it refers back to localhost. $pdo = new PDO('mysql:host=171.16.23.44;dbname=test', 'user','password'); ERROR: Access denied for user 'user'@'localhost' (using password: YES) in /var/www/html/text.php Any clue as to WHY it keeps referring back to localhost when i clearly set the host parameter to another server. I checked the /etc/hosts records to see if there was a referral for that domain back to it's self there is NOT. Just a WAG from a guy who's never tried to do this. Could the localhost in question actually be the server you are failing to connect to, and not your client machine? You are sure about your uid/pswd? dbname? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I actually do not allow the user in the connection string to connect locally which makes me think it is not accepting the host parameter and defaulting to the localhost. I would expect this if connecting localhost but the IP is not the local host IP. My question is WHY is it changing the host parameter? Like I said just a WAG, but are you sure about my other questions? My point is perhaps the error message itself is a little confusing and the response from the sql server is using the term localhost to refer to itself, but that message is getting passed back to your server and then to you, causing perhaps(?) some confusion. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PDO question
On 11/28/2012 4:22 PM, ad...@buskirkgraphics.com wrote: On November 28, 2012 at 4:11 PM Jim Giner wrote: On 11/28/2012 3:58 PM, ad...@buskirkgraphics.com wrote: Guys, I am not quiet sure what is happening but every time i try to connect to a remote host it refers back to localhost. $pdo = new PDO('mysql:host=171.16.23.44;dbname=test', 'user','password'); ERROR: Access denied for user 'user'@'localhost' (using password: YES) in /var/www/html/text.php Any clue as to WHY it keeps referring back to localhost when i clearly set the host parameter to another server. I checked the /etc/hosts records to see if there was a referral for that domain back to it's self there is NOT. Just a WAG from a guy who's never tried to do this. Could the localhost in question actually be the server you are failing to connect to, and not your client machine? You are sure about your uid/pswd? dbname? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php In reading your question again, I get what you are saying. Let me explain. It is not actually saying 'localhost' it is saying 'server1.mydomain.com' of the server I am connecting from. not the server2.mydomain.com. I have ensured the path is correct, PING, NSLOOKUP from the server trying to make the connection. It changes the domain would have been nice if you had specified the message exactly the first time. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session ?
Something new for me - working with scripts on two of my sub-domains. I want to call script 2 in my B domain from script 1 in my A domain. It appears that the session vars established in script 1 do not show up in script 2. Is that because the domain name is different? Is this where one must grab the session id and use it in another script in order to retain the original session and its vars? If this is so, can someone elaborate on the capture of the session id process? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session ?
On 12/7/2012 2:36 PM, Daniel Brown wrote: On Fri, Dec 7, 2012 at 2:33 PM, Jim Giner wrote: Something new for me - working with scripts on two of my sub-domains. I want to call script 2 in my B domain from script 1 in my A domain. It appears that the session vars established in script 1 do not show up in script 2. Is that because the domain name is different? Is this where one must grab the session id and use it in another script in order to retain the original session and its vars? If this is so, can someone elaborate on the capture of the session id process? Are both domains on the same physical (or virtual) server? Yes - they are sub-domains of my main one. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session ?
On 12/7/2012 2:41 PM, Daniel Brown wrote: On Fri, Dec 7, 2012 at 2:38 PM, Jim Giner wrote: On 12/7/2012 2:36 PM, Daniel Brown wrote: On Fri, Dec 7, 2012 at 2:33 PM, Jim Giner wrote: Something new for me - working with scripts on two of my sub-domains. I want to call script 2 in my B domain from script 1 in my A domain. It appears that the session vars established in script 1 do not show up in script 2. Is that because the domain name is different? Is this where one must grab the session id and use it in another script in order to retain the original session and its vars? If this is so, can someone elaborate on the capture of the session id process? Are both domains on the same physical (or virtual) server? Yes - they are sub-domains of my main one. The preceding dot before the SLD allow the session cookie to be accessible on *.example.com. What if my sub-domain names are not in the form of 'a.domain.com' and 'b.domain.com'. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session ?
On 12/7/2012 2:58 PM, Sebastian Krebs wrote: 2012/12/7 Jim Giner On 12/7/2012 2:41 PM, Daniel Brown wrote: On Fri, Dec 7, 2012 at 2:38 PM, Jim Giner wrote: On 12/7/2012 2:36 PM, Daniel Brown wrote: On Fri, Dec 7, 2012 at 2:33 PM, Jim Giner wrote: Something new for me - working with scripts on two of my sub-domains. I want to call script 2 in my B domain from script 1 in my A domain. It appears that the session vars established in script 1 do not show up in script 2. Is that because the domain name is different? Is this where one must grab the session id and use it in another script in order to retain the original session and its vars? If this is so, can someone elaborate on the capture of the session id process? Are both domains on the same physical (or virtual) server? Yes - they are sub-domains of my main one. The preceding dot before the SLD allow the session cookie to be accessible on *.example.com. What if my sub-domain names are not in the form of 'a.domain.com' and ' b.domain.com'. What do you mean? Subdomains are always in the form "*.example.com" -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php My bad - I was referencing the "add-on domain" name which is not. Yes - there are subs in the correct format which I forgot about. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session ?
On 12/7/2012 2:59 PM, Daniel Brown wrote: On Fri, Dec 7, 2012 at 2:54 PM, Jim Giner wrote: What if my sub-domain names are not in the form of 'a.domain.com' and 'b.domain.com'. A subdomain is a subdomain. Unless you've discovered a new magical form of subdomain that is not, you should be fine. And if you have, in fact, made that discovery, you're probably the reason the Mayans predicted a very short winter this year. Thanks for screwing us, Jim. OK - now that I've messed us all up, help me to understand your proposed solution. I added the ini-set line to my first script. Then I called my second one and still had the same problem with a missing session var. Is there a corresponding line I need in the 'called' script? And does it matter where this line is place within the script? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session ?
So i need the ini set in both scripts. Thx. Ill try that later jg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session ?
On 12/7/2012 3:20 PM, Sebastian Krebs wrote: 2012/12/7 Daniel Brown On Fri, Dec 7, 2012 at 3:04 PM, Jim Giner wrote: OK - now that I've messed us all up, help me to understand your proposed solution. I added the ini-set line to my first script. Then I called my second one and still had the same problem with a missing session var. Is there a corresponding line I need in the 'called' script? And does it matter where this line is place within the script? From your response to Sebastian, I'm not sure it will work. They need to be subdomains of the same domain; different domains won't work. However, proceeding with the presumption that the subdomains are under the same SLD (e.g. - apple.example.com and orange.example.com), this should work: Then Would be better to put 'session.cookie_domain' into the php.ini. In both cases: Clear cookies (at least for your site) completely and set session.auto_start to 0. -- Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php What does doing session.auto_start to 0 do to me? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php