Re: [PHP] To ? or not to ?
On 4/4/12 12:14 AM, Donovan Brooke wrote: Robert Cummings wrote: [snip] Could using ob_start and ob_end_flush eliminate the ambiguity of whether or not to use '?'? In the generally recommended case of don't use them at the end of your file... where's the ambiguity? http://www.php.net/manual/en/function.include.php http://www.php.net/manual/en/language.basic-syntax.phpmode.php Those seem to suggest to use them... thus the ambiguity. Donovan Most major projects at this point leave it off, and their coding standards say to as well. The official PHP docs are generally non-commital by design, but outside of those I think it's pretty well-established to just leave it off and be happy. --Larry Garfield -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] To ? or not to ?
Larry Garfield wrote: [snip] Donovan Most major projects at this point leave it off, and their coding standards say to as well. The official PHP docs are generally non-commital by design, but outside of those I think it's pretty well-established to just leave it off and be happy. --Larry Garfield Well, the preference doesn't really matter to me... my point of question was the use of ob_start, etc.. The books I've read in PHP also call for ending '?', so it's being taught to PHP'ers whether the php list and major projects likes it or not. I was wondering about the lists opinion on the use of ob_start, ob_end_flush regarding this topic. Donovan -- D Brooke -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] learning resources for PHP
On Wed, Apr 4, 2012 at 6:16 AM, Bastien phps...@gmail.com wrote: Bastien Koert On 2012-04-03, at 10:39 PM, Tim Dunphy bluethu...@gmail.com wrote: Hello list, I am quite sure that you've heard this question at least a few times before. :) But I have been dabbling a bit in PHP for years and I've decided that its' high time that became serious about getting a solid grounding in it. Currently I work as a Sysadmin and have modest but reliable skills in bash and perl. But I consider PHP more of an artform and I really need to 'pick up a brush and start painting' so to speak. So what I was wondering what websites, and books you'd recommend to someone who (for all intents and purpose) is just starting out. On my hit list of things to learn are basic php / database interaction (mysql mainly).. then how to accelerate php interraction through memcache.. and eventually one I have all that down onto using some of the NoSQLs (mongo/cassandra/membase, etc). Thanks! -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php The manual is a great place Www.php.net Then there are tons of sites forum and otherwise to aid your learning. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I'll second the manual -- quite a lot of info, and generally very well written. When I started out learning PHP, I used the tutorials at webmonkey.com. They're pretty well done, and definitely got me going quickly. If you already have programming experience, and understand data bases a bit, they should help you along. If you have no programming or data base experience, PHP isn't necessarily a bad first language, but it is very rich, and there are many ways to make mistakes and create poorly formed programs. Writing web apps is quite a bit different than writing admin scripts in shell and perl, and there are various ways to go about it. While the php.net manual is extensive in describing the workings and functions of PHP, it is not a programming tutorial by any stretch. Way back in the Jurassic of programming, I had a nifty little book called Programming Proverbs that laid out quite succinctly some rules of thumb for writing good code. Today, books like Code Complete serve that purpose well, but with a lot more text and no where near as much fun. Still, if you're are a beginner to writing applications, it's good to look at such books. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] foreach
Dear Lists - I know I am missing something fundamental - but I have no idea where to start to look. Here are code snippets: I have truncated the allowed_fields to make it easier to debug. $allowed_fields = array( 'Site' ='POST[Site]', 'MedRec' = '$_POST[MedRec]', 'Fname' = '$_POST[Fname]' ); echo post #1\n; print_r($_POST); RESPONSE: post #1 Array ( [Site] = AA [MedRec] = 10002 [Fname] = [Lname] = [Phone] = [Height] = [welcome_already_seen] = already_seen [next_step] = step10 ) // $allowed_fields = array(Site, MedRec, Fname, Lname, // previous statement of $allowed_fields // Phone, Sex, Height); Key Site, Value POST[Site] Key MedRec, Value $_POST[MedRec] Key Fname, Value $_POST[Fname] foreach ($allowed_fields as $key = $val) { print Key $key, Value $val\n; } if(isset($_Request['Sex']) trim($_POST['Sex']) != '' ) { if ($_REQUEST['Sex'] === 0) { $sex = 'Male'; } else { $sex = 'Female'; } } } echo Post#2; print_r($_POST); if(empty($allowed_fields)) //RESPONSE Post#2Array ( [Site] = AA [MedRec] = 10002 [Fname] = [Lname] = [Phone] = [Height] = [welcome_already_seen] = already_seen [next_step] = step10 ) { echo ouch; } foreach ( $allowed_fields as $key = $val ) //This is line 198 { if ( ! empty( $_POST['val'] ) ) { print Key $key, Value $val\n; $cxn = mysqli_connect($host,$user,$password,$db); $value = mysql_real_escape_string( $_POST[$fld] ); $query .= AND $fld = '$_POST[value]' ; echo #1 $query; //never echos the query } } These are the messages I receive on execution of the script: Notice: Undefined variable: allowed_fields in /var/www/srchrhsptl5.php on line 198 Warning: Invalid argument supplied for foreach() in /var/www/srchrhsptl5.php on line 198 Advice and help, please. Thank you. Ethan Rosenberg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: foreach
I don't know about others, but I can't make sense of this - way too much presented with no idea of what I am looking at - code or output. One thing: $_Request is not the same var as $_REQUEST. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PHP-DB] Re: foreach
And POST[] is not the same as $_POST[] Karl Sent from losPhone On Apr 5, 2012, at 3:24 PM, Jim Giner jim.gi...@albanyhandball.com wrote: I don't know about others, but I can't make sense of this - way too much presented with no idea of what I am looking at - code or output. One thing: $_Request is not the same var as $_REQUEST. -- PHP Database 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: foreach
On 4/5/2012 4:15 PM, Ethan Rosenberg wrote: Dear Lists - I know I am missing something fundamental - but I have no idea where to start to look. Here are code snippets: I have truncated the allowed_fields to make it easier to debug. $allowed_fields = array( 'Site' ='POST[Site]', 'MedRec' = '$_POST[MedRec]', 'Fname' = '$_POST[Fname]' ); echo post #1\n; print_r($_POST); RESPONSE: post #1 Array ( [Site] = AA [MedRec] = 10002 [Fname] = [Lname] = [Phone] = [Height] = [welcome_already_seen] = already_seen [next_step] = step10 ) // $allowed_fields = array(Site, MedRec, Fname, Lname, // previous statement of $allowed_fields // Phone, Sex, Height); Key Site, Value POST[Site] Key MedRec, Value $_POST[MedRec] Key Fname, Value $_POST[Fname] foreach ($allowed_fields as $key = $val) { print Key $key, Value $val\n; } if(isset($_Request['Sex']) trim($_POST['Sex']) != '' ) { if ($_REQUEST['Sex'] === 0) { $sex = 'Male'; } else { $sex = 'Female'; } } } echo Post#2; print_r($_POST); if(empty($allowed_fields)) //RESPONSE Post#2Array ( [Site] = AA [MedRec] = 10002 [Fname] = [Lname] = [Phone] = [Height] = [welcome_already_seen] = already_seen [next_step] = step10 ) { echo ouch; } foreach ( $allowed_fields as $key = $val ) //This is line 198 { if ( ! empty( $_POST['val'] ) ) { print Key $key, Value $val\n; $cxn = mysqli_connect($host,$user,$password,$db); $value = mysql_real_escape_string( $_POST[$fld] ); $query .= AND $fld = '$_POST[value]' ; echo #1 $query; //never echos the query } } These are the messages I receive on execution of the script: Notice: Undefined variable: allowed_fields in /var/www/srchrhsptl5.php on line 198 Warning: Invalid argument supplied for foreach() in /var/www/srchrhsptl5.php on line 198 Advice and help, please. Thank you. Ethan Rosenberg Break down you code into workable segments and test each one individually. If you have a problem with a small segment, ask for help about it specifically. Folks don't have time to digest and critique your whole code. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PHP-DB] Re: foreach
Send the code around line 198, say 170 to 210. On Apr 5, 2012, at 8:42 PM, Al wrote: On 4/5/2012 4:15 PM, Ethan Rosenberg wrote: Dear Lists - I know I am missing something fundamental - but I have no idea where to start to look. Here are code snippets: I have truncated the allowed_fields to make it easier to debug. $allowed_fields = array( 'Site' ='POST[Site]', 'MedRec' = '$_POST[MedRec]', 'Fname' = '$_POST[Fname]' ); echo post #1\n; print_r($_POST); RESPONSE: post #1 Array ( [Site] = AA [MedRec] = 10002 [Fname] = [Lname] = [Phone] = [Height] = [welcome_already_seen] = already_seen [next_step] = step10 ) // $allowed_fields = array(Site, MedRec, Fname, Lname, // previous statement of $allowed_fields // Phone, Sex, Height); Key Site, Value POST[Site] Key MedRec, Value $_POST[MedRec] Key Fname, Value $_POST[Fname] foreach ($allowed_fields as $key = $val) { print Key $key, Value $val\n; } if(isset($_Request['Sex']) trim($_POST['Sex']) != '' ) { if ($_REQUEST['Sex'] === 0) { $sex = 'Male'; } else { $sex = 'Female'; } } } echo Post#2; print_r($_POST); if(empty($allowed_fields)) //RESPONSE Post#2Array ( [Site] = AA [MedRec] = 10002 [Fname] = [Lname] = [Phone] = [Height] = [welcome_already_seen] = already_seen [next_step] = step10 ) { echo ouch; } foreach ( $allowed_fields as $key = $val ) //This is line 198 { if ( ! empty( $_POST['val'] ) ) { print Key $key, Value $val\n; $cxn = mysqli_connect($host,$user,$password,$db); $value = mysql_real_escape_string( $_POST[$fld] ); $query .= AND $fld = '$_POST[value]' ; echo #1 $query; //never echos the query } } These are the messages I receive on execution of the script: Notice: Undefined variable: allowed_fields in /var/www/srchrhsptl5.php on line 198 Warning: Invalid argument supplied for foreach() in /var/www/srchrhsptl5.php on line 198 Advice and help, please. Thank you. Ethan Rosenberg Break down you code into workable segments and test each one individually. If you have a problem with a small segment, ask for help about it specifically. Folks don't have time to digest and critique your whole code. -- PHP Database 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] image inventoryer
I need a page that will live in a directory and list all image files in there. That is, the page has img src=./foo.typeP tags emitted in it's structure, one per file in the directory with a saught file type- .png, .gif, .jpg, you get the idea. this should use relative addressing so once the tool is built I can use it in other directories as is. Now ai am still a novice at p[hp, how can I do this ? -- end Very Truly yours, - Kirk Bailey, Largo Florida kniht +-+ | BOX | +-+ think -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image inventoryer
On Thu, Apr 5, 2012 at 7:26 PM, Kirk Bailey kbai...@howlermonkey.net wrote: Now ai am still a novice at p[hp, how can I do this ? Have you read any book on PHP? even the official from PHP.net? Learn the tool so you know how to use it, efficiently. Otherwise how do you know if the tool can do what you want... What you're asking for ATM is someone to write the code for you which is not how it works. You need to provide some code, or even pseudo code at least... HTH, Tommy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image inventoryer
As Tommy says - you sound like a total new user who doesn't know how to do it and furthermore doesn't know how many things you are going to have to pick up just to accomplish this task. You have to: determine the folder your script is running from collect an array of image file names from that directory determine the size of each of these images so that you are not building some html that will try to display an unmanageable amount of data all at once. You may then have to learn how to create smaller images for your img tags, which is another learning process in itself determine how many images you will display and decide again if you really can allow the user to make this kind of request. This could also create another step in the process to keep track of what images have already been displayed so that when the screen comes back to your script you can pick up where you left off and display a second page. THEN you can generate the html to produce a useful page of images. At least that's how I would approach it. And I'm not an expert but simply a guy who has put in about a year's worth of effort into learning enough php to actually do something like this already, among other things. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image inventoryer
ok. ?php filelist=inventory all files in directory ./ for file in filelist: // walk a listing of many items IF filetype in gif, jpg, png { echo 'img src=./'.file.'P' // notice that is a 'singlequote' immedately followed by a doublequote. ? Something like this. In python I would write something like: #!/usr/bin/python import string, glob files=glob.glob(./*.*) # files is a list variable (a 1 dimensional addressable array) for file in files: # for each cell in files do this doblock: if str.split(file,'.')[1] in gif,jpg,png): #if the file type is in a list of acceptable types, print 'img src=./'+file+'P'# print out the material to return surrounding # the file name On 4/5/2012 10:34 PM, Tommy Pham wrote: On Thu, Apr 5, 2012 at 7:26 PM, Kirk Baileykbai...@howlermonkey.net wrote: Now ai am still a novice at p[hp, how can I do this ? Have you read any book on PHP? even the official from PHP.net? Learn the tool so you know how to use it, efficiently. Otherwise how do you know if the tool can do what you want... What you're asking for ATM is someone to write the code for you which is not how it works. You need to provide some code, or even pseudo code at least... HTH, Tommy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image inventoryer
jim, I am a novice at this language as I said. On 4/5/2012 10:44 PM, Jim Giner wrote: As Tommy says - you sound like a total new user who doesn't know how to do it and furthermore doesn't know how many things you are going to have to pick up just to accomplish this task. You have to: determine the folder your script is running from collect an array of image file names from that directory determine the size of each of these images so that you are not building some html that will try to display an unmanageable amount of data all at once. You may then have to learn how to create smaller images for your img tags, which is another learning process in itself determine how many images you will display and decide again if you really can allow the user to make this kind of request. This could also create another step in the process to keep track of what images have already been displayed so that when the screen comes back to your script you can pick up where you left off and display a second page. THEN you can generate the html to produce a useful page of images. At least that's how I would approach it. And I'm not an expert but simply a guy who has put in about a year's worth of effort into learning enough php to actually do something like this already, among other things. And were people this nice to you when YOU asked beginner questions? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image inventoryer
On Thu, Apr 5, 2012 at 8:02 PM, Kirk Bailey kbai...@howlermonkey.net wrote: If you don't want to read the manual or a book, you could quickly do some Google'ing as below: ok. ?php filelist=inventory all files in directory ./ filesystem site:php.net for file in filelist: // walk a listing of many items loop site:php.net IF filetype in gif, jpg, png { condition site:php.net echo 'img src=./'.file.'P' // notice that is a 'singlequote' immedately followed by a doublequote. ? Or just look at the table of contents in the official manual to see what PHP has to offer and see what you can do since you already have some programming experience. Something like this. In python I would write something like: #!/usr/bin/python import string, glob files=glob.glob(./*.*) # files is a list variable (a 1 dimensional addressable array) for file in files: # for each cell in files do this doblock: if str.split(file,'.')[1] in gif,jpg,png): #if the file type is in a list of acceptable types, print 'img src=./'+file+'P' # print out the material to return surrounding # the file name On 4/5/2012 10:34 PM, Tommy Pham wrote: On Thu, Apr 5, 2012 at 7:26 PM, Kirk Baileykbai...@howlermonkey.net wrote: Now ai am still a novice at p[hp, how can I do this ? Have you read any book on PHP? even the official from PHP.net? Learn the tool so you know how to use it, efficiently. Otherwise how do you know if the tool can do what you want... What you're asking for ATM is someone to write the code for you which is not how it works. You need to provide some code, or even pseudo code at least... HTH, Tommy PS: don't top post since it's preferred on this list. You can search the archive for the discussion about it. HTH, Tommy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php