php-general Digest 10 May 2007 13:21:15 -0000 Issue 4783
php-general Digest 10 May 2007 13:21:15 - Issue 4783 Topics (messages 254706 through 254716): Re: PhP and Java login trouble 254706 by: Brad Sumrall Re: Search function 254707 by: Chris Re: Scalable Site Architecture 254708 by: Chris SESSION LOST! 254709 by: Sascha Braun Re: Problem with mssql_query() 254710 by: Chris Re: [EMAIL PROTECTED] 254711 by: Frank Arensmeier 254712 by: Tom Rogers 254716 by: Daniel Brown Re: getting $_ENV variables 254713 by: C.R.Vegelin Re: session cookies enabled? 254714 by: Ford, Mike Re: Ajax? 254715 by: Rangel Reale 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: [EMAIL PROTECTED] -- ---BeginMessage--- I have a question about your suggestion. Would it not be easier to simply carry the sessionid from the php session validation to the javascript? Instead of: if(document.frmlogin.txtusername.value==) { alert(Please Enter Username.); document.frmlogin.txtusername.focus(); return false; Why would I want to re-enter the user name? My common sense which maybe completely wrong say, YOU ARE VALIDATED IN PHPBB via issetid, now post to (document.frmlogin.userid.value==) This is why I am not catching your angle. PhP makes so much more sense. This javascript integration is really giving me a headache! Suggestions? Brad -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 09, 2007 2:16 AM To: Brad Sumrall Cc: [EMAIL PROTECTED] Subject: Re: [PHP] PhP and Java login trouble Brad Sumrall wrote: I have been hunting all around that website you referred me too looking for javascripting information and can find nothing. I know a little bit of php but little to nothing about javascripting. Eh? I never sent you to a website. See this code: function validatelogin() { if(document.frmlogin.txtusername.value==) { alert(Please Enter Username.); document.frmlogin.txtusername.focus(); return false; } if(document.frmlogin.txtpwd.value==) { alert(Please Enter Password.); document.frmlogin.txtpwd.focus(); return false; } document.frmlogin.login.value=Success; document.frmlogin.action=operation.php?mode=login; return true; } You need to create a *similar* function (eg 'BBValidateLogin()') to check different html field names. For example: function BBValidateLogin() { var f = document.forms[0]; alert('username is ' + f.username.value); } The username.value comes from this: input type=text class=post name=username size=25 maxlength=40 value= / where you have name=username So take the name=... and put a .value on the end. Rinse, repeat until you have checked all of the fields you need to. Return true for the form to submit. Return false for it to NOT submit. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- ---BeginMessage--- Ryan A wrote: Hey! .A little background: We have a site that has already been made.. a couple of hundred pages displayed via SMARTY templates, the site's in Swedish. The navigation and other parts except for the center is taken care of by the templates and other scripts... the center main text is taken from the database(mySql) based on $page_id...its in a MySql TEXT field and has all the html etc that will be displayed in the center of the page. End of background.. Now they want to add a search function to the site... a simpe textbox where a user enters a word or sentance and they get 20 results per page... with a x.xx % closest to your query can anybody give me basic pointers on where to start? Any links/software or articles too would be appreciated... http://dev.mysql.com/doc/refman/4.1/en/fulltext-search.html Start off with that, if they need something more complicated down the line, revisit. -- Postgresql php tutorials http://www.designmagick.com/ ---End Message--- ---BeginMessage--- bruce wrote: Hi.. In looking for what's required fo a site, I'm trying to find docs/overview/mentors to talk to/etc,... Basically, I'm considering what's required in terms of hardware/apps/functionality for each server to be able to support a site/system of ~100,000/day Depends on your app and what you want to do. If it's 95% pull content from the database and display it (eg a page
[PHP] SESSION LOST!
Hi Fellows, I am developing on a large project. Its containing a couple of ajax scripts. One day, my temporeary folder was full, because everytime i clicked some- where in the page, a new session file was created. So i decided, to change to a database driven session management. But it did not really help. Its possible to log into the site. You can do authoring or use the service as it should be, but after a little time, the session is just lost. Sometimes it takes ten minutes, sometimes just a few mouse clicks. Its very strange. But it never happens during the first clicks. Maybe somebody is able to help me. Best Regards, Sascha Braun -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with mssql_query()
Richard Lynch wrote: PostgreSQL will simply throw an error, because '8' is not no way no how an INT. It's a string. Since when? test=# create table b(b int); CREATE TABLE test=# insert into b(b) values ('1'); INSERT 0 1 test=# SELECT * from b; b --- 1 (1 row) test=# select * from b where b='1'; b --- 1 (1 row) No idea about the OP's problem but that statement is just wrong :P -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [EMAIL PROTECTED]
Sorry, your question has nothing to do with PHP. Maybe try a CSS list? http://www.google.com/search?rls=sv-seq=css+discussion +listie=UTF-8oe=UTF-8 http://www.google.com/search?rls=sv-seq=why+ie+sucksie=UTF-8oe=UTF-8 http://whyiesucks.blogspot.com/ //frank 9 maj 2007 kl. 15.13 skrev Farid Jamea: Hello, To me this seems to be a very strange problem. I have a static html page (index.html) that shows correctly on both FF2 IE7. I splitted the website up into different sections: (header, footer, ...). To do this I have used: -- ?php require(header.php); ? Some code goes here... ?php require(footer.php); ? -- and so on. When I test my page (now index.php), it shows perfect on Firefox, but in IE some stuff are not in their right place. I have checked the source code of both index.html and index.php and they seem both identical to me. Do you know why IE fails to correctly render the page? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [EMAIL PROTECTED]
Hi, Wednesday, May 9, 2007, 11:13:50 PM, you wrote: FJ Hello, FJ To me this seems to be a very strange problem. FJ I have a static html page (index.html) that shows correctly on both FF2 FJ IE7. FJ I splitted the website up into different sections: (header, footer, ...). To FJ do this I have used: FJ -- FJ ?php FJ require(header.php); ? FJ Some code goes here... FJ ?php FJ require(footer.php); ? FJ -- FJ and so on. FJ When I test my page (now index.php), it shows perfect on Firefox, but in IE FJ some stuff are not in their right place. I have checked the source code of FJ both index.html and index.php and they seem both identical to me. FJ Do you know why IE fails to correctly render the page? FJ Thanks Could be stray carriage returns in your include files, good idea to remove any '? in the include files as they are not needed. -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting $_ENV variables
Thanks Daniel, Greg, Richard, I made a script with: ?php print_r($_ENV); ? and it results only into: Array ( ) nothing else ... So it must be caused by a different environment ? All I want is to check the $_ENV['OS'] within PHP scripts. Regards, Cor - Original Message - From: Daniel Brown To: C.R.Vegelin Cc: [EMAIL PROTECTED] Sent: Wednesday, May 09, 2007 5:26 PM Subject: Re: [PHP] getting $_ENV variables When I print_r($_ENV); from the CLI on 5.0.4 I get a bunch of results, no problem but no $_ENV['OS'] variable. Further, when I check my phpinfo(); output, there are even fewer $_ENV variables printed than the CLI offers. I'm not certain about this, Cor, but my guess is that PHP 5.x.x may have altered the default $_ENV output to hide some of this information --- which is a good thing, in my opinion, because then you won't just have some run-of-the-mill script kiddie checking out the details of a box for known security holes. Of course, that doesn't necessarily stop ? passthru('uname -a').\n; ? or checking the $_SERVER['SERVER_SIGNATURE'] variable for the OS information so perhaps this response is just one of those white-bread responses. Something to chew on, but you really don't get anything from it. On 5/9/07, C.R.Vegelin [EMAIL PROTECTED] wrote: Hi All, I get nothing when using: echo $_ENV['OS']; Also nothing when using: print_r($_ENV); However, phpinfo(); show a full list of ENV settings. How to get $_ENV variables ? I am using PHP version 5.2.0. TIA, Cor -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107
RE: [PHP] Re: session cookies enabled?
On 09 May 2007 16:36, [EMAIL PROTECTED] wrote: Ford, Mike writes: You can also set up php.ini and use the built-in sessions with http://php.net/session_start so that PHP will take care of this for you. That is what I was intending to do. How do I find out if whether or not the session cookie was accepted using the built-in sessions? I found no function for such a test. Check the SID constant after you've done session_start(). If it has an empty value, the session is using cookies; otherwise, it'll have a value of the form 'sessionname=sessionid', which is what is appended to the URL (or inserted in forms as a hidden value) to propagate the session-id. Interesting idea. This brings up a question. In order to decide whether to use cookies or SID the built-in sessions must be testing to see if the user's browser will accept the session cookies. How do they do that? By sending it out and checking to see whether it comes back on the next page. Assuming your setup is: session.use_cookies = On session.use_only_cookies = Off session.use_trans_sid = On Then the sequence is this: 1. The first page involving a session will *both* send the cookie *and* append the SID to URLs in the page. 2. So the next page request will return the SID, and if cookies are enabled also the cookie. 3. On starting the session for this page, PHP will first look for the cookie: if it's present, its value will be used and SID defined as empty; if not, the browser must not be accepting cookies, so the value from the URL query string is used and SID is defined with the matching string. 4. PHP now knows whether cookies are in use *for this request*, and *either* sends the cookie *or* appends the SID to URLs in the page. 5. Requests from this page will thus *either* return the cookie *or* include the SID as a URL get parameter. 6. Go back to 3. Note that with this setup, you will *always* get at least one request with the SID in the URL. Any site that doesn't do this has use_only_cookies turned on or/and use_trans_sid turned off. If they do it by the 2 page, send a cookie and see if it comes back to the second page method we have been talking about, then somehow, they are sureptiously inserting a forward to a non- existant page! Right? How do they do that? No, see above: they simply wait for the next regular page request to come in and see if the cookie came with it. Nothing surreptitious or super-clever. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, JG125, The Headingley Library, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 812 4730 Fax: +44 113 812 3211 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ajax?
JavaScript (and AJAX) took the fun out of programming. Before AJAX, programming for web was easy and fast. Now its the oposite. - Original Message - From: jekillen [EMAIL PROTECTED] To: Emil Edeholt [EMAIL PROTECTED] Cc: PHP List php-general@lists.php.net Sent: Wednesday, May 09, 2007 10:03 PM Subject: Re: [PHP] Ajax? On May 9, 2007, at 8:04 AM, Emil Edeholt wrote: Hi! What do you guys use to develop ajax applications and do you have any good articles on the subject? I've just about finished an ajaxish site but it wasn't fun. A lot of nesting javascript inside php calls, having to write the logic both in javascript and php and so on. The source looks ugly and was time consuming to debug. Thanks! Anything involving javascript development has several built in debugging facilities 1: Alert dialogs: You may find it a chore to learn how to use them effectively. But the current content of any variable can be displayed with an alert dialog. You have to pay attention to how strings are concatenated; with +, The actual variable name cannot be quoted. 2: Browser error reporting, in Netscape species, javascript console. Take a hint, all source code text should be formated for Unix/Linux ( line feed line endings) If you do scripting on a Classic Mac OS = OS9, the line endings are carriage; and Windows uses both carriage return and line feed. return. You will drive your self crazy cussing the console because it will not refer to lines containing syntax errors, but some disrelated lines. 3. View source window in browser to see exactly what the browser is getting on page load. 4. Forms: I have coded special forms just for the sake of development and debug of javascript apps. All globals are visible through out the script, WITH THE EXCEPTION OF SOME THAT ARE DEFINED IN SOURCED JS FILES; Opening a javascript window is in a function does not seem to register if the function is in a sourced file. 5. Patience, patience, patience, some masochism, Several large available paper back text books. No one will describe all you might need to know about issues like rollovers, DHTML, etc, Imagination and ingenuity, or the will to search and sift through others source code until you find what you are looking for, and then making it work for you. That's it, I have some suggestion that there are systems available for javascript but I have done without long enough to have my methods and approaches. One more thing, php and javascript work very well together. I have even written a function to display php variable values as javascript alert dialogs. It will not function as break points for php like it does with javascript, but at least you do not have to decipher php error smeared all over the screen. And Ajax, even though I have not cracked that particular aspect of javascript as yet, looks very worthwhile. Jeff K -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.467 / Virus Database: 269.6.4/790 - Release Date: 5/5/2007 10:34 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [EMAIL PROTECTED]
Farid, Can you copy each .php file to a .phps extension and link us to it? That will allow us to view the source of each page and see for ourselves. If there's any private information (passwords, database info, etc.), however, please DO NOT do this. Only if it's a simple HTML-style page. On 5/10/07, Tom Rogers [EMAIL PROTECTED] wrote: Hi, Wednesday, May 9, 2007, 11:13:50 PM, you wrote: FJ Hello, FJ To me this seems to be a very strange problem. FJ I have a static html page (index.html) that shows correctly on both FF2 FJ IE7. FJ I splitted the website up into different sections: (header, footer, ...). To FJ do this I have used: FJ -- FJ ?php FJ require(header.php); ? FJ Some code goes here... FJ ?php FJ require(footer.php); ? FJ -- FJ and so on. FJ When I test my page (now index.php), it shows perfect on Firefox, but in IE FJ some stuff are not in their right place. I have checked the source code of FJ both index.html and index.php and they seem both identical to me. FJ Do you know why IE fails to correctly render the page? FJ Thanks Could be stray carriage returns in your include files, good idea to remove any '? in the include files as they are not needed. -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107
Re: [PHP] getting $_ENV variables
Cor, If it's suggesting that it's an array, that's a little baffling, because that means there are multiple entries (at least two), but they appear to either be null or otherwise unable to display. Did you get that result when running the script from the CLI or via the web? On 5/10/07, C.R.Vegelin [EMAIL PROTECTED] wrote: Thanks Daniel, Greg, Richard, I made a script with: ?php print_r($_ENV); ? and it results only into: Array ( ) nothing else ... So it must be caused by a different environment ? All I want is to check the $_ENV['OS'] within PHP scripts. Regards, Cor - Original Message - *From:* Daniel Brown [EMAIL PROTECTED] *To:* C.R.Vegelin [EMAIL PROTECTED] *Cc:* [EMAIL PROTECTED] *Sent:* Wednesday, May 09, 2007 5:26 PM *Subject:* Re: [PHP] getting $_ENV variables When I print_r($_ENV); from the CLI on 5.0.4 I get a bunch of results, no problem but no $_ENV['OS'] variable. Further, when I check my phpinfo(); output, there are even fewer $_ENV variables printed than the CLI offers. I'm not certain about this, Cor, but my guess is that PHP 5.x.x may have altered the default $_ENV output to hide some of this information --- which is a good thing, in my opinion, because then you won't just have some run-of-the-mill script kiddie checking out the details of a box for known security holes. Of course, that doesn't necessarily stop ? passthru('uname -a').\n; ? or checking the $_SERVER['SERVER_SIGNATURE'] variable for the OS information so perhaps this response is just one of those white-bread responses. Something to chew on, but you really don't get anything from it. On 5/9/07, C.R.Vegelin [EMAIL PROTECTED] wrote: Hi All, I get nothing when using: echo $_ENV['OS']; Also nothing when using: print_r($_ENV); However, phpinfo(); show a full list of ENV settings. How to get $_ENV variables ? I am using PHP version 5.2.0. TIA, Cor -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107
Re: [PHP] SESSION LOST!
Am Donnerstag, 10. Mai 2007 08:59 schrieb Sascha Braun: but after a little time, the session is just lost. That doesn't say anything to me. Could you be more verbose on what you mean by the sessin is lost? Regards, Oliver -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] [EMAIL PROTECTED]
Hi, Could be stray carriage returns in your include files, good idea to remove any '? in the include files as they are not needed. Perhaps I should have said: remove any '?' at the END of the include file as they are not needed, of course any escaping to html in the middle will still be needed. :) -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting $_ENV variables
Daniel, I did get the result via the web / IE with the address: http://127.0.0.1/test/ENVtest.php with ENVtest.php having: ?php print_r($_ENV); ? using Windows XP, PHP 5.2.0 - Original Message - From: Daniel Brown To: C.R.Vegelin Cc: [EMAIL PROTECTED] Sent: Thursday, May 10, 2007 2:24 PM Subject: Re: [PHP] getting $_ENV variables Cor, If it's suggesting that it's an array, that's a little baffling, because that means there are multiple entries (at least two), but they appear to either be null or otherwise unable to display. Did you get that result when running the script from the CLI or via the web? On 5/10/07, C.R.Vegelin [EMAIL PROTECTED] wrote: Thanks Daniel, Greg, Richard, I made a script with: ?php print_r($_ENV); ? and it results only into: Array ( ) nothing else ... So it must be caused by a different environment ? All I want is to check the $_ENV['OS'] within PHP scripts. Regards, Cor - Original Message - From: Daniel Brown To: C.R.Vegelin Cc: [EMAIL PROTECTED] Sent: Wednesday, May 09, 2007 5:26 PM Subject: Re: [PHP] getting $_ENV variables When I print_r($_ENV); from the CLI on 5.0.4 I get a bunch of results, no problem but no $_ENV['OS'] variable. Further, when I check my phpinfo(); output, there are even fewer $_ENV variables printed than the CLI offers. I'm not certain about this, Cor, but my guess is that PHP 5.x.x may have altered the default $_ENV output to hide some of this information --- which is a good thing, in my opinion, because then you won't just have some run-of-the-mill script kiddie checking out the details of a box for known security holes. Of course, that doesn't necessarily stop ? passthru('uname -a').\n; ? or checking the $_SERVER['SERVER_SIGNATURE'] variable for the OS information so perhaps this response is just one of those white-bread responses. Something to chew on, but you really don't get anything from it. On 5/9/07, C.R.Vegelin [EMAIL PROTECTED] wrote: Hi All, I get nothing when using: echo $_ENV['OS']; Also nothing when using: print_r($_ENV); However, phpinfo(); show a full list of ENV settings. How to get $_ENV variables ? I am using PHP version 5.2.0. TIA, Cor -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107
Re: [PHP] getting $_ENV variables
Daniel Brown wrote: If it's suggesting that it's an array, that's a little baffling, because that means there are multiple entries (at least two), but they appear to either be null or otherwise unable to display. The $_ENV superb-global contains an array of environment settings, so it's not totally baffling that print_r() on it should return an array. The reason it is empty is because the variables_order setting in the php.ini has had it disabled. The default is: variables_order = EGPCS But it must have been changed to: variables_order = GPCS Dropping the E (Environment variables) will cause a print_r($_ENV) to be totally empty. Some hosts do this in order to hide the environment settings because they can contain sensitive information such as the CPU identifiers, etc. I've seen the 'cheaper' hosts (especially those hosting on Windows and/or Virtual Servers) disable this so you can't tell what kind of CPU they're using, or where their system drive is. Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting $_ENV variables
What HTTP server are you using, Apache, IIS, AnalogX SimpleServer? That last one is actually one of my favorites for simple desktop page hosting. Tiny, no installation boom, there you go. http://www.analogx.com/ --- There's a bunch of stuff there. No, I'm not affiliated with them, or advertising for them. Just linking. On 5/10/07, C.R.Vegelin [EMAIL PROTECTED] wrote: Daniel, I did get the result via the web / IE with the address: http://127.0.0.1/test/ENVtest.php with ENVtest.php having: ?php print_r($_ENV); ? using Windows XP, PHP 5.2.0 - Original Message - *From:* Daniel Brown [EMAIL PROTECTED] *To:* C.R.Vegelin [EMAIL PROTECTED] *Cc:* [EMAIL PROTECTED] *Sent:* Thursday, May 10, 2007 2:24 PM *Subject:* Re: [PHP] getting $_ENV variables Cor, If it's suggesting that it's an array, that's a little baffling, because that means there are multiple entries (at least two), but they appear to either be null or otherwise unable to display. Did you get that result when running the script from the CLI or via the web? On 5/10/07, C.R.Vegelin [EMAIL PROTECTED] wrote: Thanks Daniel, Greg, Richard, I made a script with: ?php print_r($_ENV); ? and it results only into: Array ( ) nothing else ... So it must be caused by a different environment ? All I want is to check the $_ENV['OS'] within PHP scripts. Regards, Cor - Original Message - *From:* Daniel Brown [EMAIL PROTECTED] *To:* C.R.Vegelin [EMAIL PROTECTED] *Cc:* [EMAIL PROTECTED] *Sent:* Wednesday, May 09, 2007 5:26 PM *Subject:* Re: [PHP] getting $_ENV variables When I print_r($_ENV); from the CLI on 5.0.4 I get a bunch of results, no problem but no $_ENV['OS'] variable. Further, when I check my phpinfo(); output, there are even fewer $_ENV variables printed than the CLI offers. I'm not certain about this, Cor, but my guess is that PHP 5.x.x may have altered the default $_ENV output to hide some of this information --- which is a good thing, in my opinion, because then you won't just have some run-of-the-mill script kiddie checking out the details of a box for known security holes. Of course, that doesn't necessarily stop ? passthru('uname -a').\n; ? or checking the $_SERVER['SERVER_SIGNATURE'] variable for the OS information so perhaps this response is just one of those white-bread responses. Something to chew on, but you really don't get anything from it. On 5/9/07, C.R.Vegelin [EMAIL PROTECTED] wrote: Hi All, I get nothing when using: echo $_ENV['OS']; Also nothing when using: print_r($_ENV); However, phpinfo(); show a full list of ENV settings. How to get $_ENV variables ? I am using PHP version 5.2.0. TIA, Cor -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107
Re: [PHP] getting $_ENV variables
I guess I really didn't understand that myself before either. So Richard, even though it's disabling data output, it still exists as an array? Well, damn you really DO learn something new every day. On 5/10/07, Richard Davey [EMAIL PROTECTED] wrote: Daniel Brown wrote: If it's suggesting that it's an array, that's a little baffling, because that means there are multiple entries (at least two), but they appear to either be null or otherwise unable to display. The $_ENV superb-global contains an array of environment settings, so it's not totally baffling that print_r() on it should return an array. The reason it is empty is because the variables_order setting in the php.ini has had it disabled. The default is: variables_order = EGPCS But it must have been changed to: variables_order = GPCS Dropping the E (Environment variables) will cause a print_r($_ENV) to be totally empty. Some hosts do this in order to hide the environment settings because they can contain sensitive information such as the CPU identifiers, etc. I've seen the 'cheaper' hosts (especially those hosting on Windows and/or Virtual Servers) disable this so you can't tell what kind of CPU they're using, or where their system drive is. Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107
Re: [PHP] Ajax?
On Thu, 2007-05-10 at 08:52 -0300, Rangel Reale wrote: JavaScript (and AJAX) took the fun out of programming. Before AJAX, programming for web was easy and fast. Now its the oposite. Maybe you're doing it wrong :| 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
[PHP] One class, many methods: PHP4.x: Q's
Hi, This might be a real obvious question/answer... but I have been up all night geeking on code, so my mind is kinda mushy -- please be kind. :) I have a class called Randimg. Within that class, I have several methods. Within a few of those methods, I use the below code snippet: $_SERVER['DOCUMENT_ROOT'] What would be the best way to assign the above code to a global variable/constant within the class? Also, within each method, I am returning error strings... I would like to create these as class constants... Or something... What is best way to setup static strings within my class? Basically, I would like to have these strings at the top of my class so potential users can easily change the settings. ;) Lol, sorry is stpid questions... I am still kinda new to PHP OOP. Many TIA's! Cheers, Micky -- Wishlists: http://snipurl.com/1gqpj Switch: http://browsehappy.com/ BCC?: http://snipurl.com/w6f8 My: http://del.icio.us/mhulse -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting $_ENV variables
Yes, my PHPinfo shows under configuration: variables_order = GPCS I will test EGPCS setting in php.ini But that also means that code using $_ENV cannot be run with hosts hiding the environment settings ?! And I assume that EGPCS will also affect: ?php print_r($_FILES); ? Now with GPCS this script shows also only: Array ( ) So also potential problems with $_FILES with hosts hiding the environment settings ?! Regards, Cor - Original Message - From: Richard Davey [EMAIL PROTECTED] To: [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, May 10, 2007 2:44 PM Subject: Re: [PHP] getting $_ENV variables Daniel Brown wrote: If it's suggesting that it's an array, that's a little baffling, because that means there are multiple entries (at least two), but they appear to either be null or otherwise unable to display. The $_ENV superb-global contains an array of environment settings, so it's not totally baffling that print_r() on it should return an array. The reason it is empty is because the variables_order setting in the php.ini has had it disabled. The default is: variables_order = EGPCS But it must have been changed to: variables_order = GPCS Dropping the E (Environment variables) will cause a print_r($_ENV) to be totally empty. Some hosts do this in order to hide the environment settings because they can contain sensitive information such as the CPU identifiers, etc. I've seen the 'cheaper' hosts (especially those hosting on Windows and/or Virtual Servers) disable this so you can't tell what kind of CPU they're using, or where their system drive is. Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- 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] getting $_ENV variables
Daniel Brown wrote: I guess I really didn't understand that myself before either. So Richard, even though it's disabling data output, it still exists as an array? The array ($_ENV) exists, it is just the population of it that has been disabled, thus it's empty. Just in the same way that doing a print_r($_GET) will always display an empty array even if the query string is totally blank, or print_r($_POST) does the same, even though you didn't post a thing to the script. The super-globals I guess must just be created at run-time, and populated later on in the process, by which time the php.ini settings have been taken into account and stopped the action. Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] One class, many methods: PHP4.x: Q's
Micky Hulse wrote: I have a class called Randimg. Within that class, I have several methods. Within a few of those methods, I use the below code snippet: $_SERVER['DOCUMENT_ROOT'] What would be the best way to assign the above code to a global variable/constant within the class? Within the constructor for Randimg you could set a local protected variable: class Randimg { var $docroot = false; function Randimg () { $this-docroot = $_SERVER['DOCUMENT_ROOT']; } and then you can just reference $this-docroot from any of the Randimg methods. In PHP 5 could you create $docroot as a protected class constant, but in PHP 4 the above will have to do. Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting $_ENV variables
2007. 05. 10, csütörtök keltezéssel 16.05-kor C.R.Vegelin ezt írta: Yes, my PHPinfo shows under configuration: variables_order = GPCS I will test EGPCS setting in php.ini But that also means that code using $_ENV cannot be run with hosts hiding the environment settings ?! And I assume that EGPCS will also affect: ?php print_r($_FILES); ? Now with GPCS this script shows also only: Array ( ) So also potential problems with $_FILES with hosts hiding the environment settings ?! $_FILES is only available when you upload a file to the script with a form whose enctype is set to multipart/form-data otherwise it is empty of course I think this has nothing to do with $_ENV and the above situation... greets Zoltán Németh Regards, Cor - Original Message - From: Richard Davey [EMAIL PROTECTED] To: [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, May 10, 2007 2:44 PM Subject: Re: [PHP] getting $_ENV variables Daniel Brown wrote: If it's suggesting that it's an array, that's a little baffling, because that means there are multiple entries (at least two), but they appear to either be null or otherwise unable to display. The $_ENV superb-global contains an array of environment settings, so it's not totally baffling that print_r() on it should return an array. The reason it is empty is because the variables_order setting in the php.ini has had it disabled. The default is: variables_order = EGPCS But it must have been changed to: variables_order = GPCS Dropping the E (Environment variables) will cause a print_r($_ENV) to be totally empty. Some hosts do this in order to hide the environment settings because they can contain sensitive information such as the CPU identifiers, etc. I've seen the 'cheaper' hosts (especially those hosting on Windows and/or Virtual Servers) disable this so you can't tell what kind of CPU they're using, or where their system drive is. Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- 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] One class, many methods: PHP4.x: Q's
On 5/10/07, Micky Hulse [EMAIL PROTECTED] wrote: Hi, This might be a real obvious question/answer... but I have been up all night geeking on code, so my mind is kinda mushy -- please be kind. :) I have a class called Randimg. Within that class, I have several methods. Within a few of those methods, I use the below code snippet: $_SERVER['DOCUMENT_ROOT'] What would be the best way to assign the above code to a global variable/constant within the class? Also, within each method, I am returning error strings... I would like to create these as class constants... Or something... What is best way to setup static strings within my class? Basically, I would like to have these strings at the top of my class so potential users can easily change the settings. ;) Lol, sorry is stpid questions... I am still kinda new to PHP OOP. Many TIA's! Cheers, Micky -- Wishlists: http://snipurl.com/1gqpj Switch: http://browsehappy.com/ BCC?: http://snipurl.com/w6f8 My: http://del.icio.us/mhulse -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php As Rich pointed out you cannot have constants within a class in PHP4. To answer the second part of your mail, one technique that I have seen is something like the code below. define('FOO_FILE_NOT_FOUND', 1); define('FOO_FILE_NOT_READABLE', 2); define('FOO_FILE_INVALID PATH', 2); class Foo { function render() { if (! is_readable(...)) { return FOO_FILE_NOT_READABLE; } } } Another way that is nice is Solar's way of handling locales. Basically it uses strings such as 'SOME_ERROR_MESSAGE' which is populated by an include file that contains the actual value to it. So in this include file you create an array that contains key value pairs of error codes and error messages. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] One class, many methods: PHP4.x: Q's
Hi Rich! Thanks for the quick reply. I really appreciate your help. :) Richard Davey wrote: In PHP 5 could you create $docroot as a protected class constant, but in PHP 4 the above will have to do. Ahhh! Very interesting. Many thanks for the code example and explanation -- that approach works for me. I assume setting basic strings (i.e. settings) for my error messages would be best done via: class Randimg { var $msg_1 = 'This is a string'; var $msg_2 = 'This is another string'; function rand_img() { echo $this-msg_1; } function foo() { echo $this-msg_2; } } It just seems so extraneous to declare those strings as vars... A class constant sounds like the best approach. I can't wait to start using PHP5! :D Thanks again Rich! I really appreciate your time and expertise. Have a great day and/or night. Cheers, Micky -- Wishlists: http://snipurl.com/1gqpj Switch: http://browsehappy.com/ BCC?: http://snipurl.com/w6f8 My: http://del.icio.us/mhulse -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting $_ENV variables
C.R.Vegelin wrote: Yes, my PHPinfo shows under configuration: variables_order = GPCS I will test EGPCS setting in php.ini But that also means that code using $_ENV cannot be run with hosts hiding the environment settings ?! Correct. Sucks I know, but some hosts just do this. And I assume that EGPCS will also affect: ?php print_r($_FILES); ? No, $_FILES isn't part of the Environment list, it's created again at run-time when a file upload occurs. It would be worth running a test to see if they have tied it to the $_POST array, i.e. remove the 'P' from EGPCS and see if $_FILES gets lost with it. I would be curious to know, although I can't think of a single host that would be stupid enough to disable $_POST :) Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] One class, many methods: PHP4.x: Q's
Hi Eric! Thanks for the fast reply. I really appreciate the help on this one. :D Eric Butera wrote: As Rich pointed out you cannot have constants within a class in PHP4. To answer the second part of your mail, one technique that I have seen is something like the code below. Ahhh, that is interesting! Thanks for sharing the code snippet. I think I may head this direction. :) Another way that is nice is Solar's way of handling locales. Basically it uses strings such as 'SOME_ERROR_MESSAGE' which is populated by an include file that contains the actual value to it. So in this include file you create an array that contains key value pairs of error codes and error messages. Oh, wow! That sounds interesting... I am going to catch some zzZZzz's and read-up on this in the morning. :D Ahhh, and it looks like a cool framework too: http://solarphp.com/ I may have to dip-into that. I have yet to try a PHP framework. Django was pretty fun, but I think I would have more fun with a PHP framework. :) Anyway, thanks a billion for sharing different approaches, it is great to hear how the pros deal with such things. Have a great day and/or night. Cheers, Micky -- Wishlists: http://snipurl.com/1gqpj Switch: http://browsehappy.com/ BCC?: http://snipurl.com/w6f8 My: http://del.icio.us/mhulse -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] One class, many methods: PHP4.x: Q's
Micky Hulse wrote: I assume setting basic strings (i.e. settings) for my error messages would be best done via: class Randimg { var $msg_1 = 'This is a string'; var $msg_2 = 'This is another string'; function rand_img() { echo $this-msg_1; } function foo() { echo $this-msg_2; } } I don't know if that's the *best* way, personally I'd not really do it like that, but no-one can tell you it is 'right' or 'wrong' because it depends on your application. For example if you only have a handful of possible error messages (say 10) then there is nothing inherently wrong with the above approach. If you're talking about lots of error messages then under PHP 4 I'd declare them as consts in a required() file. define('APP_ERROR_1', 'This is an error message'); Then just use APP_ERROR_1 in the methods that need it. It's a bit messy because you are creating consts all over the place, but it's an option for you and at least it keeps them all in a single file and out of the header of your class. Another way might be to create a specific class that does nothing but handle error messages / responses, then call that. Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting $_ENV variables
Okay, I will use getenv() and keep variables_order = GPCS in php.ini Thanks all and with regards, Cor - Original Message - From: Richard Davey [EMAIL PROTECTED] To: [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, May 10, 2007 3:34 PM Subject: Re: [PHP] getting $_ENV variables C.R.Vegelin wrote: Yes, my PHPinfo shows under configuration: variables_order = GPCS I will test EGPCS setting in php.ini But that also means that code using $_ENV cannot be run with hosts hiding the environment settings ?! Correct. Sucks I know, but some hosts just do this. And I assume that EGPCS will also affect: ?php print_r($_FILES); ? No, $_FILES isn't part of the Environment list, it's created again at run-time when a file upload occurs. It would be worth running a test to see if they have tied it to the $_POST array, i.e. remove the 'P' from EGPCS and see if $_FILES gets lost with it. I would be curious to know, although I can't think of a single host that would be stupid enough to disable $_POST :) Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- 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] One class, many methods: PHP4.x: Q's
Richard Davey wrote: I don't know if that's the *best* way, personally I'd not really do it like that, but no-one can tell you it is 'right' or 'wrong' because it ...snip... Perfect answer! Thanks! I do not have too many error messages to store, but I do like the constant approach... Looks like I have a bit of testing to do tomorrow (brain is mush atm.) Thanks again Rich and Eric. :) Cheers, M -- Wishlists: http://snipurl.com/1gqpj Switch: http://browsehappy.com/ BCC?: http://snipurl.com/w6f8 My: http://del.icio.us/mhulse -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] WSDL Generator class
Hello all, I'am looking for an WSDL generator class. The aim is to generate an wsdl file to use with the soap extension. The generator will look at the included classes and print all functions (except maybe abstract or private) in a correct xml format. I tried this one which is great : http://www.schlossnagle.org/~george/blog/index.php?/archives/234-WSDL-Generation.htmlbut i have to modify a lot of code and it appears it's not maintained. So what do you do in order to create WSD? Is the soap extension or a PEAR classes will include this kind of function? Thanks Brice
Re: [PHP] Re: Upload problem - final size is different
Thank you all for your tips and solutions !! I use chmod and my upload form works fine ;) Eric Le 2007-05-09 à 10:23, Daniel Brown a écrit : PHP has two functions that may help you here, Eric --- chmod() and chown(). http://php.net/chmod http://php.net/chown It should be enough to chmod($filename,0644); the file if it's just an image, or chmod($filename,0755); the file if it's a script. On 5/9/07, Eric Trahan [EMAIL PROTECTED] wrote: After some other tests, I think the problem is with the rights of the file. I made tests on my personnal Mac that runs Apache/1.3.33 (Darwin) PHP/ 4.4.4. Settings in PHP: file_uploads: On upload_tmp_dir: no value (so it uploads in /var/tmp/) upload_max_filesize: 2M My destination folder is page5, same as my server (everyone can read and write). But when the files are droped in that folder, with the move_uploaded_file function, the owner is www and group is wheel. So I can't open it... But when I change the rights on the file, I can the see the images. Is there a way to change the owner or the group of a file in PHP. Eric Le 2007-05-08 à 17:52, itoctopus a écrit : Have you tried your code on another server? -- itoctopus - http://www.itoctopus.com Eric Trahan [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, I have a form to upload file on my web server, so user can upload their images. The upload work. The user file is uploaded to my destination folder (page5/) but the file is unreadable and the file size is smaller than the original file size. I run Apache with PHP 4.1.2. Thank you, Eric. Here is the form code: form enctype=multipart/form-data action=fileupload_bd.php method=post input type=hidden name=MAX_FILE_SIZE value=10 / Une imagebr/input type=file name=uneimage / br/br/Du texte: input type=text name=untexte / br/br/input type=submit / /form Here is my PHP upload code: ?php echo $_POST['untexte'] . br/br/; $tmp_name = $_FILES['uneimage']['tmp_name']; $type = $_FILES['uneimage']['type']; $name = $_FILES['uneimage']['name']; $size = $_FILES['uneimage']['size']; echo $tmp_name . br/ . $type . br/ . $name . br/; $target_path = page5/; $target_path = $target_path . basename( $_FILES['uneimage'] ['name']); echo $target_path; if(move_uploaded_file($_FILES['uneimage']['tmp_name'], $target_path)) { echo The file . basename( $_FILES['uneimage']['name']). has been uploaded; } else{ echo There was an error uploading the file, please try again!; } ? -- 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 -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] scrolling HTML tables
I hope it's not the wrong place to ask, but has anyone experience with scrolling HTML tables ? According http://www.w3schools.com/tags/tag_thead.asp The thead, tfoot and tbody elements enable you to group rows in a table. When you create a table, you might want to have a header row, some rows with data, and a row with totals at bottom. This division enables browsers to support scrolling of table bodies independently of the table header and footer. I don't want to reinvent the wheel in own software. Or is it better to ignore these tags because of bad browser support ? Thanks, Cor
Re: [PHP] scrolling HTML tables
That's a CSS question, Cor. Check the web for the CSS property overflow. On 5/10/07, C.R.Vegelin [EMAIL PROTECTED] wrote: I hope it's not the wrong place to ask, but has anyone experience with scrolling HTML tables ? According http://www.w3schools.com/tags/tag_thead.asp The thead, tfoot and tbody elements enable you to group rows in a table. When you create a table, you might want to have a header row, some rows with data, and a row with totals at bottom. This division enables browsers to support scrolling of table bodies independently of the table header and footer. I don't want to reinvent the wheel in own software. Or is it better to ignore these tags because of bad browser support ? Thanks, Cor -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107
Re: [PHP] scrolling HTML tables
C.R.Vegelin wrote: I hope it's not the wrong place to ask, but has anyone experience with scrolling HTML tables ? It's not really a PHP question, and while personally I don't care, you ought to keep on-topic to avoid retribution from the if it isn't PHP, it shouldn't be talked about list nazis. According http://www.w3schools.com/tags/tag_thead.asp The thead, tfoot and tbody elements enable you to group rows in a table. When you create a table, you might want to have a header row, some rows with data, and a row with totals at bottom. This division enables browsers to support scrolling of table bodies independently of the table header and footer. Sadly no browser works like this. You have to remember that the W3C recommendations are just that, recommendations, as to how the client should render the controls. I don't know of any browser that will automatically keep a table header/footer inline and allow only the scrolling of the content region. Mind you, I've never seen a browser allow for pop-out rendering of select list optgroups either. In short, you'll need to fake it, and CSS is your friend in this regard. So best to ask on a dedicated CSS list. Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: session cookies enabled?
Mike, Thanks for the super clear explanation. This brings up a question. In order to decide whether to use cookies or SID the built-in sessions must be testing to see if the user's browser will accept the session cookies. How do they do that? By sending it out and checking to see whether it comes back on the next page. ... That being the case I can never find out (using the built-in sessions) until the second page request and it will always include the session cookie in the URL. Which means the value of the seesion cookie will be exposed, even if I am using SSL. :( Back to the drawing board... Best, Craig -- - Virtual Phonecards - Instant Pin by Email - - Large Selection - Great Rates- - http://speedypin.com/?aff=743co_branded=1 - -- ** ** * Craig Spencer * * [EMAIL PROTECTED]* ** ** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: session cookies enabled?
[EMAIL PROTECTED] wrote: That being the case I can never find out (using the built-in sessions) until the second page request and it will always include the session cookie in the URL. Which means the value of the seesion cookie will be exposed, even if I am using SSL. :( Back to the drawing board... While using TRANS IDs are ugly, they will show no more or less information to the user than a session cookie contains. Most browsers have built-in support for viewing cookie contents these days. Doing so will show your PHP Session ID clearly. Trans IDs are no different, just more 'obvious' being in the URL and all. The actual data displayed is the same however. Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: session cookies enabled?
On May 10, 2007, at 11:40 AM, Richard Davey wrote: [EMAIL PROTECTED] wrote: That being the case I can never find out (using the built-in sessions) until the second page request and it will always include the session cookie in the URL. Which means the value of the seesion cookie will be exposed, even if I am using SSL. :( Back to the drawing board... While using TRANS IDs are ugly, they will show no more or less information to the user than a session cookie contains. Most browsers have built-in support for viewing cookie contents these days. Doing so will show your PHP Session ID clearly. Trans IDs are no different, just more 'obvious' being in the URL and all. The actual data displayed is the same however. And the session id is open to being stored in a bookmark or worse, sent to someone else through a cut and paste of the URL. Depending on what information that id controls and how long the sessions are kept around id's in the URL could be a very bad thing indeed. Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: session cookies enabled?
Edward Vermillion wrote: And the session id is open to being stored in a bookmark or worse, sent to someone else through a cut and paste of the URL. Depending on what information that id controls and how long the sessions are kept around id's in the URL could be a very bad thing indeed. Agreed (depending entirely on how your app was written), my point was simply that a trans ID will never give away anything more than a cookie does. In that respect, they're identical. Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] sorting via PHP or MySQL?
(I've cross posted at the MySQL list as well) Here's an example with a simple table: describe collection; +--+-+--+- +-++ | Field| Type| Null | Key | Default | Extra | +--+-+--+- +-++ | id | bigint(20) unsigned | | PRI | NULL| auto_increment | | receiver_id | bigint(20) unsigned | | MUL | 0 || | set_type_id | int(2) unsigned | | | 0 || | card_id | int(3) unsigned | | | 0 || | completed_set_id | bigint(20) unsigned | | | 0 || | created_on_gmt | datetime| | | -00-00 00:00:00 || +--+-+--+- +-++ I want to end up with two PHP arrays. One for set_type_id = 22 and one for set_type_id=21. (1) one query method: SELECT * from collection WHERE set_type_id=22 OR set_type_id=21; ...do query... while( $row = $this-db-fetch_array_row() ){ if ($row['set_type_id'] == 21){ $array_a[] = $row; } else { $array_b[] = $row; } } (2) two query method: SELECT * from collection WHERE set_type_id=22; ...do query... while( $row = $this-db-fetch_array_row() ){ $array_a[] = $row; } SELECT * from collection WHERE set_type_id=21; ...do query... while( $row = $this-db-fetch_array_row() ){ $array_b[] = $row; } Which method is better? Take a hit using MySQL or take a hit using PHP? -James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] sorting via PHP or MySQL?
James Tu wrote: (I've cross posted at the MySQL list as well) Here's an example with a simple table: describe collection; +--+-+--+- +-++ Field| Type| Null | Key | Default | Extra | +--+-+--+- +-++ id | bigint(20) unsigned | | PRI | NULL| auto_increment | receiver_id | bigint(20) unsigned | | MUL | 0 || set_type_id | int(2) unsigned | | | 0 || card_id | int(3) unsigned | | | 0 || completed_set_id | bigint(20) unsigned | | | 0 || created_on_gmt | datetime| | | -00-00 00:00:00 || +--+-+--+- +-++ I want to end up with two PHP arrays. One for set_type_id = 22 and one for set_type_id=21. (1) one query method: SELECT * from collection WHERE set_type_id=22 OR set_type_id=21; ...do query... while( $row = $this-db-fetch_array_row() ){ if ($row['set_type_id'] == 21){ $array_a[] = $row; } else { $array_b[] = $row; } } (2) two query method: SELECT * from collection WHERE set_type_id=22; ...do query... while( $row = $this-db-fetch_array_row() ){ $array_a[] = $row; } SELECT * from collection WHERE set_type_id=21; ...do query... while( $row = $this-db-fetch_array_row() ){ $array_b[] = $row; } Which method is better? Take a hit using MySQL or take a hit using PHP? -James I really don't think you'd notice any difference, unless your table contains a large amount of data and is not properly indexed. And if that were the case, you'd notice a hit on just one query anyway. I'd stick with the 2 query model, but instead of creating arrays, just loop through the query results to output your data, no sense looping to make an array when you're just going to end up looping through the array to output; that seems redundant to me :P Just my $.02 -B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sorting via PHP or MySQL?
On Thu, 2007-05-10 at 14:00 -0400, James Tu wrote: (I've cross posted at the MySQL list as well) Here's an example with a simple table: describe collection; +--+-+--+- +-++ | Field| Type| Null | Key | Default | Extra | +--+-+--+- +-++ | id | bigint(20) unsigned | | PRI | NULL| auto_increment | | receiver_id | bigint(20) unsigned | | MUL | 0 || | set_type_id | int(2) unsigned | | | 0 || | card_id | int(3) unsigned | | | 0 || | completed_set_id | bigint(20) unsigned | | | 0 || | created_on_gmt | datetime| | | -00-00 00:00:00 || +--+-+--+- +-++ I want to end up with two PHP arrays. One for set_type_id = 22 and one for set_type_id=21. (1) one query method: SELECT * from collection WHERE set_type_id=22 OR set_type_id=21; ...do query... while( $row = $this-db-fetch_array_row() ){ if ($row['set_type_id'] == 21){ $array_a[] = $row; } else { $array_b[] = $row; } } (2) two query method: SELECT * from collection WHERE set_type_id=22; ...do query... while( $row = $this-db-fetch_array_row() ){ $array_a[] = $row; } SELECT * from collection WHERE set_type_id=21; ...do query... while( $row = $this-db-fetch_array_row() ){ $array_b[] = $row; } Which method is better? Take a hit using MySQL or take a hit using PHP? Single query method is superior in your example. 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
[PHP] GET variable unexpectedly assigned to session variable
Let's try to make a long story short. I'm writing a (not too complex) system visible to authorized users only. My users are stored in a MySQL database table with usr_id and usr_typ (user type) among other fields. When a user logs in, I retrieve those values from the database and store them into separate session variables: $_SESSION[usr_id] = $rs[usr_id]; $_SESSION[usr_typ] = $rs[usr_typ]; When the user visits a restricted page, I read those session variables to validate the user. So far so good. Problem started when I added a new script named usr_frm.php. This page accepts the user's id and type from the query string, like this: $id = (integer)$HTTP_GET_VARS[id]; $usr_typ = (integer)$HTTP_GET_VARS[typ]; The call comes from a list of users displayed by another script, usr_lst.php, like this (within a loop, of course): print(a href='usr_frm.php?id=.$row[usr_id].typ=.$row[usr_typ].'); Problem is, that, once the page usr_frm.php have been hit, the session variable $_SESSION[usr_type] gets changed (unexpectedly) to exactly the same value passed to the script via GET variable typ. But even worse: this code works perfectly well on my developer machine (Windows) but in doesn't on the actual server (Linux). I realized that the server uses a different PHP configuration, specially: register_globals set to ON. I already got them to change this value to OFF... but this did not solve the problem. I will appreciate any help, suggestion, idea currently I am (honestly) clue less... Thank you in advance. --Armando--.
Re: [PHP] GET variable unexpectedly assigned to session variable
On Thu, 2007-05-10 at 14:51 -0400, Armando Acosta wrote: Let's try to make a long story short. I realized that the server uses a different PHP configuration, specially: register_globals set to ON. I already got them to change this value to OFF... but this did not solve the problem. I will appreciate any help, suggestion, idea currently I am (honestly) clue less... Did they restart the webserver after changing the config? BTW, what's the point of abbreviating short words like user to usr and type to typ? 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] GET variable unexpectedly assigned to session variable
Armando; First, you can just change these: $id = (integer)$HTTP_GET_VARS[id]; $usr_typ = (integer)$HTTP_GET_VARS[typ]; to: $id = $_GET['id']; $usr_typ = $_GET['typ']; Second, I see that you're using $row[] variables for your MySQL result sets but where and how are the $rs[] values populated? On 5/10/07, Robert Cummings [EMAIL PROTECTED] wrote: On Thu, 2007-05-10 at 14:51 -0400, Armando Acosta wrote: Let's try to make a long story short. I realized that the server uses a different PHP configuration, specially: register_globals set to ON. I already got them to change this value to OFF... but this did not solve the problem. I will appreciate any help, suggestion, idea currently I am (honestly) clue less... Did they restart the webserver after changing the config? BTW, what's the point of abbreviating short words like user to usr and type to typ? 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 -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107
Re: [PHP] GET variable unexpectedly assigned to session variable
Another small and unrelated point - you don't need to use double quotes inside the array brackets - you're not processing them at all.
[PHP] PHP sorting csv array output
Hello all, I have a question concerning .CSV array sorting. I have tried googling for an answer and have tried different techniques, but nothing seems to works as I would like it to work. Here is my situation: Test file is located here: http://veanndesign.com/test.php I would like to be able to sort the output by the Time Zone (or any other fields). Here is how my code looks like: http://veanndesign.com/test.html I believe that I need to get all the data from the .csv file dumped into 1 array, and I guess I am struggling at that point. I have tried using foreach inside of the while loop, but it doesn't seem to work. So what is the best and/or right way to sort this type of data? Hopefully, this email makes sense. Thanks in advance. -- Anna Vester Web Designer http://www.veanndesign.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP sorting csv array output
One place to start reading, Anna, would be the PHP manual for the fgetcsv() function, which is specifically for CSV parsing. http://www.php.net/fgetcsv On 5/10/07, Anna Vester [EMAIL PROTECTED] wrote: Hello all, I have a question concerning .CSV array sorting. I have tried googling for an answer and have tried different techniques, but nothing seems to works as I would like it to work. Here is my situation: Test file is located here: http://veanndesign.com/test.php I would like to be able to sort the output by the Time Zone (or any other fields). Here is how my code looks like: http://veanndesign.com/test.html I believe that I need to get all the data from the .csv file dumped into 1 array, and I guess I am struggling at that point. I have tried using foreach inside of the while loop, but it doesn't seem to work. So what is the best and/or right way to sort this type of data? Hopefully, this email makes sense. Thanks in advance. -- Anna Vester Web Designer http://www.veanndesign.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107
Re: [PHP] PHP sorting csv array output
On 5/10/07, Daniel Brown [EMAIL PROTECTED] wrote: One place to start reading, Anna, would be the PHP manual for the fgetcsv() function, which is specifically for CSV parsing. http://www.php.net/fgetcsv Thanks for your quick reply Daniel. Yes I've seen that function before and i am using it to parse the file, which displays fine. I just need to be able to sort that data (by Time Zone) prior to displaying. Sorry If I wasn't clear. Thanks. -- Anna Vester Web Designer http://www.veanndesign.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP sorting csv array output
When you load your data into your array, you can use the timezone (or whatever field you're using to sort) as the array key, then use ksort(). Check the see also for a bunch of other types of sorting you can do. When it comes to the multisorts and user defined sorts, I'm at a bit of a loss..hah.. just never had to use them so they're still a bit mystical to me. -TG http://us2.php.net/manual/en/function.ksort.php = = = Original message = = = On 5/10/07, Daniel Brown [EMAIL PROTECTED] wrote: One place to start reading, Anna, would be the PHP manual for the fgetcsv() function, which is specifically for CSV parsing. http://www.php.net/fgetcsv Thanks for your quick reply Daniel. Yes I've seen that function before and i am using it to parse the file, which displays fine. I just need to be able to sort that data (by Time Zone) prior to displaying. Sorry If I wasn't clear. Thanks. -- Anna Vester Web Designer http://www.veanndesign.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Need a new shared host with php
I'm looking for a shared host with an up-to-date php5, and one who at least tries to keep it relatively current. Needs are modest. Just need good ftp access, cgi-bin, shell, etc. Any suggestions. I'm looking at Host Monster, anyone have experience with them? Thanks... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] sqlite if query changes to empty on a loop
Hello, I have a loop on an sqlite query which checks $domain until the status of $domain changes and then it deletes $domain. However when all the $domain items have been deleted I need the script to stop.. regardless of how many querys the loop still has to run. So I want to detect when its empty and then stop. I have this... which does not work. ? $db = sqlite_open(whois.sqlite); $x = 0; while ($x 9000) { $result = sqlite_query($db, SELECT * FROM whois ORDER BY id); // if (!$result) { if (empty($result)) { echo No data; } else { while ($row = sqlite_fetch_array($result)) { $domain = $row['name']; echo $domain; $x++; usleep(40); } } } sqlite_close($db); ? Thanks Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need a new shared host with php
Al wrote: I'm looking for a shared host with an up-to-date php5, and one who at least tries to keep it relatively current. Needs are modest. Just need good ftp access, cgi-bin, shell, etc. Any suggestions. I'm looking at Host Monster, anyone have experience with them? Thanks... Check out http://www.webhostingtalk.com for both discussions and searching on any possible hosts before signing up. If you can stretch your budget a bit more, go for a VPS. Shared hosting is a real pain when other users write poor code that hog the server. I use ServInt and would recommend them. Edward -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need a new shared host with php
Edward Kay wrote: Al wrote: I'm looking for a shared host with an up-to-date php5, and one who at least tries to keep it relatively current. Needs are modest. Just need good ftp access, cgi-bin, shell, etc. Any suggestions. I'm looking at Host Monster, anyone have experience with them? Thanks... I use host monster for last year and never had a problem with them. Have one account with 8 domains/web sites. None has big traffic. Though, one of web sites is my personal site with Gallery2 installed. When uploading chunk of 10 or 20 images (king size) after is DONE I would get a message that I'm using processor more then I could and it will keep me out for couple minutes before I can continue. Though, my web site is still up, just I can't do anything. And, every time whole process was finished without interruption or with error. Strange thing (never had similar before) but it doesn't bother me a lot. Agree with Edward, VPS is better solution - if possible. I used pair.com for a while. Pricey but VERY GOOD. -afan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need a new shared host with php
Al wrote: I'm looking for a shared host with an up-to-date php5, and one who at least tries to keep it relatively current. Needs are modest. Just need good ftp access, cgi-bin, shell, etc. Any suggestions. I'm looking at Host Monster, anyone have experience with them? Thanks... I've used http://phpwebhosting.com for several years, they're quite good, and for $10/month they offer what you're looking for. They're stuck on php 5.12, though. I know a guy who knows the guy behind http://dataslab.com. That seems like a pretty darn good deal($20/month), though I've not really researched the VPS market. Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP MySQL
Hi Everyone, I know this isn't strictly a PHP question, and I apologize in advance for that. I'm trying to setup a website for some of my customers that would allow them to update a database on their schedule, making it easier for us to have the most up to date info, and taking some of the work off of us. Right now, the question I have is, how would I be able to select certain records to be deleted (Or moved to another table called deleted)? Is it as simple as looping through the database, having them check a checkbox, and then hit a remove button? As I go, I will be adding a login screen to it, and hopefully protecting against SQL injection attacks... But right now, I'm still just learning and trying. The SQL syntax is easy enough for me to figure out, but the php is throwing me off right now... I'm running PHP 5.2.0 MySQL 5.0.24A Any points to the right documents are greatly appreciated as well as sample code :) Currently here is the code I'm working with on the page to display it: $link = mysql_connect($server, $username, $password) or die('Could not connect: ' . mysql_error()); echo 'Connected successfully BR'; mysql_select_db('legion') or die('Could not select database' . mysql_error()); echo 'DB selected BR'; $result = mysql_query(SELECT * FROM current) or die(mysql_error()); while($row = mysql_fetch_array($result)) { $FName = $row[FName]; $LName = $row[LName]; $Add1 = $row[Add1]; $Add2 = $row[Add2]; $City = $row[City]; $State = $row[State]; $Zip = $row[Zip]; $Date = $row[Date]; echo $FName, $LName, $Add1, $Add2, $City, $State, $Zip, $DateBR; }; I'm sure there is an easier way to do that as well... But this way worked :) Jason -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need a new shared host with php
Afan Pasalic wrote: Edward Kay wrote: Al wrote: I'm looking for a shared host with an up-to-date php5, and one who at least tries to keep it relatively current. Needs are modest. Just need good ftp access, cgi-bin, shell, etc. Any suggestions. I'm looking at Host Monster, anyone have experience with them? Thanks... I use host monster for last year and never had a problem with them. Have one account with 8 domains/web sites. None has big traffic. Though, one of web sites is my personal site with Gallery2 installed. When uploading chunk of 10 or 20 images (king size) after is DONE I would get a message that I'm using processor more then I could and it will keep me out for couple minutes before I can continue. Though, my web site is still up, just I can't do anything. And, every time whole process was finished without interruption or with error. Strange thing (never had similar before) but it doesn't bother me a lot. Agree with Edward, VPS is better solution - if possible. I used pair.com for a while. Pricey but VERY GOOD. -afan You might want to look at Canadawebhosting.com. It's located in Vancuver and Toronto. If you pay in $US you get the advantage of the higher US dollar. It's an excellent service for VPS and stand-alone server access. I've used them for both over a period of about 4 years. -- _ Myron Turner http://www.room535.org http://www.bstatzero.org http://www.mturner.org/XML_PullParser/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need a new shared host with php
Al wrote: I'm looking for a shared host with an up-to-date php5, and one who at least tries to keep it relatively current. Needs are modest. Just need good ftp access, cgi-bin, shell, etc. I'll throw my plug in here for Pair Networks too. Sure, you can get cheaper, but they run a really tight ship there - great network, great servers, great support. Have been with them since 1996 (!!) and they've been brilliant all this time and I've now plans on leaving. They're about to roll-out PHP 5.2.2 across all of their servers too. And if their 'usual' accounts are too expensive, they've just launched this: http://www.pairlite.com Which is only $10 / month and I'd wager perfect for what you need. Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Scalable Site Architecture
Hi Bruce, In looking for what's required fo a site, I'm trying to find docs/overview/mentors to talk to/etc You can read all about it from one of the world's leading scalability experts: http://www.amazon.com/Scalable-Internet-Architectures-Developers-Library/dp/067232699X Disclaimer: I work with the author. Chris -- Chris Shiflett http://shiflett.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Scalable Site Architecture
hey chris... thanks for the reply. can you tell me if the author (your friend) has thought of releasing a complete suite of code/source that would actually demonstrate an entire app. i'm talking about website, admin function/site, database function/systems, load balancing apps, etc thanks -bruce [EMAIL PROTECTED] -Original Message- From: Chris Shiflett [mailto:[EMAIL PROTECTED] Sent: Thursday, May 10, 2007 2:49 PM To: [EMAIL PROTECTED] Cc: php-general@lists.php.net Subject: Re: [PHP] Scalable Site Architecture Hi Bruce, In looking for what's required fo a site, I'm trying to find docs/overview/mentors to talk to/etc You can read all about it from one of the world's leading scalability experts: http://www.amazon.com/Scalable-Internet-Architectures-Developers-Library/dp/ 067232699X Disclaimer: I work with the author. Chris -- Chris Shiflett http://shiflett.org/ -- 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] WSDL Generator class
I'm no big fan of SOAP and certainly think it's silly that I have to use like 8 million lines of WSDL to describe a 20 line function in PHP. I don't know WSDL - at all - don't want to know it -- shouldn't have to know it. Grrr. Sadly I had the same frustrating experience you did and ultimately ended up using this WSDL_Gen tool too. What do you have to modify? It worked fine for me for int, float, string, and array -- although it's kinda wonkey with a hash as it turns it into an array -- well something does. G. Not sure if that's a SOAP feature or a bug or what. All the other solutions (for lack of a better term) required just as much messaging to even get going. WSDL_Gen was quick and dirty and got my app up and running in a few hours. We use Ruby to talk to PHP5 via SOAP. I wish PHP had a generator built in, or there was a better tool actively being developed. Daevid. There are two kinds of people in this world. Top posters and bottom posters. -Original Message- From: Brice [mailto:[EMAIL PROTECTED] Sent: Thursday, May 10, 2007 8:10 AM To: PHP General List Subject: [PHP] WSDL Generator class Hello all, I'am looking for an WSDL generator class. The aim is to generate an wsdl file to use with the soap extension. The generator will look at the included classes and print all functions (except maybe abstract or private) in a correct xml format. I tried this one which is great : http://www.schlossnagle.org/~george/blog/index.php?/archives/2 34-WSDL-Generation.htmlbut i have to modify a lot of code and it appears it's not maintained. So what do you do in order to create WSD? Is the soap extension or a PEAR classes will include this kind of function? Thanks Brice -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP on the AS400 (now i5)
Just curious if anybody else is using Zend's PHP port on an AS400/iSeries/i5? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] One class, many methods: PHP4.x: Q's
Richard Davey wrote: Within the constructor for Randimg you could set a local protected variable: class Randimg { var $docroot = false; function Randimg () { $this-docroot = $_SERVER['DOCUMENT_ROOT']; } Hi Rich and all, just one other quick question... Which approach below would you choose? Example 1: class Randimg { # Initialize var variables: var $foo1 = FALSE; var $foo2 = FALSE; var $foo3 = TRUE; # Constructor: function Randimg { $this-foo1 = TRUE; $this-foo2 = TRUE; $this-foo3 = FALSE; return $this-method_foo(); } function method_foo() { $x = $this-$foo1; $y = $this-$foo2; $z = $this-$foo3; /* Do stuff... */ return $x.$y.$z; } } Example 2: class Randimg { # Constructor: function Randimg { $foo1 = TRUE; $foo2 = TRUE; $foo3 = FALSE; return $this-method_foo($foo1, $foo2, $foo3); } function method_foo($x, $y, $z) { /* Do stuff... */ return $x.$y.$z; } } Hopefully my syntax is decent... I am guessing the approach I take depends on the needs of my script. Setting local protected variables seems like it would work well for my latest project, but is that bad programming practice to rely upon local protected variables when it comes to passing variables between methods? Seems like I have always read/heard that it is best to explicitly pass variables as function parameters... vs throwing around globals. Sorry if silly questions. :) Thanks again! Cheers, M -- Wishlists: http://snipurl.com/1gqpj Switch: http://browsehappy.com/ BCC?: http://snipurl.com/w6f8 My: http://del.icio.us/mhulse -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] reading private properties (print_r)
Hi, I dislike the output of print_r(), so I desited write my own print_r(). I need this funktion for debugging issues, and therfor it is nice to have the private attributs, which are normaly hidden. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] What is the best way to protect the PHP page that returns the AJAX data?
Like most sites, someone needs to join up to use mine. I'm using a wee-bit-o-AJAX to pull some results from a database and display them dynamically. For the AJAX to work, it has to hit a script that's accessible from the htdocs tree right? Effectively it's just a (JavaScript initiated) GET URL request correct? For example, index.html calls http://example.com/gimmedata.php?query=foo That in turn returns a JS formatted array which is eval() in JS and rendered on the page. (over simplified I know) My question is, how do you protect gimmedata.php since it's sitting out there sans normal web headers and stuff? Can it include session_start() and do all that wonderful checking to make sure the user is logged in before just happily doling out my precious data? What is the proper, secure, sanctioned and AJAX/PHP blessed way to do this? I could set up a test environment and hack up something I'm sure -- and probably will if I get too impatient, but nobody seems to address this issue in any examples, they just do it as if information is *gasp* free. I'm a PHP guru, but I am also an AJAX novice. From what I gather, the return is really in XML transport format and all the magic of converting to/from XML is transparent to me. I worry that putting other headers or whatever may corrupt that? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] One class, many methods: PHP4.x: Q's
Micky Hulse wrote: Seems like I have always read/heard that it is best to explicitly pass variables as function parameters... vs throwing around globals. Ah, well Chapter 6, page 144-145 have helped clear-up a little bit of my confusion: ...snip... Here's a simple class definition of the Person class that shows the $this variable in action: class Person { var $name; function get_name() { return $this-name; } function set_name($new_name) { $this-name = $new_name; } } As you can see, the get_name() and set_name() methods use $this to access and set the $name property of the current object. ...snip... Declaring Properties In the previous definition of the Person class, we explicityly declared the $name property. Property declaration are optional and are simply a courtesy to whoever maintains your program. It's good PHP style to declare your properties, but you can add new properties at any time. ...snip... You can assign default values to properties, but those default values must be simple constants: var $name = 'J Doe'; // Works var $age = 0; // Works var $day = 60*60*60; // Doesn't work. ...snip... So, I think I was getting a bit confused with the var variables... But now it looks like it is not bad practice to get and set object properties, and it almost sounds like it is good practice (though, not required) to declare these properties (var variables) for other eyeballs/programmers. Man, I love programming in PHP. I just wish I were better at it! :D K, gonna go practice some on these new techniques. Cheers, Micky -- Wishlists: http://snipurl.com/1gqpj Switch: http://browsehappy.com/ BCC?: http://snipurl.com/w6f8 My: http://del.icio.us/mhulse -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] One class, many methods: PHP4.x: Q's
Micky Hulse wrote: Ah, well Chapter 6, page 144-145 have helped clear-up a little bit of my confusion: Sorry, forgot to mention what book I was refering to: O'Reilly Programming PHP By Rasmus Lerdorf Kevin Tatroe http://snipurl.com/1k4ug -- Wishlists: http://snipurl.com/1gqpj Switch: http://browsehappy.com/ BCC?: http://snipurl.com/w6f8 My: http://del.icio.us/mhulse -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What is the best way to protect the PHP page that returns the AJAX data?
That's a humongous, humongous security risk there. What if someone goes http://example.com/gimmedata.php?query=DROP DATABASE hi? Unless I misunderstood. A better way would be in the script: switch ($_GET['query']) { case fetch: $dbquery = 'SELECT stuff FROM stuff'; break; case eatsnacks: $dbquery = 'SELECT snacks FROM edibles'; break; // ... } and fetch instead http://example.com/gimmedata.php?query=eatsnacks; On 5/10/07, Daevid Vincent [EMAIL PROTECTED] wrote: Like most sites, someone needs to join up to use mine. I'm using a wee-bit-o-AJAX to pull some results from a database and display them dynamically. For the AJAX to work, it has to hit a script that's accessible from the htdocs tree right? Effectively it's just a (JavaScript initiated) GET URL request correct? For example, index.html calls http://example.com/gimmedata.php?query=foo That in turn returns a JS formatted array which is eval() in JS and rendered on the page. (over simplified I know) My question is, how do you protect gimmedata.php since it's sitting out there sans normal web headers and stuff? Can it include session_start() and do all that wonderful checking to make sure the user is logged in before just happily doling out my precious data? What is the proper, secure, sanctioned and AJAX/PHP blessed way to do this? I could set up a test environment and hack up something I'm sure -- and probably will if I get too impatient, but nobody seems to address this issue in any examples, they just do it as if information is *gasp* free. I'm a PHP guru, but I am also an AJAX novice. From what I gather, the return is really in XML transport format and all the magic of converting to/from XML is transparent to me. I worry that putting other headers or whatever may corrupt that? -- 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] sorting via PHP or MySQL?
A somewhat more extensible version of the 1 query method: http://www.garfieldtech.com/blog/php-group-by If you will only ever have 2 values there, then either method is probably fine. The php group by method (above) is more extensible if you're going to have a variable or arbitrary number of groups, though. Cheers. On Thursday 10 May 2007, James Tu wrote: (I've cross posted at the MySQL list as well) Here's an example with a simple table: describe collection; +--+-+--+- +-++ | Field| Type| Null | Key | Default | Extra | +--+-+--+- +-++ | id | bigint(20) unsigned | | PRI | NULL| auto_increment | | receiver_id | bigint(20) unsigned | | MUL | 0 || | set_type_id | int(2) unsigned | | | 0 || | card_id | int(3) unsigned | | | 0 || | completed_set_id | bigint(20) unsigned | | | 0 || | created_on_gmt | datetime| | | -00-00 00:00:00 || +--+-+--+- +-++ I want to end up with two PHP arrays. One for set_type_id = 22 and one for set_type_id=21. (1) one query method: SELECT * from collection WHERE set_type_id=22 OR set_type_id=21; ...do query... while( $row = $this-db-fetch_array_row() ){ if ($row['set_type_id'] == 21){ $array_a[] = $row; } else { $array_b[] = $row; } } (2) two query method: SELECT * from collection WHERE set_type_id=22; ...do query... while( $row = $this-db-fetch_array_row() ){ $array_a[] = $row; } SELECT * from collection WHERE set_type_id=21; ...do query... while( $row = $this-db-fetch_array_row() ){ $array_b[] = $row; } Which method is better? Take a hit using MySQL or take a hit using PHP? -James -- 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] Need a new shared host with php
On Thursday 10 May 2007, Richard Davey wrote: Al wrote: I'm looking for a shared host with an up-to-date php5, and one who at least tries to keep it relatively current. Needs are modest. Just need good ftp access, cgi-bin, shell, etc. I'll throw my plug in here for Pair Networks too. Sure, you can get cheaper, but they run a really tight ship there - great network, great servers, great support. Have been with them since 1996 (!!) and they've been brilliant all this time and I've now plans on leaving. They're about to roll-out PHP 5.2.2 across all of their servers too. And if their 'usual' accounts are too expensive, they've just launched this: Where did you hear that? I'm a Pair customer of many many years myself, and I've been considering jumping ship because of their old PHP version (latest PHP 4, but still PHP 4). If they're going to be upgrading to a real PHP platform, that would kick ass. Now, if I could get APC without a dedicated box... :-) -- 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] What is the best way to protect the PHP page that returns the AJAX data? [solved]
Thanks for the suggestion and concern. Fear not, I'm a PHP Guru as mentioned. I never said that I execute the code directly like that. Perhaps my query keyname was a bit misleading. Would http://example.com/gimmedata.php?id=3foo=barmap=on have been more clear? I also am not so silly as to run unchecked variables into my SQL queries, nor do I not check for mismatched ' ; and other injection attempts in my database wrapper. ;-) Anyways none of that is the point. I wanted to know how to prevent a random person from hitting that same gimmedata.php using their own parameters (valid or not) Since I wrote this initial email, I've done some testing, and much to my glee, it seems they work just like any other page, so therefore putting a simple session_start() and testing if the user is logged in, etc is quite effective. d -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, May 10, 2007 8:28 PM To: Daevid Vincent Cc: php-general@lists.php.net Subject: Re: [PHP] What is the best way to protect the PHP page that returns the AJAX data? That's a humongous, humongous security risk there. What if someone goes http://example.com/gimmedata.php?query=DROP DATABASE hi? Unless I misunderstood. A better way would be in the script: switch ($_GET['query']) { case fetch: $dbquery = 'SELECT stuff FROM stuff'; break; case eatsnacks: $dbquery = 'SELECT snacks FROM edibles'; break; // ... } and fetch instead http://example.com/gimmedata.php?query=eatsnacks; On 5/10/07, Daevid Vincent [EMAIL PROTECTED] wrote: Like most sites, someone needs to join up to use mine. I'm using a wee-bit-o-AJAX to pull some results from a database and display them dynamically. For the AJAX to work, it has to hit a script that's accessible from the htdocs tree right? Effectively it's just a (JavaScript initiated) GET URL request correct? For example, index.html calls http://example.com/gimmedata.php?query=foo That in turn returns a JS formatted array which is eval() in JS and rendered on the page. (over simplified I know) My question is, how do you protect gimmedata.php since it's sitting out there sans normal web headers and stuff? Can it include session_start() and do all that wonderful checking to make sure the user is logged in before just happily doling out my precious data? What is the proper, secure, sanctioned and AJAX/PHP blessed way to do this? I could set up a test environment and hack up something I'm sure -- and probably will if I get too impatient, but nobody seems to address this issue in any examples, they just do it as if information is *gasp* free. I'm a PHP guru, but I am also an AJAX novice. From what I gather, the return is really in XML transport format and all the magic of converting to/from XML is transparent to me. I worry that putting other headers or whatever may corrupt that? -- 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] What is the best way to protect the PHP page that returns the AJAX data? [solved]
On Thu, 2007-05-10 at 21:23 -0700, Daevid Vincent wrote: Thanks for the suggestion and concern. Fear not, I'm a PHP Guru as mentioned. A Guru would have spent 60 seconds testing to see if the session_start() scenario worked BEFORE posting to the list :B 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
[PHP] finding next and prev record in mysql
How would I find the next id and the prev id in sql statement like the one below. The id number is not going to be in order so I can't do a or limit 1 on the search SELECT id FROM contacts WHERE category = '5' AND subcategory = '1' AND members_id= '8' ORDER BY lastname
Re: [PHP] finding next and prev record in mysql
Richard Kurth wrote: How would I find the next id and the prev id in sql statement like the one below. The id number is not going to be in order so I can't do a or limit 1 on the search SELECT id FROM contacts WHERE category = '5' AND subcategory = '1' AND members_id= '8' ORDER BY lastname Ask the mysql list: http://lists.mysql.com/ I'm sure they have been asked a similar thing many times in the past. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php