php-general Digest 9 Sep 2006 19:12:49 -0000 Issue 4338
php-general Digest 9 Sep 2006 19:12:49 - Issue 4338 Topics (messages 241523 through 241544): Re: Using a variable to call another variable 241523 by: tedd 241529 by: Christopher Weldon 241533 by: Robert Cummings Newbie question about ?= ? 241524 by: Mike Borrelli 241525 by: Dave Goodchild 241526 by: Christopher Weldon 241527 by: Satyam 241528 by: Satyam Re: if statement with or comparison (newbie) 241530 by: Mark Charette 241532 by: Stut 241534 by: Robert Cummings 241535 by: Mark Charette 241537 by: Robert Cummings 241539 by: Mark Charette 241541 by: Stut 241542 by: Robert Cummings 241543 by: Robert Cummings loop structure 241531 by: Reinhart Viane 241536 by: Robert Cummings Re: PHP Access Violations 241538 by: Christopher Watson 241544 by: Jürgen Wind Re: loop structure(SOLVED) 241540 by: Reinhart Viane Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: php-general@lists.php.net -- ---BeginMessage--- At 12:10 AM -0400 9/9/06, Robert Cummings wrote: On Sat, 2006-09-09 at 12:57 +0900, Dave M G wrote: PHP List, I have a list of variables: $001 $002 $003 $004 And what I'd like to do is have a function which will select and return one of them. Something like: public function returnVar($n) { return $(somehow n is made to reference the name of the variable); } And then in later scripts I can call anyone of the variables by saying returnVar(001) Or something like that. I've been scratching my head on how to do this for a while. I thought the answer might lie somewhere in call_user_func(), but even if it is I can't determine how. Any advice would be much appreciated. ?php function easy_peasy( $name ) { $foo1 = 1; $foo2 = 2; $foo3 = 3; return $$name; } echo easy_peasy( 'foo2' ).\n; ? Cheers, Rob. Or something like that. :-) $easy_peasyier = array(foo1 = 1, foo2 = 2, foo3 = 3); echo($easy_peasyier['foo1']); tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com ---End Message--- ---BeginMessage--- -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 tedd wrote: At 12:10 AM -0400 9/9/06, Robert Cummings wrote: On Sat, 2006-09-09 at 12:57 +0900, Dave M G wrote: PHP List, I have a list of variables: $001 $002 $003 $004 And what I'd like to do is have a function which will select and return one of them. Something like: public function returnVar($n) { return $(somehow n is made to reference the name of the variable); } And then in later scripts I can call anyone of the variables by saying returnVar(001) Or something like that. I've been scratching my head on how to do this for a while. I thought the answer might lie somewhere in call_user_func(), but even if it is I can't determine how. Any advice would be much appreciated. ?php function easy_peasy( $name ) { $foo1 = 1; $foo2 = 2; $foo3 = 3; return $$name; } echo easy_peasy( 'foo2' ).\n; ? Cheers, Rob. Or something like that. :-) $easy_peasyier = array(foo1 = 1, foo2 = 2, foo3 = 3); echo($easy_peasyier['foo1']); tedd class myClass { private var $_001; private var $_002; private var $_003; public function access_var($var) { return $this-$$var; } } $cs = new myClass; $cs-access_var('_001'); // Done BTW, please make certain that you aren't really naming your variables as $001, $002 and $003. Those are bad variable names, as PHP only allows for variables beginning with letters and '_' characters (what I did above). - -- Christopher Weldon, ZCE President CEO Cerberus Interactive, Inc. [EMAIL PROTECTED] 979.739.5874 -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFAsfXZxvk7JEXkbERAiYkAJ9misO/pDJYEpJM3iPFF5T3GVdKGwCgpwFB ae17qOdSZL2DJj+VA6rUqDc= =dRAJ -END PGP SIGNATURE- ---End Message--- ---BeginMessage--- On Sat, 2006-09-09 at 08:44 -0400, tedd wrote: At 12:10 AM -0400 9/9/06, Robert Cummings wrote: On Sat, 2006-09-09 at 12:57 +0900, Dave M G wrote: PHP List, I have a list of variables: $001 $002 $003 $004 And what I'd like to do is have a function which will select and return one of them. Something like: public function returnVar($n) { return $(somehow n is made to reference the name of the variable); } And then in later scripts I can call anyone of the variables by saying returnVar(001) Or something like that. I've been scratching my head on how to do this for a while. I
Re: [PHP] if statement with or comparison (newbie)
No, just try it. Since the returned value cannot have to values at once, whatever it comes it will succeed either one or both and being joined by an or, any single one that succeeds make the whole succeed. Just try it: Returned valueresult redtrue or true = true blackfalse or true = true whitetrue or false = true That is why in my e-mail I insisted that the best thing you can do with complex booleans is try to straighten the logic and avoid too many negations, which tend to turn the logic upside down. Satyam - Original Message - From: Kevin Murphy [EMAIL PROTECTED] To: php php-general@lists.php.net Cc: JD [EMAIL PROTECTED] Sent: Friday, September 08, 2006 11:25 PM Subject: Re: [PHP] if statement with or comparison (newbie) Shouldn't that be this instead: if (($_REQUEST['id'] != black) OR ($_REQUEST['id'] != white)) { echo wrong color; } else { echo right color; } -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada Community College www.wncc.edu 775-445-3326 On Sep 8, 2006, at 2:28 PM, Prathaban Mookiah wrote: Let me rephrase it. Your color should be black or white to be the right colour. Is this correct? In that case you should change it to if ($_REQUEST['id'] != black AND $_REQUEST['id'] != white) { echo wrong color; } else ( echo right color; } - Original Message - From: JD [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Friday, September 08, 2006 5:03 PM Subject: [PHP] if statement with or comparison (newbie) I'm trying to set up a simple conditional, something like this: If my_variable is NOT equal to (black or white) echo wrong color else echo right color Here is what I have tried: if ($_REQUEST['id'] != (black or white)) { echo wrong color; } else ( echo right color; ) However, no matter what I enter, I always get response right color. I should add that if I change the if statement to: if ($_REQUEST['id'] != (black)) then I get right color when I enter black and wrong color for everything else. Would you please point out what's the trivial thing I'm missing here... jd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using a variable to call another variable
At 12:10 AM -0400 9/9/06, Robert Cummings wrote: On Sat, 2006-09-09 at 12:57 +0900, Dave M G wrote: PHP List, I have a list of variables: $001 $002 $003 $004 And what I'd like to do is have a function which will select and return one of them. Something like: public function returnVar($n) { return $(somehow n is made to reference the name of the variable); } And then in later scripts I can call anyone of the variables by saying returnVar(001) Or something like that. I've been scratching my head on how to do this for a while. I thought the answer might lie somewhere in call_user_func(), but even if it is I can't determine how. Any advice would be much appreciated. ?php function easy_peasy( $name ) { $foo1 = 1; $foo2 = 2; $foo3 = 3; return $$name; } echo easy_peasy( 'foo2' ).\n; ? Cheers, Rob. Or something like that. :-) $easy_peasyier = array(foo1 = 1, foo2 = 2, foo3 = 3); echo($easy_peasyier['foo1']); tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Newbie question about ?= ?
Good day, While I've been using php for more than a little while now, I've never understood why the use of the ?= ...? short tag is noted to be avoided. Or rather, I understand that there's an option to disable it, and that's why it's noted in this way, but I don't understand why it's disabled? What's gained by writing ?php echo some_function(); ? over ?= some_function(); ? Thanks in advance. Cheers, Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question about ?= ?
To be gained: less typing To be lost: short_open_tag may be disabled in some environments, making your code less portable. If you are only ever going to run your code in one environment and can enable short_open_tag (or if it is already on), there's no issue. -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
Re: [PHP] Newbie question about ?= ?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Mike Borrelli wrote: Good day, While I've been using php for more than a little while now, I've never understood why the use of the ?= ...? short tag is noted to be avoided. Or rather, I understand that there's an option to disable it, and that's why it's noted in this way, but I don't understand why it's disabled? What's gained by writing ?php echo some_function(); ? over ?= some_function(); ? Thanks in advance. Cheers, Mike - From my understanding, there are multiple reasons. One is that depending on where your application is being hosted, the server it is on may have turned off the short tags option (and you can't get your hosting provider to change this). Thus, ?= ...? would simply be written to the page as that. Additionally, through some of my training courses, another reason behind it is that if you use PHP to generate any XML documents, XML uses ? ? syntax, and it's better to turn off the short tags in your PHP config so that PHP doesn't attempt to interpret those tags as PHP code. - -- Christopher Weldon President, Lead Systems Administrator Cerberus Interactive, Inc. [EMAIL PROTECTED] 979.739.5874 -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFAsRnZxvk7JEXkbERAiW+AJ9POOf3U1K6TiRVhSFC6ok7VjDm2ACfel8U /6gFKYPPFYa5iyEtWdksZ0w= =C1fK -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question about ?= ?
All forms of short tags make your php file not XML compliant. Notice that the ?php tag which starts every script is a valid XML construct, it is what is called a Processing Instruction (PI) and admits within it absolutely anything except for a ? which ends the PI. A PI you will be familiar with is the ?xml PI. XML expects something to identify who is to process that PI, thus, there can be no 'anonymous' PI such as a plain ?. Actually, I have heard that it is possible (and have been done) to use more than one interpreter at once on the same document, using the proper processing tags for each language. How you configure that, don't ask me, I wouldn't know. Any short tag then, whether a ? or a ?=, is not valid XML. Whether that is important or not, I can't tell, but it is the only reason I know why short tags might be considered inapropriate and disabled. Satyam - Original Message - From: Mike Borrelli [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Saturday, September 09, 2006 3:19 PM Subject: [PHP] Newbie question about ?= ? Good day, While I've been using php for more than a little while now, I've never understood why the use of the ?= ...? short tag is noted to be avoided. Or rather, I understand that there's an option to disable it, and that's why it's noted in this way, but I don't understand why it's disabled? What's gained by writing ?php echo some_function(); ? over ?= some_function(); ? Thanks in advance. Cheers, Mike -- 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] Using a variable to call another variable
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 tedd wrote: At 12:10 AM -0400 9/9/06, Robert Cummings wrote: On Sat, 2006-09-09 at 12:57 +0900, Dave M G wrote: PHP List, I have a list of variables: $001 $002 $003 $004 And what I'd like to do is have a function which will select and return one of them. Something like: public function returnVar($n) { return $(somehow n is made to reference the name of the variable); } And then in later scripts I can call anyone of the variables by saying returnVar(001) Or something like that. I've been scratching my head on how to do this for a while. I thought the answer might lie somewhere in call_user_func(), but even if it is I can't determine how. Any advice would be much appreciated. ?php function easy_peasy( $name ) { $foo1 = 1; $foo2 = 2; $foo3 = 3; return $$name; } echo easy_peasy( 'foo2' ).\n; ? Cheers, Rob. Or something like that. :-) $easy_peasyier = array(foo1 = 1, foo2 = 2, foo3 = 3); echo($easy_peasyier['foo1']); tedd class myClass { private var $_001; private var $_002; private var $_003; public function access_var($var) { return $this-$$var; } } $cs = new myClass; $cs-access_var('_001'); // Done BTW, please make certain that you aren't really naming your variables as $001, $002 and $003. Those are bad variable names, as PHP only allows for variables beginning with letters and '_' characters (what I did above). - -- Christopher Weldon, ZCE President CEO Cerberus Interactive, Inc. [EMAIL PROTECTED] 979.739.5874 -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFAsfXZxvk7JEXkbERAiYkAJ9misO/pDJYEpJM3iPFF5T3GVdKGwCgpwFB ae17qOdSZL2DJj+VA6rUqDc= =dRAJ -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] if statement with or comparison (newbie)
Robert Cummings wrote: On Fri, 2006-09-08 at 18:38 -0400, tedd wrote: At 5:03 PM -0400 9/8/06, JD wrote: In all of the answers given thus far, no one mentioned that the use of $_REQUEST has a security issue with regard to where the $_REQUEST originated. $_REQUEST is an array consisting of $_GET, $_POST and $_COOKIE values and as such, you don't know where the data came from and that might be important. So, wouldn't it be better to recommend that the poster use $_GET, $_POST, or $_COOKIE instead of $_REQUEST? Nope, not inherently less secure. If you are properly cleaning and validating your data (as every good program should) then it doesn't matter whether you pull from $_GET, $_POST, or $_REQUEST. The only time it's bad is if you make assumptions about the value received -- AND YOU SHOULD NEVER ASSUME YOU HAVE CLEAN DATA FROM AN OUTSIDE SOURCE!! However, looking at it from a 'knowing early the data is tainted' perspective, not from a 'validating and cleaning perspective', if you have coded that (for instance) a variable is set via COOKIE, then only looking for that variable set via COOKIE will eliminate its being tainted by being set via GET or REQUEST. It doesn't eliminate any need for validation or cleaning, but reduces (naive) attempts to set via incorrect means. That is not possible via REQUEST. Personally, I like to toss out possibilities of bad data via simple means as early in the chain as possible. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] loop structure
I've been experimenting some time now but i can't get it right. I have a database in which I have a table with a list of photo_url Table: photos Id photo_url 1 photos/boeket_s40.jpg 2 photos/boeket_k12.jpg 3 photos/boeket_z23.jpg ... I get this out of the database with this query: $sqlphoto=select * from photos where photo_type='$category'; $exephoto=mysql_query($sqlphoto) or die (mysql_error()); Now I need a loop so that the photos are put into a table: table width=420 border=0 cellpadding=0 cellspacing=0 !--DWLayoutTable-- tr td width=17 height=110 valign=top!--DWLayoutEmptyCell--nbsp;/td td width=120 valign=topPICTURE HERE/td td width=13 valign=top!--DWLayoutEmptyCell--nbsp;/td td width=120 valign=top PICTURE HERE /td td width=13 valign=top!--DWLayoutEmptyCell--nbsp;/td td width=120 valign=top PICTURE HERE /td td width=13!--DWLayoutEmptyCell--nbsp;/td td width=4!--DWLayoutEmptyCell--nbsp;/td /tr tr td height=15/td td/td td/td td/td td/td td/td td/td /tr /table The first tr must be looped as long as there are photos in the array (so something like #lines in array/3, with ceil()) In each tr there are 3 pictures in it's td tags: so maybe something like for ($i=1;$i3;$i++){ td width=120 valign=topPICTURE HERE/td td width=13 valign=top!--DWLayoutEmptyCell--nbsp;/td } I have tried several thing and I'm able to create the correct amount of rows and the loop for the 3 cells in the row. Unfortunately it always only shows the first picture from the array in each of those cells. Can someone help me out? THX -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] if statement with or comparison (newbie)
Mark Charette wrote: However, looking at it from a 'knowing early the data is tainted' perspective, not from a 'validating and cleaning perspective', if you have coded that (for instance) a variable is set via COOKIE, then only looking for that variable set via COOKIE will eliminate its being tainted by being set via GET or REQUEST. It doesn't eliminate any need for validation or cleaning, but reduces (naive) attempts to set via incorrect means. That is not possible via REQUEST. Personally, I like to toss out possibilities of bad data via simple means as early in the chain as possible. If I understood that right it's a shocking naive statement for any developer to make. While I agree with what you're saying, you're implying a bad attitude to handling data from untrusted sources. It shouldn't matter how difficult it is for the user to send you dodgy data... if its source is outside your control you need to handle it accordingly no matter how unlikely you think it is that it will be changed between you setting it and getting it back. Data from any of the superglobals should be treated the same - trust none of them!! -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using a variable to call another variable
On Sat, 2006-09-09 at 08:44 -0400, tedd wrote: At 12:10 AM -0400 9/9/06, Robert Cummings wrote: On Sat, 2006-09-09 at 12:57 +0900, Dave M G wrote: PHP List, I have a list of variables: $001 $002 $003 $004 And what I'd like to do is have a function which will select and return one of them. Something like: public function returnVar($n) { return $(somehow n is made to reference the name of the variable); } And then in later scripts I can call anyone of the variables by saying returnVar(001) Or something like that. I've been scratching my head on how to do this for a while. I thought the answer might lie somewhere in call_user_func(), but even if it is I can't determine how. Any advice would be much appreciated. ?php function easy_peasy( $name ) { $foo1 = 1; $foo2 = 2; $foo3 = 3; return $$name; } echo easy_peasy( 'foo2' ).\n; ? Cheers, Rob. Or something like that. :-) $easy_peasyier = array(foo1 = 1, foo2 = 2, foo3 = 3); echo($easy_peasyier['foo1']); That's zero marks on any exam I ever wrote. You didn't properly read the business requirements that specified the need for a function ;) Also, the version you showed isn't shared in any way, it has local scope, so unless it's defined in global scope and you're working in global scope (since I don't see a global declaration) then it's not very accessible :)) Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] if statement with or comparison (newbie)
On Sat, 2006-09-09 at 10:21 -0400, Mark Charette wrote: Robert Cummings wrote: On Fri, 2006-09-08 at 18:38 -0400, tedd wrote: At 5:03 PM -0400 9/8/06, JD wrote: In all of the answers given thus far, no one mentioned that the use of $_REQUEST has a security issue with regard to where the $_REQUEST originated. $_REQUEST is an array consisting of $_GET, $_POST and $_COOKIE values and as such, you don't know where the data came from and that might be important. So, wouldn't it be better to recommend that the poster use $_GET, $_POST, or $_COOKIE instead of $_REQUEST? Nope, not inherently less secure. If you are properly cleaning and validating your data (as every good program should) then it doesn't matter whether you pull from $_GET, $_POST, or $_REQUEST. The only time it's bad is if you make assumptions about the value received -- AND YOU SHOULD NEVER ASSUME YOU HAVE CLEAN DATA FROM AN OUTSIDE SOURCE!! However, looking at it from a 'knowing early the data is tainted' perspective, not from a 'validating and cleaning perspective', if you have coded that (for instance) a variable is set via COOKIE, then only looking for that variable set via COOKIE will eliminate its being tainted by being set via GET or REQUEST. It doesn't eliminate any need for validation or cleaning, but reduces (naive) attempts to set via incorrect means. That is not possible via REQUEST. Personally, I like to toss out possibilities of bad data via simple means as early in the chain as possible. Any malevolently intentioned hacker will have little properly screwing around with cookie data. I'm pretty sure browsers allow editing the cookie values via the cookie browser. And if not, a quick PHP script is just as simple to create that mucks with cookie data. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] if statement with or comparison (newbie)
Stut wrote: Mark Charette wrote: However, looking at it from a 'knowing early the data is tainted' perspective, not from a 'validating and cleaning perspective', if you have coded that (for instance) a variable is set via COOKIE, then only looking for that variable set via COOKIE will eliminate its being tainted by being set via GET or REQUEST. It doesn't eliminate any need for validation or cleaning, but reduces (naive) attempts to set via incorrect means. That is not possible via REQUEST. Personally, I like to toss out possibilities of bad data via simple means as early in the chain as possible. If I understood that right it's a shocking naive statement for any developer to make. While I agree with what you're saying, you're implying a bad attitude to handling data from untrusted sources. I am being neither shocking or naive. Why is early discarding of data because it comes in the wrong area shocking? If I were looking for a variable set via a COOKIE, why would I look for the variable set via GET? As I so explicitly said above It doesn't eliminate any need for validation or cleaning, but reduces (naive) attempts to set via incorrect means. My CPU resources are valuable; writing code that checks whether a variable is set via the correct method is no harder ($_COOKIE vs. $_REQUEST) and throws out trivially spurious data. No more, no less. The same checks still need apply after that, but my CPU won't be burdened by the script kiddies. No more, no less. The data just won't appear. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] loop structure
On Sat, 2006-09-09 at 16:49 +0200, Reinhart Viane wrote: I've been experimenting some time now but i can't get it right. I have a database in which I have a table with a list of photo_url Table: photos Idphoto_url 1 photos/boeket_s40.jpg 2 photos/boeket_k12.jpg 3 photos/boeket_z23.jpg ... I get this out of the database with this query: $sqlphoto=select * from photos where photo_type='$category'; $exephoto=mysql_query($sqlphoto) or die (mysql_error()); Now I need a loop so that the photos are put into a table: table width=420 border=0 cellpadding=0 cellspacing=0 !--DWLayoutTable-- tr td width=17 height=110 valign=top!--DWLayoutEmptyCell--nbsp;/td td width=120 valign=topPICTURE HERE/td td width=13 valign=top!--DWLayoutEmptyCell--nbsp;/td td width=120 valign=top PICTURE HERE /td td width=13 valign=top!--DWLayoutEmptyCell--nbsp;/td td width=120 valign=top PICTURE HERE /td td width=13!--DWLayoutEmptyCell--nbsp;/td td width=4!--DWLayoutEmptyCell--nbsp;/td /tr tr td height=15/td td/td td/td td/td td/td td/td td/td /tr /table The first tr must be looped as long as there are photos in the array (so something like #lines in array/3, with ceil()) In each tr there are 3 pictures in it's td tags: so maybe something like for ($i=1;$i3;$i++){ td width=120 valign=topPICTURE HERE/td td width=13 valign=top!--DWLayoutEmptyCell--nbsp;/td } I have tried several thing and I'm able to create the correct amount of rows and the loop for the 3 cells in the row. Unfortunately it always only shows the first picture from the array in each of those cells. Can someone help me out? THX Untested... ... ... ?php if( ($result = mysql_query( $query )) === false ) { // do something other than die you lazy ass programmers. } else { $hits = mysql_num_rows( $result ); $cols = 3; $rows = ceil( $hits / $cols ); for( $i = 0; $i $rows; $i++ ) { for( $j = 0; $j $cols; $j++ ) { $picture = ''; if( ($item = mysql_fetch_assoc( $result )) !== false ) { echo 'td width=120 valign=top' .$item['picture'] .'/td' .'td width=13 valign=top' .'!--DWLayoutEmptyCell--nbsp;' .'/td'; } } } } ? Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] if statement with or comparison (newbie)
On Sat, 2006-09-09 at 11:30 -0400, Mark Charette wrote: Stut wrote: Mark Charette wrote: However, looking at it from a 'knowing early the data is tainted' perspective, not from a 'validating and cleaning perspective', if you have coded that (for instance) a variable is set via COOKIE, then only looking for that variable set via COOKIE will eliminate its being tainted by being set via GET or REQUEST. It doesn't eliminate any need for validation or cleaning, but reduces (naive) attempts to set via incorrect means. That is not possible via REQUEST. Personally, I like to toss out possibilities of bad data via simple means as early in the chain as possible. If I understood that right it's a shocking naive statement for any developer to make. While I agree with what you're saying, you're implying a bad attitude to handling data from untrusted sources. I am being neither shocking or naive. Why is early discarding of data because it comes in the wrong area shocking? That's your last line, I think he's commenting on the rest of your comment. Questionable data is questionable data, it doesn't matter from whence you clean it. If you haven't cleaned it your still going to get screwed no matter how much you rely on it being difficult to manipulate by a site visitor. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Access Violations
Hi Wolf, Please correct me if I'm wrong, but neither of these tools from the MySQL team can SSH tunnel. I need that. -Chris On 9/8/06, Wolf [EMAIL PROTECTED] wrote: MySQL Query Tool MySQL Admin Tool Both free, both work flawlessly w/ MySQL and both maintained by MySQL Wolf Christopher Watson wrote: Following up on this now... I have successfully installed Apache 2.0.59 (Win32), and configured successfully for PHP 5.1.6 and MySQL 5.0.24. The app is running fine, but I ran a few manipulation queries from the SQLyog interface and Apache did crash. I'll have try to reproduce the problem again in order to get the exception data. This is looking more and more like a SQLyog problem. Maybe I should try another MySQL admin client. -Christopher On 9/6/06, Christopher Watson [EMAIL PROTECTED] wrote: Spoke too soon. After a reboot, I had only IE and Homesite open, making changes to PHP code and running the app, and it hit an access violation. So SQLyog ain't it. -Chris On 9/6/06, Christopher Watson [EMAIL PROTECTED] wrote: Thanks for the input, Jon. I'll get to the Apache and IIS restart suggestions soon. Meanwhile, I think I have a semi-repeatable recipe for getting the access violation to happen. As far as I can tell, everything is cool until I open up SQLyog and do some sort of database manipulation within it. Almost immediately after that, switching back to the browser and flying through the app a little more brings on the violation. So far, my testing is indicating to me that the violation does not occur without SQLyog having done some work in the database. -Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] if statement with or comparison (newbie)
Robert Cummings wrote: On Sat, 2006-09-09 at 11:30 -0400, Mark Charette wrote: Stut wrote: Mark Charette wrote: However, looking at it from a 'knowing early the data is tainted' perspective, not from a 'validating and cleaning perspective', if you have coded that (for instance) a variable is set via COOKIE, then only looking for that variable set via COOKIE will eliminate its being tainted by being set via GET or REQUEST. It doesn't eliminate any need for validation or cleaning, but reduces (naive) attempts to set via incorrect means. That is not possible via REQUEST. Personally, I like to toss out possibilities of bad data via simple means as early in the chain as possible. If I understood that right it's a shocking naive statement for any developer to make. While I agree with what you're saying, you're implying a bad attitude to handling data from untrusted sources. I am being neither shocking or naive. Why is early discarding of data because it comes in the wrong area shocking? That's your last line, I think he's commenting on the rest of your comment. Questionable data is questionable data, it doesn't matter from whence you clean it. If you haven't cleaned it your still going to get screwed no matter how much you rely on it being difficult to manipulate by a site visitor. Where am I being unclear, then? reduces (naive) attempts to set via incorrect means. doesn't say 'eliminate serious attempts'. I would think my statement It doesn't eliminate any need for validation or cleaning, covers the remaining scenarios. Indeed, determining the source of data is one of the essential steps in validation. The one of the rules is 'discard even valid data if it comes from an untrusted source - and data coming from an _incorrect_ source is, by definition, untrusted even if if you wish to expend the effort to prove it valid. And I'll wager a brew no one here has ever done a formal, mathematically rigorous proof of a validation routine except as a class project. As a senior member of the software QC department in a major industrial company, I generally find more errors and omissions in validation routines during code reviews and ethical hacks than anywhere else. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] loop structure(SOLVED)
Thx, it works like a charm I think the mysql_fetch_assoc was the thing I was looking for. -Oorspronkelijk bericht- Van: Robert Cummings [mailto:[EMAIL PROTECTED] Verzonden: zaterdag 9 september 2006 17:36 Aan: [EMAIL PROTECTED] CC: php-general@lists.php.net Onderwerp: Re: [PHP] loop structure Untested... ... ... ?php if( ($result = mysql_query( $query )) === false ) { // do something other than die you lazy ass programmers. } else { $hits = mysql_num_rows( $result ); $cols = 3; $rows = ceil( $hits / $cols ); for( $i = 0; $i $rows; $i++ ) { for( $j = 0; $j $cols; $j++ ) { $picture = ''; if( ($item = mysql_fetch_assoc( $result )) !== false ) { echo 'td width=120 valign=top' .$item['picture'] .'/td' .'td width=13 valign=top' .'!--DWLayoutEmptyCell--nbsp;' .'/td'; } } } } ? Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] if statement with or comparison (newbie)
Mark Charette wrote: And I'll wager a brew no one here has ever done a formal, mathematically rigorous proof of a validation routine except as a class project. As a senior member of the software QC department in a major industrial company, I generally find more errors and omissions in validation routines during code reviews and ethical hacks than anywhere else. Ok, let's not turn this into a pissing contest. I admit I misread the initial email and read more into it than it said. However, since this is a mailing list with a lot of beginners on it we usually make a point to be very clear on issues like validation and it was worth reiterating the point that no data that comes from the user should not be trusted no matter how hard it is for the user to change. Your point is valid, but in the great scheme of things it's more important to enforce the importance of validation than performance. I felt your post was confusing so I'm sure others did too. 'Nuff pissing. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] if statement with or comparison (newbie)
On Sat, 2006-09-09 at 12:12 -0400, Mark Charette wrote: As a senior member of the software QC department in a major industrial company, I generally find more errors and omissions in validation routines during code reviews and ethical hacks than anywhere else. http://en.wikipedia.org/wiki/Appeal_to_authority Where's Tedd, he's got the latin to go with the above link :) Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] if statement with or comparison (newbie)
On Sat, 2006-09-09 at 17:27 +0100, Stut wrote: Mark Charette wrote: And I'll wager a brew no one here has ever done a formal, mathematically rigorous proof of a validation routine except as a class project. As a senior member of the software QC department in a major industrial company, I generally find more errors and omissions in validation routines during code reviews and ethical hacks than anywhere else. Ok, let's not turn this into a pissing contest. I admit I misread the initial email and read more into it than it said. However, since this is a mailing list with a lot of beginners on it we usually make a point to be very clear on issues like validation and it was worth reiterating the point that no data that comes from the user should not be trusted no matter how hard it is for the user to change. Your point is valid, but in the great scheme of things it's more important to enforce the importance of validation than performance. I felt your post was confusing so I'm sure others did too. 'Nuff pissing. A, what about this bonfire I was putting out?? Admittedly there's a strong odour hanging in the air now, but we don't want forest fires do we? *heheh* Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Access Violations
did you try mysql 5.0.24a? there where some problems with 5.0.24 (segfaults...) -- View this message in context: http://www.nabble.com/PHP-Access-Violations-tf023.html#a6227018 Sent from the PHP - General forum at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] if statement with or comparison (newbie)
At 12:29 PM -0400 9/9/06, Robert Cummings wrote: On Sat, 2006-09-09 at 12:12 -0400, Mark Charette wrote: As a senior member of the software QC department in a major industrial company, I generally find more errors and omissions in validation routines during code reviews and ethical hacks than anywhere else. http://en.wikipedia.org/wiki/Appeal_to_authority Where's Tedd, he's got the latin to go with the above link :) Cheers, Rob. Rob: Don't throw me in that briar patch. I know the saying Locus ab auctoritate est infirmissimus may appear to fit, but I think in this case se méfier de l'eau qui dort is better. Besides: A) I was the one that started this fire storm. B) Mark came in and backed me up. C) Stu, who respect greatly, surprisingly waded in on the other side. Now, I stand cowardly between two opinions not wanting to offend either, nor embarrass myself publicly, which I do often enough anyway. However with that said, my original question/statement still stands. I realize (AS WE ALL DO), that *all* data coming from outside *must* be sanitized -- BUT -- using $_REQUEST still does not provide as much information as to where the data came from as the use of $_GET, $_POST, and $_COOKIE -- that's an unarguable fact, is it not? This thread was like an old-west circled wagon train with everyone inside expounding about the obvious dangers of an Indian attack* but failing to listen to some who are saying They're attacking from the West, while arguing it's not important to know which way the attack comes. I think some just misread the point of the post. tedd (as he scurries around to the east side of a rock while dodging arrows) *In keeping with current Political correctness, it was an US Indian attack -- also note the attack was from the West and not from the East. :-) -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using a variable to call another variable
At 11:19 AM -0400 9/9/06, Robert Cummings wrote: Or something like that. :-) $easy_peasyier = array(foo1 = 1, foo2 = 2, foo3 = 3); echo($easy_peasyier['foo1']); That's zero marks on any exam I ever wrote. You didn't properly read the business requirements that specified the need for a function ;) Also, the version you showed isn't shared in any way, it has local scope, so unless it's defined in global scope and you're working in global scope (since I don't see a global declaration) then it's not very accessible :)) Cheers, Rob. Rob: If you ever wrote an exam that said at the end of a question -- Or something like that. -- then you would have gotten an answer like mine. I've been dodging teachers longer than you've been one. :-) tedd PS: Few things are harder to put up with than the annoyance of a good example. -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using a variable to call another variable
On Sat, 2006-09-09 at 16:05 -0400, tedd wrote: At 11:19 AM -0400 9/9/06, Robert Cummings wrote: Or something like that. :-) $easy_peasyier = array(foo1 = 1, foo2 = 2, foo3 = 3); echo($easy_peasyier['foo1']); That's zero marks on any exam I ever wrote. You didn't properly read the business requirements that specified the need for a function ;) Also, the version you showed isn't shared in any way, it has local scope, so unless it's defined in global scope and you're working in global scope (since I don't see a global declaration) then it's not very accessible :)) Cheers, Rob. Rob: If you ever wrote an exam that said at the end of a question -- Or something like that. -- then you would have gotten an answer like mine. -5 Argumentation *haha*. I've been dodging teachers longer than you've been one. :-) I'm not a teacher, and if I were, I'd most certanly only have a few to choose from my history that I considered good teachers. Grab some popcorn for a little story... I have an especial disdain for this one teacher in grade 12 that forced the whole class to write points on 4x6 cards for an essay we had to write. Each week she'd check the stack. So you'd see the smug looks on the annoying people that thought writing down hundreds of snippets was good work. I on the other hand was doing mine on the 9 wonders of the world, I had 9 cards. She really didn't find that amusing, especially since week one I had 9 cards, and on week 4 I had 9 cards unchanged. When I got my essay back I got 75%. 25 for the intro, 25 for the body, 25 for the conclusion, and 0 for content... oh the bitterness she had for me. PS: Few things are harder to put up with than the annoyance of a good example. You feel that way about my example? Aw! ;) Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using a variable to call another variable
On Sat, 09 Sep 2006 08:55:35 -0500, Christopher Weldon [EMAIL PROTECTED] wrote: class myClass { private var $_001; private var $_002; private var $_003; public function access_var($var) { return $this-$$var; } } $cs = new myClass; $cs-access_var('_001'); How about call a function whose name is returned from the function myFunc()? :-D Ansewer: {myFunc()}() My 2 cents. -- - Lic. Martín Marqués | SELECT 'mmarques' || Centro de Telemática| '@' || 'unl.edu.ar'; Universidad Nacional| DBA, Programador, del Litoral | Administrador - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Memcache function usage
Hi, I'm trying to use memcache ( http://uk2.php.net/manual/en/function.memcache-add.php ) but I'm having a problem. When using the add/set functions I want to set an expire time, but dont want the data to be compressed (using small strings it seems silly to try to and compress), what do I put for flags to allow me to use the extra expire parameter? Thanks, Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question about ?= ?
On Saturday 09 September 2006 08:19, Mike Borrelli wrote: Good day, While I've been using php for more than a little while now, I've never understood why the use of the ?= ...? short tag is noted to be avoided. Or rather, I understand that there's an option to disable it, and that's why it's noted in this way, but I don't understand why it's disabled? What's gained by writing ?php echo some_function(); ? over ?= some_function(); ? Thanks in advance. Cheers, Mike As was said before, the major reasons for not using short tags are: 1) Not everyone has access to the ini file, and might not be able to use short tags. If you're releasing your code to the public, you want to work in as many places as possible, so then you should use ?php instead. 2) when using XML files, they use ?xml, and the ? is recognized as the start of a PHP block, but the following syntax will be correct and your code will fail. I have seen that someone suggested having PHP recognize ?xml as not being a PHP short tag, but I don't remember where off the top of my head. This does bring up an interesting idea though. It appears that ?php= is not valid. A lot of people use ?= as a sort of templating system instead of adding the complexity of smarty or other templating systems (which are fine). Is it possible, or will it be possible, to use ?php=blah ? -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: IE session problem on one server only
On Friday 08 September 2006 06:06, Alex Turner wrote: We had issues before with the session not working correctly in IE, but I fixed those with info from the php.net manual user comments. I'm at a loss as to why it's only happening on the one server and not the other now. If it were the other way around I wouldn't care, but the live site shouldn't break. :-) Any idea what could be the problem? It sounds like the IE is putting different security/cookie settings for your local and remote site. We get the same symptoms from multiple systems. I get it on my work desktop, and on the client's desktop in another city. -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it. -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using a variable to call another variable [SOLVED]
Martin, Tedd, Robert, Christopher, Thank you all for your advice and examples. I had not been aware that it was possible to simply add another $ ahead of the variable, to make a variable of the variable's name. And especially thank you for expressing an example in terms of a class and method, which is my ultimate intent with this process. I will also make sure to name my variables with at least one leading alphabet character. Thanks for the warning. All your time and expert advice is much appreciated. -- Dave M G Ubuntu 6.06 LTS Kernel 2.6.17.7 Pentium D Dual Core Processor PHP 5, MySQL 5, Apache 2 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Memcache function usage
Chris wrote: Hi, I'm trying to use memcache ( http://uk2.php.net/manual/en/function.memcache-add.php ) but I'm having a problem. When using the add/set functions I want to set an expire time, but dont want the data to be compressed (using small strings it seems silly to try to and compress), what do I put for flags to allow me to use the extra expire parameter? Just pass NULL or 0 as the flags argument, and pass the expiry time as usual. E.g. $obj-add/set($var,$val,0,$expiry) jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question about ?= ?
Okay, after thinking about it, and looking at the replies, it seems as though there is only one situation where the short tags break things, and that's in XML with the ? ? pair being valid for XML. Yes, enabling the short tags is in the ini file, but is it on by default and require effort to change? That's the real question, I think. Not, why shouldn't I use them the way they are, but why is it that the ?= ? tag isn't designed into the language to be acceptable? Honestly, the ? ? pair just feels a little lazy, since all you save are the 4 characters php , and all the code inside is the same. The ?= ? tag gives you 7 characters free and does something unique. The situation I think of using it the most in is something such as: lia href=?= $post-permLink; ?.../a/li Which looks cleaner, in my opinion, than: lia href=?php print $post-permLink; ?.../a/li Not a whole lot larger, no, and perhaps you might say, Well, the second way is more explicit! Yes. Also, shouldn't it be possible to check for ?= ? and, based on the '=' there, pop out of the parser if it comes across ?xml...? ? Cheers, Mike As was said before, the major reasons for not using short tags are: 1) Not everyone has access to the ini file, and might not be able to use short tags. If you're releasing your code to the public, you want to work in as many places as possible, so then you should use ?php instead. 2) when using XML files, they use ?xml, and the ? is recognized as the start of a PHP block, but the following syntax will be correct and your code will fail. I have seen that someone suggested having PHP recognize ?xml as not being a PHP short tag, but I don't remember where off the top of my head. This does bring up an interesting idea though. It appears that ?php= is not valid. A lot of people use ?= as a sort of templating system instead of adding the complexity of smarty or other templating systems (which are fine). Is it possible, or will it be possible, to use ?php=blah ? -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php