php-general Digest 2 Mar 2012 19:03:00 -0000 Issue 7710
php-general Digest 2 Mar 2012 19:03:00 - Issue 7710 Topics (messages 316834 through 316850): Re: Nested database loops and completing an unordered list 316834 by: Jay Blanchard 316840 by: Jim Lucas 316842 by: Bastien Koert 316843 by: Jay Blanchard 316849 by: Jay Blanchard 316850 by: Jim Lucas curl equivalent in PHP 316835 by: Nibin V M 316836 by: Marc Guay 316837 by: Nibin V M 316838 by: Nibin V M 316839 by: FeIn 316841 by: Jim Lucas 316844 by: Nibin V M 316845 by: Micky Hulse 316846 by: Daniel Brown 316848 by: Nibin V M problem about PHP-FPM in TCP socket and Unix socket 316847 by: Yuchen Wang Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- My usual approach to a problem like this to to includes a parent column in the table ID (int pk) Parent ( default null ) // no parent Item Itemtype [etc] Parent will then hold either a null if a top level item, or a structured path ( 1/10/24 ) that notes the parents of the item all the way up to the parent. That way, a single query will get you all items in that parent's lineage to whatever depth is needed by using the child's value Select * from table where parent = '1/10' Would retrieve all items that are children of a top level of 1 and a second level of 10 I would do that under normal circumstance but I cannot modify the client's table in any way shape or form. I am considering the COMPANY_ID to be the parent at this point and I can get all who belong to a company. I just need to turn that lineage into a tree.---End Message--- ---BeginMessage--- On 03/01/2012 06:20 PM, Jay Blanchard wrote: [snip] Can you show the output of the function above? [/snip] Doesn't this SQL query return everything that has company_id set to 3 which would it not contain all the data from the other queries combined into one large data set? At this point, I don't believe you have shown your output. Please show the output of your function. 0 SELECT DISTINCT `TIER1DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' Executives and Management Normally this query alone returns 9 rows of data. Each of these rows should be included in the next query where TIER1DATA = each of the nine in succession 1 SELECT DISTINCT `TIER2DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND `TIER1DATA` = 'Executives and Management' Executives and ManagementLeadership 2 SELECT DISTINCT `TIER3DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND `TIER2DATA` = 'Executives and ManagementLeadership' Executives and ManagementLeadershipManager 3 SELECT DISTINCT `BUSTIER1DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND `TIER3DATA` = 'Executives and ManagementLeadershipManager' Knee 4 SELECT DISTINCT `BUSTIER2DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND `BUSTIER1DATA` = 'Knee' KneeDIV01 5 SELECT DISTINCT `BUSTIER3DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND `BUSTIER2DATA` = 'KneeDIV01' KneeDIV01DEPT02 6 SELECT DISTINCT `BUSTIER4DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND `BUSTIER3DATA` = 'KneeDIV01DEPT02' KneeDIV01DEPT02GRP04 7 SELECT DISTINCT `` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND `BUSTIER4DATA` = 'KneeDIV01DEPT02GRP04' 1054Unknown column '' in 'field list' -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ http://www.bendsource.com/ ---End Message--- ---BeginMessage--- On Fri, Mar 2, 2012 at 7:43 AM, Jay Blanchard jay.blanch...@sigmaphinothing.org wrote: My usual approach to a problem like this to to includes a parent column in the table ID (int pk) Parent ( default null ) // no parent Item Itemtype [etc] Parent will then hold either a null if a top level item, or a structured path ( 1/10/24 ) that notes the parents of the item all the way up to the parent. That way, a single query will get you all items in that parent's lineage to whatever depth is needed by using the child's value Select * from table where parent = '1/10' Would retrieve all items that are children of a top level of 1 and a second level of 10 I would do that under normal circumstance but I cannot modify the client's table in any way shape or form. I am considering the COMPANY_ID to be the parent at this point and I can get all who belong to a company. I just need to turn that lineage into a tree. Would they let you make a copy or a join table where you could build what you need? Then maybe add a stored proc to move data as needed -- Bastien Cat, the other other white meat ---End Message---
Re: [PHP] Nested database loops and completing an unordered list....
My usual approach to a problem like this to to includes a parent column in the table ID (int pk) Parent ( default null ) // no parent Item Itemtype [etc] Parent will then hold either a null if a top level item, or a structured path ( 1/10/24 ) that notes the parents of the item all the way up to the parent. That way, a single query will get you all items in that parent's lineage to whatever depth is needed by using the child's value Select * from table where parent = '1/10' Would retrieve all items that are children of a top level of 1 and a second level of 10 I would do that under normal circumstance but I cannot modify the client's table in any way shape or form. I am considering the COMPANY_ID to be the parent at this point and I can get all who belong to a company. I just need to turn that lineage into a tree. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] curl equivalent in PHP
Hello, I am trying to display the website content through a php code ( my own websites; doesn't cause copy right issues ). I use curl to display the page via the following simple code. ?php $curl = curl_init(); curl_setopt ($curl, CURLOPT_URL, http://mytest.com;); curl_exec ($curl); curl_close ($curl); ? But on some of my servers, curl isn't enabled! Is there any equivalent code to achieve the same? Thank you, -- Regards Nibin. http://TechsWare.in
Re: [PHP] curl equivalent in PHP
Thanks Marc. But that need to add the DOM parser to the server. What I am looking for something like iframe in html and that doesn't require any additional PHP modules ( I do would like to avoid additions to the current php; that is why I didn't compiled in curl ) On Fri, Mar 2, 2012 at 7:58 PM, Marc Guay marc.g...@gmail.com wrote: http://simplehtmldom.sourceforge.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Regards Nibin. http://TechsWare.in
Re: [PHP] curl equivalent in PHP
Thanks Marc. But that need to add the DOM parser to the server. What I am looking for something like iframe in html and that doesn't require any additional PHP modules ( I do would like to avoid additions to the current php; that is why I didn't compiled in curl ) On Fri, Mar 2, 2012 at 8:10 PM, Nibin V M nibi...@gmail.com wrote: Thanks Marc. But that need to add the DOM parser to the server. What I am looking for something like iframe in html and that doesn't require any additional PHP modules ( I do would like to avoid additions to the current php; that is why I didn't compiled in curl ) On Fri, Mar 2, 2012 at 7:58 PM, Marc Guay marc.g...@gmail.com wrote: http://simplehtmldom.sourceforge.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Regards Nibin. http://TechsWare.in -- Regards Nibin. http://TechsWare.in
Re: [PHP] curl equivalent in PHP
http://www.php.net/manual/en/function.stream-context-create.php On Fri, Mar 2, 2012 at 4:44 PM, Nibin V M nibi...@gmail.com wrote: Thanks Marc. But that need to add the DOM parser to the server. What I am looking for something like iframe in html and that doesn't require any additional PHP modules ( I do would like to avoid additions to the current php; that is why I didn't compiled in curl ) On Fri, Mar 2, 2012 at 8:10 PM, Nibin V M nibi...@gmail.com wrote: Thanks Marc. But that need to add the DOM parser to the server. What I am looking for something like iframe in html and that doesn't require any additional PHP modules ( I do would like to avoid additions to the current php; that is why I didn't compiled in curl ) On Fri, Mar 2, 2012 at 7:58 PM, Marc Guay marc.g...@gmail.com wrote: http://simplehtmldom.sourceforge.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Regards Nibin. http://TechsWare.in -- Regards Nibin. http://TechsWare.in
Re: [PHP] Nested database loops and completing an unordered list....
On 03/01/2012 06:20 PM, Jay Blanchard wrote: [snip] Can you show the output of the function above? [/snip] Doesn't this SQL query return everything that has company_id set to 3 which would it not contain all the data from the other queries combined into one large data set? At this point, I don't believe you have shown your output. Please show the output of your function. 0 SELECT DISTINCT `TIER1DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' Executives and Management Normally this query alone returns 9 rows of data. Each of these rows should be included in the next query where TIER1DATA = each of the nine in succession 1 SELECT DISTINCT `TIER2DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND `TIER1DATA` = 'Executives and Management' Executives and ManagementLeadership 2 SELECT DISTINCT `TIER3DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND `TIER2DATA` = 'Executives and ManagementLeadership' Executives and ManagementLeadershipManager 3 SELECT DISTINCT `BUSTIER1DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND `TIER3DATA` = 'Executives and ManagementLeadershipManager' Knee 4 SELECT DISTINCT `BUSTIER2DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND `BUSTIER1DATA` = 'Knee' KneeDIV01 5 SELECT DISTINCT `BUSTIER3DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND `BUSTIER2DATA` = 'KneeDIV01' KneeDIV01DEPT02 6 SELECT DISTINCT `BUSTIER4DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND `BUSTIER3DATA` = 'KneeDIV01DEPT02' KneeDIV01DEPT02GRP04 7 SELECT DISTINCT `` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND `BUSTIER4DATA` = 'KneeDIV01DEPT02GRP04' 1054Unknown column '' in 'field list' -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ http://www.bendsource.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] curl equivalent in PHP
On 03/02/2012 06:26 AM, Nibin V M wrote: Hello, I am trying to display the website content through a php code ( my own websites; doesn't cause copy right issues ). I use curl to display the page via the following simple code. ?php $curl = curl_init(); curl_setopt ($curl, CURLOPT_URL, http://mytest.com;); curl_exec ($curl); curl_close ($curl); ? But on some of my servers, curl isn't enabled! Is there any equivalent code to achieve the same? Thank you, As long as you do not need to perform posts to the other website via the PHP request, you could include, file_get_contents, fopen + fread, etc... All you need to make sure is that allow_url_fopen is enabled. -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ http://www.bendsource.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Nested database loops and completing an unordered list....
On Fri, Mar 2, 2012 at 7:43 AM, Jay Blanchard jay.blanch...@sigmaphinothing.org wrote: My usual approach to a problem like this to to includes a parent column in the table ID (int pk) Parent ( default null ) // no parent Item Itemtype [etc] Parent will then hold either a null if a top level item, or a structured path ( 1/10/24 ) that notes the parents of the item all the way up to the parent. That way, a single query will get you all items in that parent's lineage to whatever depth is needed by using the child's value Select * from table where parent = '1/10' Would retrieve all items that are children of a top level of 1 and a second level of 10 I would do that under normal circumstance but I cannot modify the client's table in any way shape or form. I am considering the COMPANY_ID to be the parent at this point and I can get all who belong to a company. I just need to turn that lineage into a tree. Would they let you make a copy or a join table where you could build what you need? Then maybe add a stored proc to move data as needed -- Bastien Cat, the other other white meat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Nested database loops and completing an unordered list....
[snip] Doesn't this SQL query return everything that has company_id set to 3 which would it not contain all the data from the other queries combined into one large data set? [/snip] I could do that, I can return one large dataset for all of the columns shown in the tiers array. I have to remove the DISTINCT's. When I return that dataset in this case I return seven columns of data with the parent being in the leftmost column and descending to the right. The goal with the the recursive function was to get each descendant line so that it could be formatted in a nested unordered list. So in the SQL below you get 9 records. For each of the 9 records you could get any number of children depending on which of the 9 you're looking at. Then for each of those children you could get their descendants and so on. I was doing it the long way at first, until a recursive function was suggested. The problem that I was having there was formatting the ul's and li's properly. Now I feel as if I am really close to a better solution than the brute force method. I may just be a little too frustrated to see what is a simple answer. Thanks for your help! At this point, I don't believe you have shown your output. Please show the output of your function. 0 SELECT DISTINCT `TIER1DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' Executives and Management Normally this query alone returns 9 rows of data. Each of these rows should be included in the next query where TIER1DATA = each of the nine in succession 1 SELECT DISTINCT `TIER2DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND `TIER1DATA` = 'Executives and Management' Executives and ManagementLeadership -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] curl equivalent in PHP
Thanks guys :) Now another problem...I use a test domain ( say blahblah.com ) for testing this, which isn't registered yet. So with the given code the index page is loading fine. But when I try to click on any links, it will redirect to the original domain which isn't exists! ( I have actually pointed the test domain to my server via hosts file on the server ) So I wanted to browse the website via a PHP script, same as if I use a browser on the server. Hope you get me! :) Is there any way to achieve this via PHP? What I wanted to On Fri, Mar 2, 2012 at 9:37 PM, Jim Lucas li...@cmsws.com wrote: On 03/02/2012 06:26 AM, Nibin V M wrote: Hello, I am trying to display the website content through a php code ( my own websites; doesn't cause copy right issues ). I use curl to display the page via the following simple code. ?php $curl = curl_init(); curl_setopt ($curl, CURLOPT_URL, http://mytest.com;); curl_exec ($curl); curl_close ($curl); ? But on some of my servers, curl isn't enabled! Is there any equivalent code to achieve the same? Thank you, As long as you do not need to perform posts to the other website via the PHP request, you could include, file_get_contents, fopen + fread, etc... All you need to make sure is that allow_url_fopen is enabled. -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ http://www.bendsource.com/ -- Regards Nibin. http://TechsWare.in
Re: [PHP] curl equivalent in PHP
Hello, On Fri, Mar 2, 2012 at 8:07 AM, Jim Lucas li...@cmsws.com wrote: But on some of my servers, curl isn't enabled! Is there any equivalent code to achieve the same? I've used a combination of output buffering [1], readfile() [2] and caching (specific to the framework I was using). Simply, you could resort to: ?php readfile('http://www.google.com'); ? Ofc, the links would need to be absolute in order for the assets to load. Good luck! Cheers, Micky [1] php.net/ob-start [2] php.net/readfile -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] curl equivalent in PHP
On Fri, Mar 2, 2012 at 11:29, Nibin V M nibi...@gmail.com wrote: Thanks guys :) Now another problem...I use a test domain ( say blahblah.com ) for testing this, which isn't registered yet. So with the given code the index page is loading fine. But when I try to click on any links, it will redirect to the original domain which isn't exists! ?php echo str_replace('blahblah.com','localhost',file_get_contents('remote-domain.example.com')); ? Modify it as needed, and if you want to surf the site using the script as a proxy, add the logic to handle that. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] problem about PHP-FPM in TCP socket and Unix socket
Hello all, I am trying to config some new server All of my servers are using TCP Socket(127.0.0.1:9000) between nginx and php-fpm before But, I run ab(ab -n 2 -c50 http://192.168.74.130:81/) to test the performance of Unix Socket and TCP Socket, the result is Unix is little better than TCP Usually we run php and web server in the same server, So, TCP socket and Unix socket Which method do you prefer ? Thank you -- *Yuchen Wang*
Re: [PHP] curl equivalent in PHP
Hmm..I am a php newbie ( just started learning it )... what my need is to display website from my server always for a non-registered domain.This is the code I use now to display the website ?php $opts = array( 'http'=array( 'method'=GET, 'header'=Accept-language: en\r\n . Cookie: foo=bar\r\n ) ); $context = stream_context_create($opts); $fp = fopen('http://www.blahblah.com', 'r', false, $context); fpassthru($fp); fclose($fp); ? Of course blahblah.com isn't registered yet. This will load the index page of blahblah.com fine ( since I use hosts file to resolve blahblah.com on the server ). But if we click on any link, it will give server not found error since my local machine is trying to resolve blahblah.com this time. I need to avoid it and want to load my domain always from the server when I click any link on the webpage, etc . How can I modify the above code to make it work! If possible, I request somebody to tell me the exact code that I need to change in the above script - since most of the php part is still greek to me :) Thank you, On Fri, Mar 2, 2012 at 10:09 PM, Micky Hulse rgmi...@gmail.com wrote: Hello, On Fri, Mar 2, 2012 at 8:07 AM, Jim Lucas li...@cmsws.com wrote: But on some of my servers, curl isn't enabled! Is there any equivalent code to achieve the same? I've used a combination of output buffering [1], readfile() [2] and caching (specific to the framework I was using). Simply, you could resort to: ?php readfile('http://www.google.com'); ? Ofc, the links would need to be absolute in order for the assets to load. Good luck! Cheers, Micky [1] php.net/ob-start [2] php.net/readfile -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Regards Nibin. http://TechsWare.in
Re: [PHP] Nested database loops and completing an unordered list....
[snip] ...stuff ... [/snip] A thought occurred to me - I need to call the function at the end of the while loop and then again with different criteria after the while loop? I'll have to test that later today. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Nested database loops and completing an unordered list....
On 03/02/2012 08:27 AM, Jay Blanchard wrote: [snip] Doesn't this SQL query return everything that has company_id set to 3 which would it not contain all the data from the other queries combined into one large data set? [/snip] I could do that, I can return one large dataset for all of the columns shown in the tiers array. I have to remove the DISTINCT's. When I return that dataset in this case I return seven columns of data with the parent being in the leftmost column and descending to the right. The goal with the the recursive function was to get each descendant line so that it could be formatted in a nested unordered list. So in the SQL below you get 9 records. For each of the 9 records you could get any number of children depending on which of the 9 you're looking at. Then for each of those children you could get their descendants and so on. I was doing it the long way at first, until a recursive function was suggested. The problem that I was having there was formatting the ul's and li's properly. I'm not saying you should get rid of the recursive function calls, but rather, why not pull all your data in one SQL call, then use recursive functions on the returned array of data. It will save a little time by not hitting the DB on each function call too. Now I feel as if I am really close to a better solution than the brute force method. I may just be a little too frustrated to see what is a simple answer. Thanks for your help! -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ http://www.bendsource.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Nested database loops and completing an unordered list....
[snip] I'm not saying you should get rid of the recursive function calls, but rather, why not pull all your data in one SQL call, then use recursive functions on the returned array of data. It will save a little time by not hitting the DB on each function call too. [/snip] I'll just need to wrap my head around using a recursive function to iterate through the array. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SESSION var and Objects problem
My first foray into classes objects. When retrieving a set of records, I'm using a class to build an object. At this time I save each record/object into a Session array by doing this: $rows = mysql_num_rows($qrslts); if ($rows 0) for ($i=1;$i=$rows;$i++) { $row = mysql_fetch_array($qrslts); $e = new Entry; if ($e-GetAnEntry($row['recordkey'],$row['Eventcode'])) { $evts[] = $e; array_push($_SESSION['TMScurr_evts'],$e); // THIS DOESN'T $cls_errs .= Stored $e-event in sess var $i-1; ; // THIS WORKS } else $cls_errs .= Could not retrieve event record for .$row['recordkey']. .$row['Eventcode']; } The above code works AFAIK - the line above the array_push correctly stores my retreived record data in the $evts array just fine and I can see the data when I use that array to display my page. Note also that the var $cls_errs following the array_push does show me that valid values are being stored in $e Later on, in my main process I attempt to retreive the contents of my Session var to use to re-display the data. The code for that doesn't display any values. In trying to debug this here is what I've done: $cnt = count($_SESSION['TMScurr_evts']); echo In Display process with $cnt recs in session var TMScurr_evts. ; // THIS WORKS reset($_SESSION['TMScurr_evts']); $e = new Entry; for ($i=0;$icount($_SESSION['TMScurr_evts']);$i++) { $e = array_pop($_SESSION['TMScurr_evts']); echo in Display process - sess event $i is $e-eventbr;// THIS DOESN'T } This debugging code correctly tells me how many entries are in the Session array variable, but the attempt to echo the values stored in the first field of each object contained in it shows blank for each one. What am I doing wrong when I try to pull the contents of my session array out and store them back into an Entry object, one at a time, so that I can display the object on my webpage?? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION var and Objects problem
On 2 Mar 2012, at 20:07, Jim Giner wrote: My first foray into classes objects. When retrieving a set of records, I'm using a class to build an object. At this time I save each record/object into a Session array by doing this: $rows = mysql_num_rows($qrslts); if ($rows 0) for ($i=1;$i=$rows;$i++) { $row = mysql_fetch_array($qrslts); $e = new Entry; if ($e-GetAnEntry($row['recordkey'],$row['Eventcode'])) { $evts[] = $e; array_push($_SESSION['TMScurr_evts'],$e); // THIS DOESN'T $cls_errs .= Stored $e-event in sess var $i-1; ; // THIS WORKS } else $cls_errs .= Could not retrieve event record for .$row['recordkey']. .$row['Eventcode']; } What is the type of $e (i.e. what's the class called)? Side note... it looks like GetAnEntry fetches the entry into internal data. This isn't really how objects are supposed to work. To be more OO-like you should be passing the recordkey and Eventcode values into the constructor. But that's not relevant to your issue. The above code works AFAIK - the line above the array_push correctly stores my retreived record data in the $evts array just fine and I can see the data when I use that array to display my page. Note also that the var $cls_errs following the array_push does show me that valid values are being stored in $e Later on, in my main process I attempt to retreive the contents of my Session var to use to re-display the data. The code for that doesn't display any values. In trying to debug this here is what I've done: $cnt = count($_SESSION['TMScurr_evts']); echo In Display process with $cnt recs in session var TMScurr_evts. ; // THIS WORKS reset($_SESSION['TMScurr_evts']); $e = new Entry; for ($i=0;$icount($_SESSION['TMScurr_evts']);$i++) { $e = array_pop($_SESSION['TMScurr_evts']); echo in Display process - sess event $i is $e-eventbr;// THIS DOESN'T } This debugging code correctly tells me how many entries are in the Session array variable, but the attempt to echo the values stored in the first field of each object contained in it shows blank for each one. What am I doing wrong when I try to pull the contents of my session array out and store them back into an Entry object, one at a time, so that I can display the object on my webpage?? In the above script, the one that gets the objects out of the session, has the class been declared? IOW, have you included the PHP file that defines that class? If not then it won't be able to recreate the object. If that was the problem then I suggest you make sure you have error_reporting set to at least E_ALL, and display_errors set on, because this issue will be causing a fatal error, the text of which would make it obvious what's going wrong. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION var and Objects problem
Yes I ahve the class defined. The classes work in most cases - just this one place where I want to save the objects in a sess var for re-use fails me. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION var and Objects problem
Please quote the pertinent bit of the message you're replying to, it makes using the list a halluvalot easier and improves SEO for the archives. On 2 Mar 2012, at 20:55, Jim Giner wrote: Yes I ahve the class defined. The classes work in most cases - just this one place where I want to save the objects in a sess var for re-use fails me. Put the following line at the top of the code that you posted and post the output. echo 'pre'; var_dump($_SESSION['TMScurr_evts']); die('/pre'); Have you checked your error log, or your error settings? Scripts generally don't stop executing for no reason or without saying why. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION var and Objects problem
ok - In examinig the objects in the Session after the data has been displayed and the user has hit triggered a re-entry into my script (just one script involved here), the objects in the session array now say [__PHP_Incomplete_Class_Name and __PHP_Incomplete_Class Object . They didn't say that during my examiniation of the sess var before exiting the script. Also with All error reporting on (a great tip that I never think of) I get many messages indicating that the object may not have been loaded. I don't know what this means. The include file for my class is present in my script and is always loaded. But at this point in the process no functions of the class have been called. Is that a problem? In trying to re-display my data stored in the Sessioin array I instantiate a var of the class and then pop an array off the session var and assign it to the object and then call my display function to show the data on the webpage - that is where I get the errors. Here is one of these messages: Notice: DisplayAnEntry() [function.displayanentry]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition Entry of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in /home/albany/public_html/tms/php/tmsentry.php on line 372 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION var and Objects problem
On 2 Mar 2012, at 21:09, Jim Giner wrote: ok - In examinig the objects in the Session after the data has been displayed and the user has hit triggered a re-entry into my script (just one script involved here), the objects in the session array now say [__PHP_Incomplete_Class_Name and __PHP_Incomplete_Class Object . They didn't say that during my examiniation of the sess var before exiting the script. Also with All error reporting on (a great tip that I never think of) I get many messages indicating that the object may not have been loaded. I don't know what this means. The include file for my class is present in my script and is always loaded. But at this point in the process no functions of the class have been called. Is that a problem? In trying to re-display my data stored in the Sessioin array I instantiate a var of the class and then pop an array off the session var and assign it to the object and then call my display function to show the data on the webpage - that is where I get the errors. Here is one of these messages: Notice: DisplayAnEntry() [function.displayanentry]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition Entry of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in /home/albany/public_html/tms/php/tmsentry.php on line 372 Make sure the class is declared before you call session_start. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION var and Objects problem
Stuart Dallas stu...@3ft9.com wrote in message news:7eeba658-c7f6-4449-87bd-aac71b41e...@3ft9.com... Make sure the class is declared before you call session_start. * You Da Man!! I see now why it makes a difference. The session tries to bring back the data but doesn't know how to handle the objects in the session vars since the objects haven't been defined. Never would of thought of that! Thank you for being there! :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem about PHP-FPM in TCP socket and Unix socket
This how I would look at it, if it on the same box use socket, and yes it is expected that socket is faster than TCP since (as far as I know) you don't need to deal with the overhead of TCP. Regards, Daniel Fenn On Sat, Mar 3, 2012 at 3:56 AM, Yuchen Wang phob...@gmail.com wrote: Hello all, I am trying to config some new server All of my servers are using TCP Socket(127.0.0.1:9000) between nginx and php-fpm before But, I run ab(ab -n 2 -c50 http://192.168.74.130:81/) to test the performance of Unix Socket and TCP Socket, the result is Unix is little better than TCP Usually we run php and web server in the same server, So, TCP socket and Unix socket Which method do you prefer ? Thank you -- *Yuchen Wang* -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION var and Objects problem
Hi, Jim To avoid this kind of problem it would also help to provide an autoloader-function as PHP then tries to load the class-definition by this autoloader ;) Using that you'd bind yourself to have a pretty good system for php-classes and you'd avoid having problems like that. I'd in fact have never thought about a solution like that - but that may comes from the fact that I always use auto-loader-scripts ;) One additional info: I had some problems putting an instance of *SimpleXmlElement *into the session ... The only valuable info I found was this error: *Fatal error: Exception thrown without a stack frame in Unknown on line 0* Here's the solution and description why: http://stackoverflow.com/questions/4624223/object-in-session-fatal-error-exception-thrown-without-a-stack-frame-in-unknow#answer-4624256 Bye Simon 2012/3/2 Jim Giner jim.gi...@albanyhandball.com Stuart Dallas stu...@3ft9.com wrote in message news:7eeba658-c7f6-4449-87bd-aac71b41e...@3ft9.com... Make sure the class is declared before you call session_start. * You Da Man!! I see now why it makes a difference. The session tries to bring back the data but doesn't know how to handle the objects in the session vars since the objects haven't been defined. Never would of thought of that! Thank you for being there! :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] curl equivalent in PHP
On Fri, Mar 2, 2012 at 6:09 PM, Nibin V M nibi...@gmail.com wrote: Hmm..I am a php newbie ( just started learning it )... what my need is to display website from my server always for a non-registered domain.This is the code I use now to display the website ?php $opts = array( 'http'=array( 'method'=GET, 'header'=Accept-language: en\r\n . Cookie: foo=bar\r\n ) ); $context = stream_context_create($opts); $fp = fopen('http://www.blahblah.com', 'r', false, $context); fpassthru($fp); fclose($fp); ? Of course blahblah.com isn't registered yet. This will load the index page of blahblah.com fine ( since I use hosts file to resolve blahblah.com on the server ). But if we click on any link, it will give server not found error since my local machine is trying to resolve blahblah.com this time. I need to avoid it and want to load my domain always from the server when I click any link on the webpage, etc . How can I modify the above code to make it work! If possible, I request somebody to tell me the exact code that I need to change in the above script - since most of the php part is still greek to me :) Thank you, Have you actually read/tried Daniel Browns reply? The following seems to be all you need... ?php echo str_replace('blahblah.com','localhost',file_get_contents('blahblah.com')); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem about PHP-FPM in TCP socket and Unix socket
On Fri, Mar 2, 2012 at 5:56 PM, Yuchen Wang phob...@gmail.com wrote: Hello all, I am trying to config some new server All of my servers are using TCP Socket(127.0.0.1:9000) between nginx and php-fpm before But, I run ab(ab -n 2 -c50 http://192.168.74.130:81/) to test the performance of Unix Socket and TCP Socket, the result is Unix is little better than TCP Usually we run php and web server in the same server, So, TCP socket and Unix socket Which method do you prefer ? Thank you -- *Yuchen Wang* Always go for Unix sockets. TCP has quite a bit overhead which includes stuff you really don't need if two processes live on the same server. Think about error detection, flow control, congestion control, packet loss. None of these are needed if your system is functioning correctly. - Matijn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem about PHP-FPM in TCP socket and Unix socket
Something else that should be said: You won't need to muck around with firewall settings as well (that if your running a firewall on the same box On Sat, Mar 3, 2012 at 11:22 AM, Matijn Woudt tijn...@gmail.com wrote: On Fri, Mar 2, 2012 at 5:56 PM, Yuchen Wang phob...@gmail.com wrote: Hello all, I am trying to config some new server All of my servers are using TCP Socket(127.0.0.1:9000) between nginx and php-fpm before But, I run ab(ab -n 2 -c50 http://192.168.74.130:81/) to test the performance of Unix Socket and TCP Socket, the result is Unix is little better than TCP Usually we run php and web server in the same server, So, TCP socket and Unix socket Which method do you prefer ? Thank you -- *Yuchen Wang* Always go for Unix sockets. TCP has quite a bit overhead which includes stuff you really don't need if two processes live on the same server. Think about error detection, flow control, congestion control, packet loss. None of these are needed if your system is functioning correctly. - Matijn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php