Re: [PHP] fsocketopen not returning data properly
On 6/19/07, Dan [EMAIL PROTECTED] wrote: I'm having trouble with sockets in PHP, if anyone has the time to help out that would be awesome. I am trying to get the result of a post There are a lot of people that are probably willing to help, but what is your exact problem? echo httpSocketConnection(www.google.com, POST, /search, q=test, 80); This should post to google.com with a query of test. Then give me the response. The function I'm using is below. Google doesn't wants a POST request, make it a GET request and it should work. Here's the function's code: snip You copied this straight from the web? If so, then there are probably no bugs in it. Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php framework, large site
Hi, as a creator of the one of those half baked's I want to say someting about this issue. People wants own Php framework etc. Because 1-) Documentation. For my point of view most of unix documentation style was too complex. After more than 10 years of linux experience I still hate man pages. And some how (I believe this because of want look like professional/ubergeek/hyper academic) most language/framework/cms/thisthat in Open Source universe uses complex documentation model. Php was non programmers programming language especially for web. Uber Programmers still rejecting php (because of function naming, not good enough oo support, etc etc etc). Also there was tons of more polished programming (and or scripting) language for web (perl, python, ruby) none of them reach popularty of php. After tons of security problems, misbehaved functions, php still growing as fast as possible. It was documentation damn it. No other language has php style documentation. So ? Most of php framework's uses complex documentation model and because of this lost of people can't understand (and improve) those frameworks and implement own. 2-) Complexing... Over time frameworks become more complex... If you are there from start there was no problem for you and if came here after 4 years you will see lots of classes and functions to understand to the what the hell goes around there. Last month our company give try for typo3. OUCH!! I'm still tyring to understand what goin there. Function names was very funny. I still try to understand their system. According the their web pages in 5.0 they will clean up the system. .Backward compatibility. Most of php programmers are non programmers and php can grow up with his programmer and world of WWW too fast for anything. Programming c was not so much change last 5 years and programmin php in last 5 years was changed too much. AND if you are my kind (growing with php) your programing style was dramaticly changed. And if you had so popular framework you have to give backward support. And this was increase complexity of some frameworks. .overused OO I see some frame works uses $this-$that-$yada-$bada() Ouch man if we can tolerate this kind of compexity we can even program in ASM... 3-) This is world of HTML, JS and HTTP. there was lot of way to implement your idea. 4-) Writing someting in php very easy 5-) Having own framework was coool. ;) Regards sancar -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP calling an ISAPI Extension
On 6/19/07, Jim Lucas [EMAIL PROTECTED] wrote: Dan wrote: I wish I could, I can't count on the script being on a linux machine. I also can't expect people to rebuild PHP with the curl library just to use my script. Is there any other way to do a post to a page from a php function? - Daniel Jim Lucas [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Dan wrote: I would normaly do it with an AJAX call but I need to do a post from WITHIN a PHP function, so when it's doing php stuff ex. function something() { echo 'whatever'; $response = post some data to a ISAPI Extension eg. post to http://domain.com/scripts/app.dll return $response . other data; } Jay Blanchard [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [snip] I'm in need of a way to contact an ISAPI Extension from a PHP function. Does anyone know how I would be able to do this? Usually you would post a page to their URL/actionname. Can I do a POST from a PHP function without reloading the page, and get a result back? That's one tall order. Anyone want to give it a shot? [/snip] Do the POST with an AJAX call perform an ajax call the a php script that calls curl to do a post to the ISAPI extension -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare The only method that I am aware of is the fsockopen method you mention in your other email -- Jim Lucas Yes, and what's wrong with it? ?php $post_data = form_a=1form_b=4; $fp = fsockopen(www.domain.com,80); fwrite($fp,POST /scripts/app.dll HTTP/1.1\r\nHost: www.domain.com\r\nContent-Length: .strlen($post_data).\r\n\r\n.$post_data); $result = fread($fp,102400); // Reads 100KB, change if you need more ? That's not too long is it? Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: generate images of register definitions
Mike Frysinger wrote: On 6/9/07, Richard Lynch [EMAIL PROTECTED] wrote: On Sat, June 9, 2007 4:27 pm, Mike Frysinger wrote: anyone know of some software to generate images like this: http://wh0rd.org/register.png idea is i have a list of registers and their bit meanings, and i want to automatically generate images like the above one from this data yes, i can write some custom code in PHP using GD, but i'd much rather use someone else's work than start from scratch It's remotely possible that you could hack something from JP Graph to look not completely unlike that... Though I suspect you might find it easier to start from scratch, honestly... yeah ive just started from scratch ... here's what ive got so far in case anyone happens to wander across this ... $reg = new register(WDOG_CTL, Watchdog Control Register, 0xFFC00200, 0x0AD0, 16, array( array(15, 15, WDRO, 0 - Watchdog timer has not expired\n1 - Watchdog timer has expired, W1C), array(11, 4, WDEN, 0xAD - Counter disabled\nAll other values - Counter enabled), array(2, 1, WDEV, 00 - Generate reset event\n01 - Generate NMI\n10 - Generate GP interrupt\n11 - Disable event generation) ) ); register_to_png($reg); http://wh0rd.org/register2.png maybe i'll start a cheesy sf project for it That looks pretty damn good :) Just a pity I can't think of a reason for me to use it! :p Col -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP calling an ISAPI Extension
Dan wrote: For example, I could use function fsockopen but that seems like it would probably be pretty slow doing all that, and if there's a php function or small script that would be preferable over the 50/60 lines you would need to do it properly with fsockopen. with the caveat that it'll only work as a GET request (which probably means no cigar for you), and requires that your php is setup to allow open urls (ini setting 'allow_url_fopen') $response = file_get_contents('http://your.iis.machine/some/path/some_isapi.dll?foo=bar'); otherwise the fsockopen() route is all that seems to be open to you, given that curl reliance is a no-no. - the biggest factor in the response speed is likely to be the server at the other end (assuming the network connection between the 2 machines is generally ok), so if things are slow you might consider caching the results locally (again, assuming that this is feasable.) is the isapi extension on the same machine? if so maybe it has a COM interface with which you can talk to it? http://php.net/com no idea if that is feasible - I've never really used IIS, let alone had to deal with isapi extensions. - Daniel Jay Blanchard [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [snip] I'm in need of a way to contact an ISAPI Extension from a PHP function. Does anyone know how I would be able to do this? Usually you would post a page to their URL/actionname. Can I do a POST from a PHP function without reloading the page, and get a result back? That's one tall order. Anyone want to give it a shot? [/snip] Do the POST with an AJAX call -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] Comparing string to array
Hi Larry, Tuesday, June 19, 2007, 2:55:07 AM, you wrote: Perhaps you're looking for in_array()? If only it was that simple! But pray tell how an in_array search is going to find: $userparam = test['bob'][]; within: Array ( [test] = Array ( ['bob'] = Array ( [0] = red [1] = green [2] = blue ) ) ) ? The problem is that $userparam in the example above needs to be expanded out into a form that $_POST can be searched for it. Or vica versa. 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] Comparing string to array
Richard Davey wrote: Hi all, Ok it's 2am, my brain has gone to mush and I am having trouble figuring out an easy way to do this, can anyone shed some light? Take a peek at the following code: // START pre ?php print_r($_POST); $userparam = test['sam'][]; // How to check if $userparam exists in the $_POST array // and get all the values from it? // Obviously this won't work, but you get the idea: if (isset($_POST[$userparam])) { echo 'yeah'; $values = $_POST[$userparam]; } else { echo 'nah'; } ? /pre form method=post input type=checkbox name=test['bob'][] value=redredbr input type=checkbox name=test['bob'][] value=greengreenbr input type=checkbox name=test['bob'][] value=bluebluebr input type=checkbox name=test['sam'][] value=red2red2br input type=checkbox name=test['sam'][] value=green2green2br input type=checkbox name=test['sam'][] value=blue2blue2br input type=submit /form // END From the code above I'm trying to figure out how to tell if the $userparam exists in the $_POST array. PHP automatically expands the form element name into multi-dim arrays within $_POST, so a simple 'isset' as shown in the code above won't play because it's got a totally useless array key passed to it. I need a way to turn the string: test['sam'][] into something I can look into $_POST for. Any ideas? The coffee boost is wearing off, but I want to get this licked tonight :-\ Do you have control over what $userparam looks like? I'm not entirely sure what you're after due to the [] on the end of it, but I'm going to assume you want to know if any of the 'sam' checkboxes were ticked. Maybe the following is a possibility... $userparam = test.sam; // How to check if $userparam exists in the $_POST array // and get all the values from it? $idx = '[\''.implode('\'][\']', explode('.', $userparam)).'\']'; eval('$isset = isset($_POST'.$idx.');'); // Obviously this won't work, but you get the idea: if ($isset) { echo 'yeah'; eval('$values = $_POST'.$idx.';'); } else { echo 'nah'; } Untested, and remember that eval is pure evil. If you can't control $userparam and it has to look like you have it then you're parsing of it is a little more involved, but still fairly simple. What are you actually trying to do? Where will $userparam actually come from? There is almost certainly a better way to do this, but without knowing all the details I'd be peeing in the wind. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date
Larry Garfield wrote: (Note: strtotime() is probably not the fastest to execute way of doing it, but it's the fastest to write. Choose wisely.) Is it? How about: $timestamp = strtotime($expiry_date) + (86400 * 7); -- Richard Heyes 0844 801 1072 http://www.websupportsolutions.co.uk Knowledge Base and HelpDesk software -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Keeping sessions
Hi all ! In a web server cluster, how do you do guys keep the php sessions? I mean, with Apache and mod_proxy_balanced you could have a cluster with apache backend webservers but If a user is logged into an php app then this user goes always to the same backend server and if that server goes down then the session is invalid. How to deal with sessions? thanks in advance! cheers -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Keeping sessions
Jorge González wrote: In a web server cluster, how do you do guys keep the php sessions? I mean, with Apache and mod_proxy_balanced you could have a cluster with apache backend webservers but If a user is logged into an php app then this user goes always to the same backend server and if that server goes down then the session is invalid. How to deal with sessions? Several options exist, but the most common is to store session data in a database that can be accessed by all of the web servers. Alternatives include using memcached but recently I read something that suggested that can be problematic. I believe the cluster support in Zend Platform includes this functionality, so depending on your budget that may also be an option. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] Comparing string to array
Hi Stut, Tuesday, June 19, 2007, 10:16:02 AM, you wrote: If you can't control $userparam and it has to look like you have it then you're parsing of it is a little more involved, but still fairly simple. What are you actually trying to do? Where will $userparam actually come from? There is almost certainly a better way to do this, but without knowing all the details I'd be peeing in the wind. Thank you for your code so far. Here is a more detailed explanation of what I'm trying to do: The designers here can create forms with whatever form elements they like on them. They can name the form elements with any valid name. As you know sometimes it is useful to give the form elements names which will convert them into arrays in PHP, i.e.: input type=checkbox name=test[color][] value=red2red2br input type=checkbox name=test[color][] value=green2green2br input type=checkbox name=test[color][] value=blue2blue2br So $_POST['test']['color'] would contain an array of all the checked values. So far so good. The problem comes in that I don't know what the form elements will be named, but I still need to check to see if they exist within the $_POST array. So knowing that $input_name = 'test[color][]' I then need to see if $_POST['test']['color'] exists and get the value if it does. To make matters worse it's perfectly legal to have a form element named like: input type=checkbox name=test['bob']['jazz'][] value=redred input type=checkbox name=test['bob']['jazz'][] value=greengreen input type=checkbox name=test['bob']['jazz'][] value=blueblue Which when bought back into PHP will come out as: array(1) { [test]= array(2) { ['bob']= array(1) { ['jazz']= array(3) { [0]= string(3) red [1]= string(5) green [2]= string(4) blue } } Does that make it any clearer? I have been playing with the RecursiveIteratorIterator this morning in an attempt to solve it, but the results from that are less than useless :( I'm happy to try and explore the RAW post value instead if that would be easier. I just figured there must be an easier way? Here is the complete page you can test with: START pre ?php var_dump($_POST); $iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($_POST)); while($iterator-valid()) { echo $iterator-key() . ' -- ' . $iterator-current(); echo \n; $iterator-next(); } $userparam = test['bob'][jazz][]; // How to determine if $userparam exists in $_POST ? /pre form method=post input type=checkbox name=test['bob'][jazz][] value=redredbr input type=checkbox name=test['bob'][jazz][] value=greengreenbr input type=checkbox name=test['bob'][jazz][] value=bluebluebr input type=checkbox name=test[sam][] value=red2red2br input type=checkbox name=test[sam][] value=green2green2br input type=checkbox name=test[sam][] value=blue2blue2br input type=submit /form END Remember the whole crux of this problem is that I have no control over what the form name will be. It will be *valid*, but that is all. They could nest the resulting array as deep in $_POST as they like. 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] Comparing string to array
Richard Davey wrote: Hi Stut, Tuesday, June 19, 2007, 10:16:02 AM, you wrote: If you can't control $userparam and it has to look like you have it then you're parsing of it is a little more involved, but still fairly simple. What are you actually trying to do? Where will $userparam actually come from? There is almost certainly a better way to do this, but without knowing all the details I'd be peeing in the wind. Thank you for your code so far. Here is a more detailed explanation of what I'm trying to do: The designers here can create forms with whatever form elements they like on them. They can name the form elements with any valid name. As you know sometimes it is useful to give the form elements names which will convert them into arrays in PHP, i.e.: input type=checkbox name=test[color][] value=red2red2br input type=checkbox name=test[color][] value=green2green2br input type=checkbox name=test[color][] value=blue2blue2br So $_POST['test']['color'] would contain an array of all the checked values. So far so good. The problem comes in that I don't know what the form elements will be named, but I still need to check to see if they exist within the $_POST array. So knowing that $input_name = 'test[color][]' I then need to see if $_POST['test']['color'] exists and get the value if it does. To make matters worse it's perfectly legal to have a form element named like: input type=checkbox name=test['bob']['jazz'][] value=redred input type=checkbox name=test['bob']['jazz'][] value=greengreen input type=checkbox name=test['bob']['jazz'][] value=blueblue Which when bought back into PHP will come out as: array(1) { [test]= array(2) { ['bob']= array(1) { ['jazz']= array(3) { [0]= string(3) red [1]= string(5) green [2]= string(4) blue } } Does that make it any clearer? I have been playing with the RecursiveIteratorIterator this morning in an attempt to solve it, but the results from that are less than useless :( I'm happy to try and explore the RAW post value instead if that would be easier. I just figured there must be an easier way? Here is the complete page you can test with: START pre ?php var_dump($_POST); $iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($_POST)); while($iterator-valid()) { echo $iterator-key() . ' -- ' . $iterator-current(); echo \n; $iterator-next(); } $userparam = test['bob'][jazz][]; // How to determine if $userparam exists in $_POST ? /pre form method=post input type=checkbox name=test['bob'][jazz][] value=redredbr input type=checkbox name=test['bob'][jazz][] value=greengreenbr input type=checkbox name=test['bob'][jazz][] value=bluebluebr input type=checkbox name=test[sam][] value=red2red2br input type=checkbox name=test[sam][] value=green2green2br input type=checkbox name=test[sam][] value=blue2blue2br input type=submit /form END Remember the whole crux of this problem is that I have no control over what the form name will be. It will be *valid*, but that is all. They could nest the resulting array as deep in $_POST as they like. If you have no control over what the fields in the form will be, what are you doing with the data? Surely if you're writing logic that requires you to know what the fields are called, you need to have control over it. On the other hand, if you're just squidging the data somewhere can't you just iterate over the contents of $_POST? I understand now that you're not in control of the form. What are you doing with the data that's submitted? -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Keeping sessions
Stut wrote: Jorge González wrote: In a web server cluster, how do you do guys keep the php sessions? I mean, with Apache and mod_proxy_balanced you could have a cluster with apache backend webservers but If a user is logged into an php app then this user goes always to the same backend server and if that server goes down then the session is invalid. How to deal with sessions? Several options exist, but the most common is to store session data in a database that can be accessed by all of the web servers. Alternatives include using memcached but recently I read something that suggested that can be problematic. I believe the cluster support in Zend Platform includes this functionality, so depending on your budget that may also be an option. Just a note: you could have either one of the web servers acting as the session server which the other web servers use or, if need be, a dedicated session server. I wouldn't imagine you'd need that though unless your site's really busy. -- Richard Heyes 0844 801 1072 http://www.websupportsolutions.co.uk Knowledge Base and HelpDesk software -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Keeping sessions
Richard Heyes wrote: Stut wrote: Jorge González wrote: In a web server cluster, how do you do guys keep the php sessions? I mean, with Apache and mod_proxy_balanced you could have a cluster with apache backend webservers but If a user is logged into an php app then this user goes always to the same backend server and if that server goes down then the session is invalid. How to deal with sessions? Several options exist, but the most common is to store session data in a database that can be accessed by all of the web servers. Alternatives include using memcached but recently I read something that suggested that can be problematic. I believe the cluster support in Zend Platform includes this functionality, so depending on your budget that may also be an option. Just a note: you could have either one of the web servers acting as the session server which the other web servers use or, if need be, a dedicated session server. I wouldn't imagine you'd need that though unless your site's really busy. What do you mean by session server? How are you accessing the session data on another server? -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] Comparing string to array
Hi Stut, Tuesday, June 19, 2007, 12:09:12 PM, you wrote: If you have no control over what the fields in the form will be, what are you doing with the data? Surely if you're writing logic that requires you to know what the fields are called, you need to have control over it. Here, this should help expand it further: $icecream = $form-addSelectList('list', icecream[flavor][], 1, true, 'xml', 'icecream.xml', '//flavour'); The above code will add a select list into the current form (the contents of which come from the icecream.xml file, using the xpath query at the end, but this isn't relevant to the problem) The 2nd parameter is the form name. In this instance the flavors from the multi-select list will come into $_POST in: icecream[flavor] When the form is submitted I take all of these form elements, and if they exist in the filtered $_POST array, I re-populate them on error. If the input name is just 'icecream' then you can do a simple: if (isset($_POST[$input_name])) .. and get the submitted value back. If the input name is 'icecream[flavor][]' the above will no longer work. The problem is finding a way to expand the input name (which is a string) into a format that $_POST can be searched for. Or do the reverse, iterate through $_POST to find a match for the input name and get that value. 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] Keeping sessions
What do you mean by session server? I server dedicated (or it can also act as a web server, or the main web server) to storing sessions. How are you accessing the session data on another server? Usually by way of a database. -- Richard Heyes 0844 801 1072 http://www.websupportsolutions.co.uk Knowledge Base and HelpDesk software -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Keeping sessions
On Tuesday 19 June 2007 14:15:00 Stut wrote: Richard Heyes wrote: Stut wrote: Jorge González wrote: In a web server cluster, how do you do guys keep the php sessions? I mean, with Apache and mod_proxy_balanced you could have a cluster with apache backend webservers but If a user is logged into an php app then this user goes always to the same backend server and if that server goes down then the session is invalid. How to deal with sessions? Several options exist, but the most common is to store session data in a database that can be accessed by all of the web servers. Alternatives include using memcached but recently I read something that suggested that can be problematic. I believe the cluster support in Zend Platform includes this functionality, so depending on your budget that may also be an option. Just a note: you could have either one of the web servers acting as the session server which the other web servers use or, if need be, a dedicated session server. I wouldn't imagine you'd need that though unless your site's really busy. What do you mean by session server? How are you accessing the session data on another server? -Stut -- http://stut.net/ Via Memcached or mysql server which only holds session data. Regards Sancar -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Keeping sessions
Ok, you both are right but not what I need because web servers is for shared hosting with PHP then each user choose the way to develop their apps. Then one user maybe store sessions in DB but another one not. This should be on Apache or OS side. It's because I talk about ldirector, LVS and so I know this is a PHP and not an Apache list but maybe someone is doing this with web hosting... cheers! Stut escribió: Richard Heyes wrote: Stut wrote: Jorge González wrote: In a web server cluster, how do you do guys keep the php sessions? I mean, with Apache and mod_proxy_balanced you could have a cluster with apache backend webservers but If a user is logged into an php app then this user goes always to the same backend server and if that server goes down then the session is invalid. How to deal with sessions? Several options exist, but the most common is to store session data in a database that can be accessed by all of the web servers. Alternatives include using memcached but recently I read something that suggested that can be problematic. I believe the cluster support in Zend Platform includes this functionality, so depending on your budget that may also be an option. Just a note: you could have either one of the web servers acting as the session server which the other web servers use or, if need be, a dedicated session server. I wouldn't imagine you'd need that though unless your site's really busy. What do you mean by session server? How are you accessing the session data on another server? -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Comparing string to array
Richard Davey wrote: Hi Stut, Tuesday, June 19, 2007, 12:09:12 PM, you wrote: If you have no control over what the fields in the form will be, what are you doing with the data? Surely if you're writing logic that requires you to know what the fields are called, you need to have control over it. Here, this should help expand it further: $icecream = $form-addSelectList('list', icecream[flavor][], 1, true, 'xml', 'icecream.xml', '//flavour'); The above code will add a select list into the current form (the contents of which come from the icecream.xml file, using the xpath query at the end, but this isn't relevant to the problem) The 2nd parameter is the form name. In this instance the flavors from the multi-select list will come into $_POST in: icecream[flavor] When the form is submitted I take all of these form elements, and if they exist in the filtered $_POST array, I re-populate them on error. If the input name is just 'icecream' then you can do a simple: if (isset($_POST[$input_name])) .. and get the submitted value back. If the input name is 'icecream[flavor][]' the above will no longer work. The problem is finding a way to expand the input name (which is a string) into a format that $_POST can be searched for. Or do the reverse, iterate through $_POST to find a match for the input name and get that value. Try this overly commented snippet on for size... http://dev.stut.net/php/davey.php -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Keeping sessions
Richard Heyes wrote: What do you mean by session server? I server dedicated (or it can also act as a web server, or the main web server) to storing sessions. How are you accessing the session data on another server? Usually by way of a database. Ok, that's basically what I suggested. Just wanted to make sure there wasn't another way I wasn't aware of. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date
Hello, There's another way out there using mysql SELECT DATE_ADD('$expiry_date', INTERVAL 7 DAY) as fDate but off course not a recommended way. In fact you can use it update query (update tbl_name set expiry_date = date_add('$expiry_date', INTERVAL 7 DAY) where user ='$user') -- Shafiq Rehman (ZCE) http://www.phpgurru.com | http://shafiq.pk Cell: +92 300 423 9385 On 6/19/07, Richard Heyes [EMAIL PROTECTED] wrote: Larry Garfield wrote: (Note: strtotime() is probably not the fastest to execute way of doing it, but it's the fastest to write. Choose wisely.) Is it? How about: $timestamp = strtotime($expiry_date) + (86400 * 7); -- Richard Heyes 0844 801 1072 http://www.websupportsolutions.co.uk Knowledge Base and HelpDesk software -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] Comparing string to array
Hi Stut, Tuesday, June 19, 2007, 1:16:54 PM, you wrote: The problem is finding a way to expand the input name (which is a string) into a format that $_POST can be searched for. Or do the reverse, iterate through $_POST to find a match for the input name and get that value. Try this overly commented snippet on for size... http://dev.stut.net/php/davey.php Very nice, thank you. I was hoping there would be a way to do it without resorting to eval(), but if even you can't figure out how, I'm not going to waste any more time trying to either :) I loved this part: // The target - offensive American spelling! :) 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] Date
Shafiq Rehman wrote: Hello, There's another way out there using mysql SELECT DATE_ADD('$expiry_date', INTERVAL 7 DAY) as fDate but of course not a recommended way. So why suggest it? In fact you can use it update query (update tbl_name set expiry_date = date_add('$expiry_date', INTERVAL 7 DAY) where user ='$user') Seriously, no. -- Richard Heyes 0844 801 1072 http://www.websupportsolutions.co.uk Knowledge Base and HelpDesk software -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Comparing string to array
preg_grep() or foreach($_POST as $value){ if(empty($value)) continue; $good_stuff[] = $value; } Richard Davey wrote: Hi all, Ok it's 2am, my brain has gone to mush and I am having trouble figuring out an easy way to do this, can anyone shed some light? Take a peek at the following code: // START pre ?php print_r($_POST); $userparam = test['sam'][]; // How to check if $userparam exists in the $_POST array // and get all the values from it? // Obviously this won't work, but you get the idea: if (isset($_POST[$userparam])) { echo 'yeah'; $values = $_POST[$userparam]; } else { echo 'nah'; } ? /pre form method=post input type=checkbox name=test['bob'][] value=redredbr input type=checkbox name=test['bob'][] value=greengreenbr input type=checkbox name=test['bob'][] value=bluebluebr input type=checkbox name=test['sam'][] value=red2red2br input type=checkbox name=test['sam'][] value=green2green2br input type=checkbox name=test['sam'][] value=blue2blue2br input type=submit /form // END From the code above I'm trying to figure out how to tell if the $userparam exists in the $_POST array. PHP automatically expands the form element name into multi-dim arrays within $_POST, so a simple 'isset' as shown in the code above won't play because it's got a totally useless array key passed to it. I need a way to turn the string: test['sam'][] into something I can look into $_POST for. Any ideas? The coffee boost is wearing off, but I want to get this licked tonight :-\ Cheers, Rich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Comparing string to array
Richard Davey wrote: Hi Stut, Tuesday, June 19, 2007, 1:16:54 PM, you wrote: The problem is finding a way to expand the input name (which is a string) into a format that $_POST can be searched for. Or do the reverse, iterate through $_POST to find a match for the input name and get that value. Try this overly commented snippet on for size... http://dev.stut.net/php/davey.php Very nice, thank you. I was hoping there would be a way to do it without resorting to eval(), but if even you can't figure out how, I'm not going to waste any more time trying to either :) You probably could by breaking it into each part and then using a loop to descend to the right place, but I don't think that's going to be any better than using eval. I'm assuming the source for $target is trusted. If not then you'll want to sanitise it further by removing anything that's not a-z, 0-9 and [] just to ensure no dodgy code can be inserted. I loved this part: // The target - offensive American spelling! :) Cheers, No probs. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Keeping sessions
Jorge González wrote: Ok, you both are right but not what I need because web servers is for shared hosting with PHP then each user choose the way to develop their apps. Then one user maybe store sessions in DB but another one not. This should be on Apache or OS side. It's because I talk about ldirector, LVS and so I know this is a PHP and not an Apache list but maybe someone is doing this with web hosting... Not only is this a PHP list, but your problem is a PHP problem. I'm shocked. No, really. Apache does *not* get involved in sessions. Not at all. You could put in a custom session handler using a prepended file. See the php.ini configuration option auto_prepend_file. I think there are also extensions available that drop in to replace the session extension - suggest you search the PECL site for those (http://pecl.php.net/). Of course you need to be aware that any PHP script can override both of these options. Just to clarify, you're building a shared hosting system that load balances all sites across a cluster of web servers? If not, please explain what it is you're actually trying to do. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date
On 6/19/07, Richard Heyes [EMAIL PROTECTED] wrote: Shafiq Rehman wrote: Hello, There's another way out there using mysql SELECT DATE_ADD('$expiry_date', INTERVAL 7 DAY) as fDate but of course not a recommended way. So why suggest it? just to share the knowledge In fact you can use it update query (update tbl_name set expiry_date = date_add('$expiry_date', INTERVAL 7 DAY) where user ='$user') Seriously, no. -- Richard Heyes 0844 801 1072 http://www.websupportsolutions.co.uk Knowledge Base and HelpDesk software -- Shafiq Rehman (ZCE) http://www.phpgurru.com | http://shafiq.pk Cell: +92 300 423 9385
Re: [PHP] Re: Comparing string to array
Hi Al, Tuesday, June 19, 2007, 1:46:47 PM, you wrote: preg_grep() or foreach($_POST as $value){ if(empty($value)) continue; $good_stuff[] = $value; } A classic case of not reading the post fully methinks. 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[2]: [PHP] Comparing string to array
Hi Stut, Tuesday, June 19, 2007, 1:49:53 PM, you wrote: Very nice, thank you. I was hoping there would be a way to do it without resorting to eval(), but if even you can't figure out how, I'm not going to waste any more time trying to either :) You probably could by breaking it into each part and then using a loop to descend to the right place, but I don't think that's going to be any better than using eval. I was wondering about doing something like this: Recurse through $_POST, grabbing all of the keys, and then building a string from them, something like: icecream_batch2_flavours and then storing the value of 'flavours' in a new array with the above as the key. Then I could manipulate the form input name: name=icecream[batch2][flavours][] or name=icecream['batch2']['flavours'][] To resemble the above key relatively simply. 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: php framework, large site
At 9:35 PM -0400 6/18/07, Robert Cummings wrote: Some of the greatest science comes from those unaware of established rules and theories. There's the quote of the day. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Comparing string to array
Richard Davey wrote: Hi Stut, Tuesday, June 19, 2007, 1:49:53 PM, you wrote: Very nice, thank you. I was hoping there would be a way to do it without resorting to eval(), but if even you can't figure out how, I'm not going to waste any more time trying to either :) You probably could by breaking it into each part and then using a loop to descend to the right place, but I don't think that's going to be any better than using eval. I was wondering about doing something like this: Recurse through $_POST, grabbing all of the keys, and then building a string from them, something like: icecream_batch2_flavours and then storing the value of 'flavours' in a new array with the above as the key. Then I could manipulate the form input name: name=icecream[batch2][flavours][] or name=icecream['batch2']['flavours'][] To resemble the above key relatively simply. Not quite what I was thinking of. More like this: http://dev.stut.net/php/davey2.php -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Keeping sessions
Stut escribió: Jorge González wrote: Ok, you both are right but not what I need because web servers is for shared hosting with PHP then each user choose the way to develop their apps. Then one user maybe store sessions in DB but another one not. This should be on Apache or OS side. It's because I talk about ldirector, LVS and so I know this is a PHP and not an Apache list but maybe someone is doing this with web hosting... Not only is this a PHP list, but your problem is a PHP problem. I'm shocked. No, really. Ok :) Apache does *not* get involved in sessions. Not at all. Well the question is I was dealing with an Apache mod_proxy_balanced and plans to use LVS or ldirector for balancing between backend servers. I didn't know about other solutions. You could put in a custom session handler using a prepended file. See the php.ini configuration option auto_prepend_file. I think there are also extensions available that drop in to replace the session extension - suggest you search the PECL site for those (http://pecl.php.net/). Of course you need to be aware that any PHP script can override both of these options. Well, I'll see later, sounds great. Just to clarify, you're building a shared hosting system that load balances all sites across a cluster of web servers? If not, please explain what it is you're actually trying to do. yes, that is, and sessions are important. Users's session must be persistent in all cases: web server down, user jumpig between backend web servers, etc -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] if test
Jochem Maas wrote: please keep posts on list. jekillen wrote: On Jun 17, 2007, at 12:18 PM, Jochem Maas wrote: jekillen wrote: Hello again; does the following test pass if the file is successfully included: if( include( some file ) ) or does it pass with: if( ! include( some file ) ) have you tried it? Well, typically while waiting for a reply, which I thank you for, I did browse through My Oreilly text Programming php which did not have anything definitive, and looking at the manual which did not have anything completely satisfying, I did try it as if( include( some file ) ) and it worked. But I also testing a file that I knew would cause an error, sure enough the else conditional did smear error messages all over the browser window. I have no idea what else condition you mean and I also have no idea what these 'error messages' are or what they have to do with the original question (which I had assumed was about the testing return values from an include statement ... something you could have gleaned from the manual and a couple of tests. So I did: if(file_exists( some file )) { include(some file); } Thanks again JK Im not exactly sure either about what you mean but you could give it a try using try {} catch {} -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php framework, large site
At 1:41 PM +0800 6/19/07, Crayon Shin Chan wrote: On Tuesday 19 June 2007 09:35, Robert Cummings wrote: Some of the greatest science comes from those unaware of established rules and theories. I'm sure most people on the list aren't looking to make revolutionary advances in php programming. Most are simply looking for practical answers to practical questions. You missed the point. Science is not just about php programming and php programmers are not just concerned about php, but rather it's application -- and it's the application that touches all science. While list attendees seek solutions to their programming problems, I'm sure that most want to develop solid applications and hope they can contribute to the greater science. After all, like it or not, that's what we are doing anyway. And, along the way, some of us actually do grab the brass ring and make revolutionary advances. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Keeping sessions
Jorge González wrote: Stut escribió: Jorge González wrote: Ok, you both are right but not what I need because web servers is for shared hosting with PHP then each user choose the way to develop their apps. Then one user maybe store sessions in DB but another one not. This should be on Apache or OS side. It's because I talk about ldirector, LVS and so I know this is a PHP and not an Apache list but maybe someone is doing this with web hosting... Not only is this a PHP list, but your problem is a PHP problem. I'm shocked. No, really. Ok :) Indeed it is. Apache does *not* get involved in sessions. Not at all. Well the question is I was dealing with an Apache mod_proxy_balanced and plans to use LVS or ldirector for balancing between backend servers. I didn't know about other solutions. That doesn't change the fact that Apache does not get involved in sessions. Nor does mod_proxy_balanced, LVS or ldirector. Sessions are a PHP entity. The only part of them that leaves the PHP part of the solution is the session identifier which travels in cookies and/or URLs. Just to clarify, you're building a shared hosting system that load balances all sites across a cluster of web servers? If not, please explain what it is you're actually trying to do. yes, that is, and sessions are important. Users's session must be persistent in all cases: web server down, user jumpig between backend web servers, etc In that case you need to make sure you explain to your users/customers that they cannot use a custom session handler and expect it to work. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] if test
I am not sure what you are trying to accomplish, but maybe require( some file ) will be of more use to you. -Original Message- From: Kostas Papadimitriou [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 19, 2007 9:31 AM To: php-general@lists.php.net Subject: Re: [PHP] if test Jochem Maas wrote: please keep posts on list. jekillen wrote: On Jun 17, 2007, at 12:18 PM, Jochem Maas wrote: jekillen wrote: Hello again; does the following test pass if the file is successfully included: if( include( some file ) ) or does it pass with: if( ! include( some file ) ) have you tried it? Well, typically while waiting for a reply, which I thank you for, I did browse through My Oreilly text Programming php which did not have anything definitive, and looking at the manual which did not have anything completely satisfying, I did try it as if( include( some file ) ) and it worked. But I also testing a file that I knew would cause an error, sure enough the else conditional did smear error messages all over the browser window. I have no idea what else condition you mean and I also have no idea what these 'error messages' are or what they have to do with the original question (which I had assumed was about the testing return values from an include statement ... something you could have gleaned from the manual and a couple of tests. So I did: if(file_exists( some file )) { include(some file); } Thanks again JK Im not exactly sure either about what you mean but you could give it a try using try {} catch {} -- 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] Re: php framework, large site
On 6/19/07, tedd [EMAIL PROTECTED] wrote: At 9:35 PM -0400 6/18/07, Robert Cummings wrote: Some of the greatest science comes from those unaware of established rules and theories. There's the quote of the day. Second. -- 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
Re: [PHP] Keeping sessions
Stut wrote: Jorge González wrote: Stut escribió: Jorge González wrote: Ok, you both are right but not what I need because web servers is for shared hosting with PHP then each user choose the way to develop their apps. Then one user maybe store sessions in DB but another one not. This should be on Apache or OS side. It's because I talk about ldirector, LVS and so I know this is a PHP and not an Apache list but maybe someone is doing this with web hosting... Not only is this a PHP list, but your problem is a PHP problem. I'm shocked. No, really. Ok :) Indeed it is. Apache does *not* get involved in sessions. Not at all. Well the question is I was dealing with an Apache mod_proxy_balanced and plans to use LVS or ldirector for balancing between backend servers. I didn't know about other solutions. That doesn't change the fact that Apache does not get involved in sessions. Nor does mod_proxy_balanced, LVS or ldirector. Sessions are a PHP entity. The only part of them that leaves the PHP part of the solution is the session identifier which travels in cookies and/or URLs. Just to clarify, you're building a shared hosting system that load balances all sites across a cluster of web servers? If not, please explain what it is you're actually trying to do. yes, that is, and sessions are important. Users's session must be persistent in all cases: web server down, user jumpig between backend web servers, etc In that case you need to make sure you explain to your users/customers that they cannot use a custom session handler and expect it to work. race conditions aside I think they could use a custom handler that makes use the [mysql?] database that comes with their account (I'm assuming that the DB server is also centralized/replicated.) ... I agree with Stut that your going to want to make information available about all this to your users/customers in big cow-sized letters. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php framework, large site
Robert Cummings wrote: Some of the greatest science comes from those unaware of established rules and theories. Third. not that my complete lack of knowledge theory and complete lack of respect for rules has come to any kind of fruition :-P PS - the troll seems to been subdued? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Novice Question - Viewing Errors
I am just beginning to learn about PHP. It seems as though if I make a code error... The PHP page will simply come up blank. ( Not too helpful for error checking) - I would like to see some kind of report on the page as to what went wrong. I have tried adding various lines of code to my page - from the link below - however I still get a blank page when errors occur... display_errors(1); error_reporting (E_ALL); Etc I have read that possibly the errors are being sent to kind of error log - rather than the page? Q: How can I get the error reporting show up on the page so I can see it? - - - - - From: PHP: Error Handling and Logging Functions - Manual Location: http://www.php.net/manual/en/ref.errorfunc.php - - - - - XXXIII. Error Handling and Logging Functions -- Thanks - RevDave [EMAIL PROTECTED] [db-lists] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Novice Question - Viewing Errors
On 6/19/07, revDAVE [EMAIL PROTECTED] wrote: I am just beginning to learn about PHP. It seems as though if I make a code error... The PHP page will simply come up blank. ( Not too helpful for error checking) - I would like to see some kind of report on the page as to what went wrong. I have tried adding various lines of code to my page - from the link below - however I still get a blank page when errors occur... display_errors(1); error_reporting (E_ALL); Etc I have read that possibly the errors are being sent to kind of error log - rather than the page? Q: How can I get the error reporting show up on the page so I can see it? - - - - - From: PHP: Error Handling and Logging Functions - Manual Location: http://www.php.net/manual/en/ref.errorfunc.php - - - - - XXXIII. Error Handling and Logging Functions -- Thanks - RevDave [EMAIL PROTECTED] [db-lists] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php If it's a shared host, your administrator may have disabled it. If it's your own box, check your php.ini settings for errors and output. -- 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
Re: [PHP] Novice Question - Viewing Errors
On 6/19/07, Daniel Brown [EMAIL PROTECTED] wrote: On 6/19/07, revDAVE [EMAIL PROTECTED] wrote: I am just beginning to learn about PHP. It seems as though if I make a code error... The PHP page will simply come up blank. ( Not too helpful for error checking) - I would like to see some kind of report on the page as to what went wrong. I have tried adding various lines of code to my page - from the link below - however I still get a blank page when errors occur... display_errors(1); error_reporting (E_ALL); Etc I have read that possibly the errors are being sent to kind of error log - rather than the page? Q: How can I get the error reporting show up on the page so I can see it? - - - - - From: PHP: Error Handling and Logging Functions - Manual Location: http://www.php.net/manual/en/ref.errorfunc.php - - - - - XXXIII. Error Handling and Logging Functions -- Thanks - RevDave [EMAIL PROTECTED] [db-lists] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php If it's a shared host, your administrator may have disabled it. If it's your own box, check your php.ini settings for errors and output. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 Also, to answer the question that you didn't ask check in the same directory as the scripts for a file named `error_log`. -- 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
Re: [PHP] Novice Question - Viewing Errors
revDAVE wrote: I am just beginning to learn about PHP. It seems as though if I make a code error... The PHP page will simply come up blank. ( Not too helpful for error checking) - I would like to see some kind of report on the page as to what went wrong. I have tried adding various lines of code to my page - from the link below - however I still get a blank page when errors occur... if you make an syntax error then your script will never be run, in which case the error reporting settings will never be set by your script. if your on a local/dev machine try changing the relevant ini settings in php.ini alternatively if you have the ability to use a .htaccess file (apache webserver) the you can add the following 2 lines to set the error_reporting: php_value display_errors On php_value error_reporting 2048 (I wrote than off the top of my head - please check the manual for exact ini setting names and values) alternatively you could may 'tail' the relevant error_log (most often this is the apache error log) you can check what the current ini setting for something is using this: echo ini_get(error_reporting); display_errors(1); error_reporting (E_ALL); Etc I have read that possibly the errors are being sent to kind of error log - rather than the page? Q: How can I get the error reporting show up on the page so I can see it? - - - - - From: PHP: Error Handling and Logging Functions - Manual Location: http://www.php.net/manual/en/ref.errorfunc.php - - - - - XXXIII. Error Handling and Logging Functions -- Thanks - RevDave [EMAIL PROTECTED] [db-lists] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Wiki lib?
Hi, Do any of you guys know of a good php library to use as a base if one wants to develop a simple wiki? I don't want a complete system like MediaWiki, I want a library that can compare different versions of text, and so on. I first thought of using subversion, but it seems a bit overkill. It would be really neat with a small php library under LGPL or BSD or similiar license. Any ideas? -- Regards Emil Edeholt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Wiki lib?
On 6/19/07, Emil Edeholt [EMAIL PROTECTED] wrote: I want a library that can compare different versions of text, Command line diff wrapped in exec() calls should work fine. -- Greg Donald http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink before imagepng?
On 6/17/07, Brian Dunning [EMAIL PROTECTED] wrote: If I write an edited image back to disk using imagepng, is it desirable to first unlink the existing image? It's not required. I notice that it works fine if I don't. Just wondering if there are any pros or cons. Just be sure and call clearstatcache() so your changes show up immediately. -- Greg Donald http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New htmlentities() '$double_enocde' Param Question
On 6/17/07, Chris [EMAIL PROTECTED] wrote: I just need a clarification about the new $double_encode param for htmlentities() and htmlspecialchars(). Is it supposed to do as I expect it to do in the code below or am I misuderstanding its use? // Output: lt; echo htmlentities('', ENT_QUOTES, false); // Expected Output: lt; // Actual Output: amp;lt; echo htmlentities(htmlentities('', ENT_QUOTES, false), ENT_QUOTES, false); Your false value for your htmlentities() call should be the 4th parameter, not the 3rd. -- Greg Donald http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file charset: something like file -i
On 6/14/07, Martin Marques [EMAIL PROTECTED] wrote: Is there something like the UNIX command file -i to know the charset of a file? I don't want to use a system call, so I was wondering if there was some predefined function in PHP. P.D.: I'm using PHP 5.2.0 http://us.php.net/manual/en/ref.fileinfo.php Examples in the comments. -- Greg Donald http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP calling an ISAPI Extension
Tijnema wrote: On 6/19/07, Jim Lucas [EMAIL PROTECTED] wrote: Dan wrote: I wish I could, I can't count on the script being on a linux machine. I also can't expect people to rebuild PHP with the curl library just to use my script. Is there any other way to do a post to a page from a php function? - Daniel Jim Lucas [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Dan wrote: I would normaly do it with an AJAX call but I need to do a post from WITHIN a PHP function, so when it's doing php stuff ex. function something() { echo 'whatever'; $response = post some data to a ISAPI Extension eg. post to http://domain.com/scripts/app.dll return $response . other data; } Jay Blanchard [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [snip] I'm in need of a way to contact an ISAPI Extension from a PHP function. Does anyone know how I would be able to do this? Usually you would post a page to their URL/actionname. Can I do a POST from a PHP function without reloading the page, and get a result back? That's one tall order. Anyone want to give it a shot? [/snip] Do the POST with an AJAX call perform an ajax call the a php script that calls curl to do a post to the ISAPI extension -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare The only method that I am aware of is the fsockopen method you mention in your other email -- Jim Lucas Yes, and what's wrong with it? where did I infer that their was something wrong with the fsockopen method? ?php $post_data = form_a=1form_b=4; $fp = fsockopen(www.domain.com,80); fwrite($fp,POST /scripts/app.dll HTTP/1.1\r\nHost: www.domain.com\r\nContent-Length: .strlen($post_data).\r\n\r\n.$post_data); $result = fread($fp,102400); // Reads 100KB, change if you need more ? That's not too long is it? Tijnema -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Comparing string to array
Richard Davey wrote: Hi all, Ok it's 2am, my brain has gone to mush and I am having trouble figuring out an easy way to do this, can anyone shed some light? Take a peek at the following code: // START pre ?php print_r($_POST); $userparam = test['sam'][]; // How to check if $userparam exists in the $_POST array // and get all the values from it? // Obviously this won't work, but you get the idea: if (isset($_POST[$userparam])) { echo 'yeah'; $values = $_POST[$userparam]; } else { echo 'nah'; } ? /pre form method=post input type=checkbox name=test['bob'][] value=redredbr input type=checkbox name=test['bob'][] value=greengreenbr input type=checkbox name=test['bob'][] value=bluebluebr input type=checkbox name=test['sam'][] value=red2red2br input type=checkbox name=test['sam'][] value=green2green2br input type=checkbox name=test['sam'][] value=blue2blue2br DON'T USE SINGLE QUOTES IN YOUR NAME= ATTRIBUTE input type=checkbox name=test[bob][red] value=redredbr input type=checkbox name=test[bob][green] value=greengreenbr input type=checkbox name=test[bob][blue] value=bluebluebr input type=checkbox name=test[sam][red] value=redredbr input type=checkbox name=test[sam][green] value=greengreenbr input type=checkbox name=test[sam][blue] value=bluebluebr Now print_r() should show this. Array ( [test] = Array ( ['bob'] = Array -- notice the single quotes?? they are in your actual value ( [red] = red [green] = green [blue] = blue ) [sam] = Array ( [red] = red [green] = green [blue] = blue ) ) ) input type=submit /form // END From the code above I'm trying to figure out how to tell if the $userparam exists in the $_POST array. PHP automatically expands the form element name into multi-dim arrays within $_POST, so a simple 'isset' as shown in the code above won't play because it's got a totally useless array key passed to it. I need a way to turn the string: test['sam'][] into something I can look into $_POST for. Any ideas? The coffee boost is wearing off, but I want to get this licked tonight :-\ Cheers, Rich -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] Comparing string to array
Hi Jim, Tuesday, June 19, 2007, 5:06:47 PM, you wrote: DON'T USE SINGLE QUOTES IN YOUR NAME= ATTRIBUTE Hate to piss on your bonfire but a single quote is a perfectly valid (if somewhat stupid choice of) character for inclusion in an array key. 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] Comparing string to array
Richard Davey wrote: Hi Jim, Tuesday, June 19, 2007, 5:06:47 PM, you wrote: DON'T USE SINGLE QUOTES IN YOUR NAME= ATTRIBUTE Hate to piss on your bonfire but a single quote is a perfectly valid (if somewhat stupid choice of) character for inclusion in an array key. Cheers, Rich in this case, it isn't a valid char. Look at his output, you will see that the single quotes are being included in the actual value of the submitted array. So, in this case, they will mess with his comparison. you'll be comparing 'bob' not bob Look at the output a little closer... -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Comparing string to array
Richard Davey wrote: Hi Jim, Tuesday, June 19, 2007, 5:06:47 PM, you wrote: DON'T USE SINGLE QUOTES IN YOUR NAME= ATTRIBUTE Hate to piss on your bonfire but a single quote is a perfectly valid (if somewhat stupid choice of) character for inclusion in an array key. Cheers, Rich if you use var_dump() instead of print_r() you will see what I am talking about. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Comparing string to array
Richard Davey wrote: Hi Jim, Tuesday, June 19, 2007, 5:06:47 PM, you wrote: DON'T USE SINGLE QUOTES IN YOUR NAME= ATTRIBUTE where in this sentence did I say that it was invalid? just told you not to use them, because it is going to mess with your output Hate to piss on your bonfire but a single quote is a perfectly valid (if somewhat stupid choice of) character for inclusion in an array key. Cheers, Rich -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] Comparing string to array
Hi Jim, Tuesday, June 19, 2007, 5:29:55 PM, you wrote: Richard Davey wrote: Hi Jim, Tuesday, June 19, 2007, 5:06:47 PM, you wrote: DON'T USE SINGLE QUOTES IN YOUR NAME= ATTRIBUTE Hate to piss on your bonfire but a single quote is a perfectly valid (if somewhat stupid choice of) character for inclusion in an array key. Cheers, Rich in this case, it isn't a valid char. Look at his output, you will see that the single quotes are being included in the actual value of the submitted array. Read the rest of the thread, specifically the code given by Stut, the single quote makes bugger-all difference to the comparison I'm afraid, the problem at hand is much deeper than that. Look at the output a little closer... No need, it's *my* output, and I've been looking at it very closely for hours now, and believe me quotes aren't the issue (if only it was that simple a solution) 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] Force zero numbers on a integer
Hello, I have a integer that is submitted by the user and i need it to always contain 5 digits. If the user submitted 45, i need it to be 00045. If the user submitted 4595, i need it to be 04595. How can i do this? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP calling an ISAPI Extension
You meant imply, infer is when you draw a conclusion based on what one already knows. Imply on the other hand means something you expressed or stated indirectly. Sorry, that's just one thing I can't pass up correcting people on :(. Jim Lucas [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Tijnema wrote: On 6/19/07, Jim Lucas [EMAIL PROTECTED] wrote: Dan wrote: I wish I could, I can't count on the script being on a linux machine. I also can't expect people to rebuild PHP with the curl library just to use my script. Is there any other way to do a post to a page from a php function? - Daniel Jim Lucas [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Dan wrote: I would normaly do it with an AJAX call but I need to do a post from WITHIN a PHP function, so when it's doing php stuff ex. function something() { echo 'whatever'; $response = post some data to a ISAPI Extension eg. post to http://domain.com/scripts/app.dll return $response . other data; } Jay Blanchard [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [snip] I'm in need of a way to contact an ISAPI Extension from a PHP function. Does anyone know how I would be able to do this? Usually you would post a page to their URL/actionname. Can I do a POST from a PHP function without reloading the page, and get a result back? That's one tall order. Anyone want to give it a shot? [/snip] Do the POST with an AJAX call perform an ajax call the a php script that calls curl to do a post to the ISAPI extension -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare The only method that I am aware of is the fsockopen method you mention in your other email -- Jim Lucas Yes, and what's wrong with it? where did I infer that their was something wrong with the fsockopen method? ?php $post_data = form_a=1form_b=4; $fp = fsockopen(www.domain.com,80); fwrite($fp,POST /scripts/app.dll HTTP/1.1\r\nHost: www.domain.com\r\nContent-Length: .strlen($post_data).\r\n\r\n.$post_data); $result = fread($fp,102400); // Reads 100KB, change if you need more ? That's not too long is it? Tijnema -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fsocketopen not returning data properly
I got the function from the web, the implementation I did myself, echo httpSoc... Maybe I'm not using the function right because I keep getting a fatal error of: Fatal error: Call to undefined function logEventToTextFile() on line 79 Does it look like I'm implementing the code correctly? And I tried with GET, I get the same error. - Daniel Tijnema [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 6/19/07, Dan [EMAIL PROTECTED] wrote: I'm having trouble with sockets in PHP, if anyone has the time to help out that would be awesome. I am trying to get the result of a post There are a lot of people that are probably willing to help, but what is your exact problem? echo httpSocketConnection(www.google.com, POST, /search, q=test, 80); This should post to google.com with a query of test. Then give me the response. The function I'm using is below. Google doesn't wants a POST request, make it a GET request and it should work. Here's the function's code: snip You copied this straight from the web? If so, then there are probably no bugs in it. Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP calling an ISAPI Extension
Yes, the ISAPI would be on the same machine, sorry I didn't mention that earlier. I'll go take a look at COM. - Daniel Jochem Maas [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Dan wrote: For example, I could use function fsockopen but that seems like it would probably be pretty slow doing all that, and if there's a php function or small script that would be preferable over the 50/60 lines you would need to do it properly with fsockopen. with the caveat that it'll only work as a GET request (which probably means no cigar for you), and requires that your php is setup to allow open urls (ini setting 'allow_url_fopen') $response = file_get_contents('http://your.iis.machine/some/path/some_isapi.dll?foo=bar'); otherwise the fsockopen() route is all that seems to be open to you, given that curl reliance is a no-no. - the biggest factor in the response speed is likely to be the server at the other end (assuming the network connection between the 2 machines is generally ok), so if things are slow you might consider caching the results locally (again, assuming that this is feasable.) is the isapi extension on the same machine? if so maybe it has a COM interface with which you can talk to it? http://php.net/com no idea if that is feasible - I've never really used IIS, let alone had to deal with isapi extensions. - Daniel Jay Blanchard [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [snip] I'm in need of a way to contact an ISAPI Extension from a PHP function. Does anyone know how I would be able to do this? Usually you would post a page to their URL/actionname. Can I do a POST from a PHP function without reloading the page, and get a result back? That's one tall order. Anyone want to give it a shot? [/snip] Do the POST with an AJAX call -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Comparing string to array
Jim Lucas wrote: Richard Davey wrote: Hi Jim, Tuesday, June 19, 2007, 5:06:47 PM, you wrote: DON'T USE SINGLE QUOTES IN YOUR NAME= ATTRIBUTE Hate to piss on your bonfire but a single quote is a perfectly valid (if somewhat stupid choice of) character for inclusion in an array key. Cheers, Rich in this case, it isn't a valid char. Look at his output, you will see that the single quotes are being included in the actual value of the submitted array. So, in this case, they will mess with his comparison. you'll be comparing 'bob' not bob Look at the output a little closer... I'm not sure who's output you are referring to, but while you're making sense as a comment to a competely different question, it's not relevant to this question. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP calling an ISAPI Extension
I've looked arround and I can't find any mention of ISAPI COM, it's a pretty low level way of making applications, you used to be able to install PHP itself as a COM application on IIS to do PHP stuff. Is there any sort of compatiblity list for com? - Daniel Jochem Maas [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Dan wrote: For example, I could use function fsockopen but that seems like it would probably be pretty slow doing all that, and if there's a php function or small script that would be preferable over the 50/60 lines you would need to do it properly with fsockopen. with the caveat that it'll only work as a GET request (which probably means no cigar for you), and requires that your php is setup to allow open urls (ini setting 'allow_url_fopen') $response = file_get_contents('http://your.iis.machine/some/path/some_isapi.dll?foo=bar'); otherwise the fsockopen() route is all that seems to be open to you, given that curl reliance is a no-no. - the biggest factor in the response speed is likely to be the server at the other end (assuming the network connection between the 2 machines is generally ok), so if things are slow you might consider caching the results locally (again, assuming that this is feasable.) is the isapi extension on the same machine? if so maybe it has a COM interface with which you can talk to it? http://php.net/com no idea if that is feasible - I've never really used IIS, let alone had to deal with isapi extensions. - Daniel Jay Blanchard [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [snip] I'm in need of a way to contact an ISAPI Extension from a PHP function. Does anyone know how I would be able to do this? Usually you would post a page to their URL/actionname. Can I do a POST from a PHP function without reloading the page, and get a result back? That's one tall order. Anyone want to give it a shot? [/snip] Do the POST with an AJAX call -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Comparing string to array
Stut wrote: Jim Lucas wrote: Richard Davey wrote: Hi Jim, Tuesday, June 19, 2007, 5:06:47 PM, you wrote: DON'T USE SINGLE QUOTES IN YOUR NAME= ATTRIBUTE Hate to piss on your bonfire but a single quote is a perfectly valid (if somewhat stupid choice of) character for inclusion in an array key. Cheers, Rich in this case, it isn't a valid char. Look at his output, you will see that the single quotes are being included in the actual value of the submitted array. So, in this case, they will mess with his comparison. you'll be comparing 'bob' not bob Look at the output a little closer... I'm not sure who's output you are referring to, but while you're making sense as a comment to a competely different question, it's not relevant to this question. -Stut What do you mean? This is the op's output Array ( [test] = Array ( ['bob'] = Array ( [0] = red [1] = green [2] = blue ) ) ) Do you see the single quotes in the array hey at the second level?? They should not be there. it will mess with things. but, for the op here is what I think you might be looking for. pre ?php $user = sam; if ( isset($_POST['test'][$user]) count($_POST['test'][$user]) 0 ) { echo yeah\n; echo join(':', $_POST['test'][$user]); } else { echo 'nah'; } ? /pre form method=post input type=checkbox name=test[bob][red] value=redredbr input type=checkbox name=test[bob][green] value=greengreenbr input type=checkbox name=test[bob][blue] value=bluebluebr input type=checkbox name=test[sam][red] value=redredbr input type=checkbox name=test[sam][green] value=greengreenbr input type=checkbox name=test[sam][blue] value=bluebluebr input type=submit /form -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Comparing string to array
Jim Lucas wrote: $userparam = test['sam'][]; then what you are saying it that this HAS to be your search string? -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] Comparing string to array
Hi Jim, Tuesday, June 19, 2007, 5:47:29 PM, you wrote: Jim Lucas wrote: $userparam = test['sam'][]; then what you are saying it that this HAS to be your search string? Heck no, it doesn't *have* to be. Feel free to remove the quotes from it and then attempt my original question again. It's still not as simple as an isset() or count() call. (but boy I wish it was!) 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] PHP calling an ISAPI Extension
I modified your code to work with what I'm doing and this is what I got: $post_data = name=wowlikes=true; $fp = fsockopen(localhost,8080); fwrite($fp,POST /Project1.dll HTTP/1.1\r\nHost: localhost\r\nContent-Length: .strlen($post_data).\r\n\r\n.$post_data); $result = fread($fp,102400); // Reads 100KB, change if you need more echo $result; Now when I try that I get a Bad Request invalid header name error. I have an IIS server running localy on port 8080, the Project1.dll is in the root directory, it contains two input components 1 a textfield to type your name, the other a checkbox called likes. What's wrong? Here's it's code: html head titleLearning ISAPI/title /head h3Learning ISAPI!/h3 form name=isapiform method=POST action=/Project1.dll strongPlease enter the following information/strong brName: input type=text name=name brinput type=checkbox name=likes value=true checked I like ISAPI!p input type=submit value=View Output /form /html Tijnema [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 6/19/07, Jim Lucas [EMAIL PROTECTED] wrote: Dan wrote: I wish I could, I can't count on the script being on a linux machine. I also can't expect people to rebuild PHP with the curl library just to use my script. Is there any other way to do a post to a page from a php function? - Daniel Jim Lucas [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Dan wrote: I would normaly do it with an AJAX call but I need to do a post from WITHIN a PHP function, so when it's doing php stuff ex. function something() { echo 'whatever'; $response = post some data to a ISAPI Extension eg. post to http://domain.com/scripts/app.dll return $response . other data; } Jay Blanchard [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [snip] I'm in need of a way to contact an ISAPI Extension from a PHP function. Does anyone know how I would be able to do this? Usually you would post a page to their URL/actionname. Can I do a POST from a PHP function without reloading the page, and get a result back? That's one tall order. Anyone want to give it a shot? [/snip] Do the POST with an AJAX call perform an ajax call the a php script that calls curl to do a post to the ISAPI extension -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare The only method that I am aware of is the fsockopen method you mention in your other email -- Jim Lucas Yes, and what's wrong with it? ?php $post_data = form_a=1form_b=4; $fp = fsockopen(www.domain.com,80); fwrite($fp,POST /scripts/app.dll HTTP/1.1\r\nHost: www.domain.com\r\nContent-Length: .strlen($post_data).\r\n\r\n.$post_data); $result = fread($fp,102400); // Reads 100KB, change if you need more ? That's not too long is it? Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Force zero numbers on a integer
On Tue, 2007-06-19 at 13:17 -0300, [EMAIL PROTECTED] wrote: I have a integer that is submitted by the user and i need it to always contain 5 digits. str_pad($userSubmittedNumber, 5, 0, 0); --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Comparing string to array
Jim Lucas wrote: Stut wrote: Jim Lucas wrote: Richard Davey wrote: Hi Jim, Tuesday, June 19, 2007, 5:06:47 PM, you wrote: DON'T USE SINGLE QUOTES IN YOUR NAME= ATTRIBUTE Hate to piss on your bonfire but a single quote is a perfectly valid (if somewhat stupid choice of) character for inclusion in an array key. Cheers, Rich in this case, it isn't a valid char. Look at his output, you will see that the single quotes are being included in the actual value of the submitted array. So, in this case, they will mess with his comparison. you'll be comparing 'bob' not bob Look at the output a little closer... I'm not sure who's output you are referring to, but while you're making sense as a comment to a competely different question, it's not relevant to this question. -Stut What do you mean? I thought I was pretty clear. This is the op's output Array ( [test] = Array ( ['bob'] = Array ( [0] = red [1] = green [2] = blue ) ) ) Do you see the single quotes in the array hey at the second level?? I do indeed. They should not be there. Why not? They're in the form so they're in the post data. Seems reasonable to me. it will mess with things. Only if you let it. Stand up to the quotes!! Fight for your rights!! but, for the op here is what I think you might be looking for. pre ?php $user = sam; if ( isset($_POST['test'][$user]) count($_POST['test'][$user]) 0 ) { echo yeah\n; echo join(':', $_POST['test'][$user]); } else { echo 'nah'; } ? /pre form method=post input type=checkbox name=test[bob][red] value=redredbr input type=checkbox name=test[bob][green] value=greengreenbr input type=checkbox name=test[bob][blue] value=bluebluebr input type=checkbox name=test[sam][red] value=redredbr input type=checkbox name=test[sam][green] value=greengreenbr input type=checkbox name=test[sam][blue] value=bluebluebr input type=submit /form That's so far off the mark it's just not funny. As Richard has suggested, read the full thread otherwise you're never going to understand what the actual problem was. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Comparing string to array
Richard Davey wrote: Hi Jim, Tuesday, June 19, 2007, 5:47:29 PM, you wrote: Jim Lucas wrote: $userparam = test['sam'][]; then what you are saying it that this HAS to be your search string? Heck no, it doesn't *have* to be. Feel free to remove the quotes from it and then attempt my original question again. It's still not as simple as an isset() or count() call. (but boy I wish it was!) Cheers, Rich well, here lets break it down. You need to know that for a given use, if they have any values set in the POST? Correct? What exactly are you looking to find. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Force zero numbers on a integer
Hi, Tuesday, June 19, 2007, 5:17:29 PM, you wrote: I have a integer that is submitted by the user and i need it to always contain 5 digits. If the user submitted 45, i need it to be 00045. If the user submitted 4595, i need it to be 04595. How can i do this? Given PHPs type switching abilities, this would work: http://uk2.php.net/str_pad but this would be more elegant: http://uk2.php.net/manual/en/function.sprintf.php 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] Force zero numbers on a integer
I have a integer that is submitted by the user and i need it to always contain 5 digits. If the user submitted 45, i need it to be 00045. If the user submitted 4595, i need it to be 04595. How can i do this? Check out printf(); http://us.php.net/manual/en/function.printf.php thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Comparing string to array
Richard Davey wrote: Hi Jim, Tuesday, June 19, 2007, 5:47:29 PM, you wrote: Jim Lucas wrote: $userparam = test['sam'][]; then what you are saying it that this HAS to be your search string? Heck no, it doesn't *have* to be. Feel free to remove the quotes from it and then attempt my original question again. It's still not as simple as an isset() or count() call. (but boy I wish it was!) Cheers, Rich let me try this again. in the submitted $_POST array, you are looking for a key (test) that contains a given $username that may or may not have any values set? Correct? -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] apache file paths
how do apache filepaths match the directories? This is my document root acording to $_SERVER /usr/local/apache/htdocs/ but I also sometimes see this /home/mysitename/public_html/ public_html is where I put my files via ftp so can someone explain where the 'home' folder is in relation to the document root? is the full path to the public html folder /usr/local/apache/htdocs/home/mysitename/public_html/ I have never got to grips with this. thanks, R. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Comparing string to array
Jim Lucas wrote: Richard Davey wrote: Hi Jim, Tuesday, June 19, 2007, 5:47:29 PM, you wrote: Jim Lucas wrote: $userparam = test['sam'][]; then what you are saying it that this HAS to be your search string? Heck no, it doesn't *have* to be. Feel free to remove the quotes from it and then attempt my original question again. It's still not as simple as an isset() or count() call. (but boy I wish it was!) Cheers, Rich let me try this again. in the submitted $_POST array, you are looking for a key (test) that contains a given $username that may or may not have any values set? Correct? Seriously, read the rest of the damn thread before trying again. As an example of how far off you are... $username has never appeared in this thread until you just said it. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Force zero numbers on a integer
[EMAIL PROTECTED] wrote: I have a integer that is submitted by the user and i need it to always contain 5 digits. If the user submitted 45, i need it to be 00045. If the user submitted 4595, i need it to be 04595. How can i do this? $val = str_pad(intval($val), 5, '0', STR_PAD_LEFT); -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] Comparing string to array
Hi Jim, Tuesday, June 19, 2007, 6:21:25 PM, you wrote: let me try this again. in the submitted $_POST array, you are looking for a key (test) that contains a given $username that may or may not have any values set? Correct? Sorry not even close. Here, let me try again... $param = 'test[batch1][colour][]'; (the above being a perfectly valid name for say a range of checkboxes in a form) Using just the above $param string, do this: $values = $_POST['test']['batch1']['colour']; Of course $param is a totally moving feast, and you don't know what it may contain, only that what it does contain WILL actually be in $_POST somewhere. The problem was turning the string 'test[batch1][colour][]' into a something from which you can pull the resulting values from the $_POST array. 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] Comparing string to array
Stut wrote: Jim Lucas wrote: Richard Davey wrote: Hi Jim, Tuesday, June 19, 2007, 5:47:29 PM, you wrote: Jim Lucas wrote: $userparam = test['sam'][]; then what you are saying it that this HAS to be your search string? Heck no, it doesn't *have* to be. Feel free to remove the quotes from it and then attempt my original question again. It's still not as simple as an isset() or count() call. (but boy I wish it was!) Cheers, Rich let me try this again. in the submitted $_POST array, you are looking for a key (test) that contains a given $username that may or may not have any values set? Correct? Seriously, read the rest of the damn thread before trying again. As an example of how far off you are... $username has never appeared in this thread until you just said it. -Stut You're not getting my point. Never mind. Maybe the op understands better. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php framework, large site
On Tuesday 19 June 2007 09:26, Robert Cummings wrote: Making up phrases and passing them off as though they are common adages only goes towards showing that you have no steam to your argument. I really wish you would make up your mind. On the one hand you value individuality and originality (or so you claim) and yet now you dismiss my quote because of it's lack of popularity? All great quotes comes from humble origins, and you yourself said that popularity does not equate to quality. I have little faith in your words now. If I wanted fallacious reasoning I'd go watch a commercial on the telly. Your loss, not mine :) You're not very good at this: http://en.wikipedia.org/wiki/Ad_hominem In that case could you point out to me where you mistake my pointing out projects' lack of updates equates to a project's lack of popularity. Read what I wrote above, I'm talking about UPDATES (or the lack of), not popularity. You implied it. Where? How? Maybe the English that they taught me at school is subtly different to the English that you learnt. It doesn't seem like you're exchanging ideas. That is a suggestion. I have plenty of ideas, but they would mostly be based on my experience writing InterJinn and what I hate about other frameworks I've come across, as such I chose to keep quiet rather than pollute his ideology with my own and sound like I'm tooting my own horn. I often find myself writing responses to people that are based on what I did or do in my framework... often I delete them before sending them because I don't like how it seems impartial. once in a while it still comes up, but I'm not perfect. The OP was not asking questions on _how_ a framework should behave or _what_ a framework should contain. Rather the question was how to _start_ [writing a] php framwork [sic]. Your answer, should it ever be forthcoming, need not pollute his innocent mind with your framework ideals. One of the ways to do anything is to just wade in. Er, obviously. Can't really argue with that statement. Another true statement is One of the ways to do anything is to study the situation before you wade in. So your point? Who are you to assess the OP's skills and determine that he is unable to make a reasonable assessment? I think you were the one assessing the OP's skills. You stated that evaluating the available frameworks is a staggering task, yet suggest that the OP go ahead and write his own framework. In my life experience, judging is easier than creating. I know a good book when I read one, a good meal when I eat one and a good movie when I see one, however I'm not sure I know how to write a good novel, cook a good meal or make a good movie. But going back to your point about narrowing it down, you've already jumped to the conclusion that the OP has no clue what he's doing and so it follows that he probably wouldn't know how to begin narrowing down the candidates since that would require experience. And yet he is able to put together a kickass framework sometime in the future through flirting with serendipity? So working as a one-person band on your very own framework how easy is it to get your code reviewed? And a security audit? I'm going to borrow a bit of your style here and make a fallacious statement... I write perfect code and I have no bugs. There, your ego is showing through again :) I was using you as in the royal One, not you as in you, Robert. Still, it's good to know that your code is flawless and can be relied upon. -- Crayon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php framework, large site
On Tuesday 19 June 2007 13:47, Robert Cummings wrote: No, it's simple probability. So it's probability now? Which has the greater probability: 1) study a selection of frameworks and learn from their strengths and weaknesses then go on to create a kickass framework based on what you've learnt 2) just jump right in a create a kickass framework Please note the distinction between possibility and probability. And many will encounter serendipity along the way regardless of what they are looking to achieve. Now we're bypassing logical argument and relying on serendipity? -- Crayon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php framework, large site
On Tuesday 19 June 2007 06:58, tedd wrote: Yes, but the fact still remains, for the exception of drug companies passing DNA sequences off as patents, In the bad old U S of A you can patent your own grandmother (or at least someone somewhere thinks you ought be able to). the *majority* of patents for inventions are due to the efforts of a lone risk taker putting his money, time, and effort on the line trying to invent something. I've no idea what the figures are but I find that hard to believe, do you have any sources to backup that claim? And, one *never* could conduct high energy particle physics experiments in my own basement and launch interplanetary space probes from my own backyard. Lighten up, it's satire. -- Crayon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Comparing string to array
Richard Davey wrote: Hi all, Ok it's 2am, my brain has gone to mush and I am having trouble figuring out an easy way to do this, can anyone shed some light? Take a peek at the following code: // START pre ?php print_r($_POST); $userparam = test['sam'][]; // How to check if $userparam exists in the $_POST array // and get all the values from it? // Obviously this won't work, but you get the idea: if (isset($_POST[$userparam])) { echo 'yeah'; $values = $_POST[$userparam]; } else { echo 'nah'; } ? /pre form method=post input type=checkbox name=test['bob'][] value=redredbr input type=checkbox name=test['bob'][] value=greengreenbr input type=checkbox name=test['bob'][] value=bluebluebr input type=checkbox name=test['sam'][] value=red2red2br input type=checkbox name=test['sam'][] value=green2green2br input type=checkbox name=test['sam'][] value=blue2blue2br input type=submit /form // END From the code above I'm trying to figure out how to tell if the $userparam exists in the $_POST array. PHP automatically expands the form element name into multi-dim arrays within $_POST, so a simple 'isset' as shown in the code above won't play because it's got a totally useless array key passed to it. I need a way to turn the string: test['sam'][] into something I can look into $_POST for. Any ideas? The coffee boost is wearing off, but I want to get this licked tonight :-\ Cheers, Rich taking a step back and looking a little closer at the problem. I have come up with this Which does not require eval() Maybe this will work for the OP pre ?php $param = 'test[sam][colors][]'; function find_within_array($string, $source) { $data = array(); $tmp = $source; if ( preg_match_all('/(\[?([\w]+)\]?)/', $string, $matches, PREG_SET_ORDER) ) { if ( count($matches) 1 ) { for ( $i = 0; $icount($matches); $i++ ) { if ( isset($tmp[$matches[$i][2]]) ) { if ( is_array($tmp[$matches[$i][2]]) ) { foreach ($tmp[$matches[$i][2]] AS $value ) { if ( is_string($value) ) { $data[] = $value; } } } $tmp = $tmp[$matches[$i][2]]; } } return $data; } } return array(); } $results = find_within_array($param, $_POST); if ( count($results) 0 ) { echo yeah\n; echo join(':', $results); } else { echo 'nah'; } ? /pre form method=post input type=checkbox name=test[bob][colors][] value=redredbr input type=checkbox name=test[bob][colors][] value=greengreenbr input type=checkbox name=test[bob][colors][] value=bluebluebr input type=checkbox name=test[sam][colors][] value=redredbr input type=checkbox name=test[sam][colors][] value=greengreenbr input type=checkbox name=test[sam][colors][] value=bluebluebr input type=submit /form -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] apache file paths
Ross [EMAIL PROTECTED] wrote: how do apache filepaths match the directories? The answer you don't want is however they were configured. :) You have seen some conventions. This is my document root acording to $_SERVER /usr/local/apache/htdocs/ The /usr/local/apache/ path is pretty common. I am seeing htdocs more frequently, but have also seen html and docroot. There is an entry in the apache ini file, httpd.conf, when the document root is specified, and you can pick any directory you like, subject to permissions, of course. but I also sometimes see this /home/mysitename/public_html/ When you have shared hosting, each user (domain) needs their own document root. These are created in the user directory area, which by convention is called /home. On my home system home is mounted to root, and is on its own drive. But this can vary for computer to computer. /usr/local/apache/htdocs/home/mysitename/public_html/ Here home is mounted in a rather uncommon place, but it should work. And whether public_html is used or htdocs, seems to be a choice made by the people who created the different control panels for mantaining apache servers that are set up to do virtual hosting. On of apaches .conf files has all the virtual document roots, and apache really doesn't care what the paths and directories are. (Subject again to permissioons!) Stephen
Re: [PHP] Re: php framework, large site
On Wed, 2007-06-20 at 02:20 +0800, Crayon Shin Chan wrote: On Tuesday 19 June 2007 09:26, Robert Cummings wrote: Making up phrases and passing them off as though they are common adages only goes towards showing that you have no steam to your argument. I really wish you would make up your mind. On the one hand you value individuality and originality (or so you claim) and yet now you dismiss my quote because of it's lack of popularity? All great quotes comes from humble origins, and you yourself said that popularity does not equate to quality. I didn't dismiss it for lack of popularity, I dismissed it for being passed off as an adage when it is not. If you had claimed from the onset of its usage that you made it up then I would have accepted it at face value. I have little faith in your words now. If I wanted fallacious reasoning I'd go watch a commercial on the telly. Your loss, not mine :) Nothing gained, nothing lost. You're not very good at this: http://en.wikipedia.org/wiki/Ad_hominem In that case could you point out to me where you mistake my pointing out projects' lack of updates equates to a project's lack of popularity. You attempted to use an Ad Hominem to discredit my argument by suggesting I was jealous at the lack of popularity of my own project. I'm sure that's why you quoted the Ad Hominem link but I'm not sure about your following question since that's not at all related to an Ad Hominem. But it is related to the following: http://en.wikipedia.org/wiki/Red_herring Read what I wrote above, I'm talking about UPDATES (or the lack of), not popularity. You implied it. Where? How? Maybe the English that they taught me at school is subtly different to the English that you learnt. I'm moving forward with the discussion, not backwards, Please keep up. I've no reason for the discussion to go into circular mode. It doesn't seem like you're exchanging ideas. That is a suggestion. I have plenty of ideas, but they would mostly be based on my experience writing InterJinn and what I hate about other frameworks I've come across, as such I chose to keep quiet rather than pollute his ideology with my own and sound like I'm tooting my own horn. I often find myself writing responses to people that are based on what I did or do in my framework... often I delete them before sending them because I don't like how it seems impartial. once in a while it still comes up, but I'm not perfect. The OP was not asking questions on _how_ a framework should behave or _what_ a framework should contain. Rather the question was how to _start_ [writing a] php framwork [sic]. Exactly, so why you gave him an answer that didn't suggest anything about writing a framework still eludes me. Your answer, should it ever be forthcoming, need not pollute his innocent mind with your framework ideals. Well it would, since I'd almost certainly begin talking about how I started mine. One of the ways to do anything is to just wade in. Er, obviously. Can't really argue with that statement. Another true statement is One of the ways to do anything is to study the situation before you wade in. So your point? Like I said, it's one of the ways. The point is that you're suggestions push away other options as though your suggestion is the right one. I'm not going to argue whether yours is right or wrong, only that many options exist and that anyone who tells you their way is the right way is probably wrong. Who are you to assess the OP's skills and determine that he is unable to make a reasonable assessment? I think you were the one assessing the OP's skills. You stated that evaluating the available frameworks is a staggering task, yet suggest that the OP go ahead and write his own framework. In my life experience, judging is easier than creating. I know a good book when I read one, a good meal when I eat one and a good movie when I see one, however I'm not sure I know how to write a good novel, cook a good meal or make a good movie. No, you assessed the OP's skills when you assumed that he would be unable to create a fully-baked framework and should totter off and join an existing framework. But see how you're trying to circle back again. This has already been discussed, the archives show it, I'll not answer it again. But going back to your point about narrowing it down, you've already jumped to the conclusion that the OP has no clue what he's doing and so it follows that he probably wouldn't know how to begin narrowing down the candidates since that would require experience. And yet he is able to put together a kickass framework sometime in the future through flirting with serendipity? No, I never said the OP would flirt with serendipity, in fact if he created a kick-ass framework while pursuing that goal then it could not be serendipity. Now if he discovered something else while pursing the creation of a
[PHP] passing sessions with header()
The php.net manual states: quote Session ID is not passed with Location header even if session.use_trans_sid is enabled. It must by passed manually using SID constant. /quote How should the SID be passed manually? I'd like to keep the SID out of the uri, so is a POST variable the best way to handle that? My problem is that I'm trying to keep a session persistent through a header() redirect. which when left to it's own, looses all association to the session . Thanks! J
Re: [PHP] passing sessions with header()
John wrote: The php.net manual states: quote Session ID is not passed with Location header even if session.use_trans_sid is enabled. It must by passed manually using SID constant. /quote How should the SID be passed manually? I'd like to keep the SID out of the uri, so is a POST variable the best way to handle that? My problem is that I'm trying to keep a session persistent through a header() redirect. which when left to it's own, looses all association to the session . Just stick it on the end of the URL... header('Location: http://domain.com/dir/script.php?'.SID); Or, if you already have a querystring... header('Location: http://domain.com/dir/script.php?a=b;'.SID); -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php framework, large site
On Wed, 2007-06-20 at 02:20 +0800, Crayon Shin Chan wrote: On Tuesday 19 June 2007 13:47, Robert Cummings wrote: No, it's simple probability. So it's probability now? Which has the greater probability: 1) study a selection of frameworks and learn from their strengths and weaknesses then go on to create a kickass framework based on what you've learnt Now, now, let's not pretend that you even nearly suggested that in your original answer: It's an extremely inefficient use of precious time. Inventing the wheel over and over. Surely out of the billions of half-baked to fully-baked frameworks out there must be something suitable for everyone. How far would you take it? Write your own PHP, why not write your own OS, heck build your own computer while you're at it :) You don't offer anything up. Only that pursing the creation of a framework is extremely inefficient use of precious time by relating it to Inventing of the wheel over and over. You go on to suggest that surely there is something suitable out there already. Then you attempt to suggest the idiocy of doing so and liken it to attempting to writing one's own OS. 2) just jump right in a create a kickass framework Please note the distinction between possibility and probability. Please stay on track. And many will encounter serendipity along the way regardless of what they are looking to achieve. Now we're bypassing logical argument and relying on serendipity? The comment about serendipity was a generalized statement that neither added nor subtracted to the argument about creating a framework from scratch. Again, please stick with the program. 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] Comparing string to array
On 19/06/07, Richard Davey [EMAIL PROTECTED] wrote: $userparam = test['sam'][]; // How to check if $userparam exists in the $_POST array // and get all the values from it? full_key_exists(test['sam'][], $_POST) // returns true if key is set full_find_key(test['sam'][], $_POST) // returns value of key or undef. function full_key_exists ($key, $array) { preg_match_all('/[^][]+/', $key, $branch); if (!sizeof($branch[0])) false; foreach ($branch[0] as $index) { if (!(is_array($array) isset($array[$index]))) return false; $array = $array[$index]; } return true; } function full_find_key ($key, $array) { preg_match_all('/[^][]+/', $key, $branch); if (!sizeof($branch[0])) return; foreach ($branch[0] as $index) { if (!(is_array($array) isset($array[$index]))) return; $array = $array[$index]; } return $array; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fsocketopen not returning data properly
On 6/19/07, Dan [EMAIL PROTECTED] wrote: I got the function from the web, the implementation I did myself, echo httpSoc... Maybe I'm not using the function right because I keep getting a fatal error of: Fatal error: Call to undefined function logEventToTextFile() on line 79 Does it look like I'm implementing the code correctly? And I tried with GET, I get the same error. - Daniel Hi, It seems that you copied only a part of the code, and that you didn't copy the code of that self-made function. You can remove these lines: logEvent('debug', 'Failed opening http socket connection: '.$errorString.' ('.$errorNumber.')br/\n'); logEventToTextFile('debug', $chunk_length); logEventToTextFile('debug', $responseContent); Tijnema Tijnema [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 6/19/07, Dan [EMAIL PROTECTED] wrote: I'm having trouble with sockets in PHP, if anyone has the time to help out that would be awesome. I am trying to get the result of a post There are a lot of people that are probably willing to help, but what is your exact problem? echo httpSocketConnection(www.google.com, POST, /search, q=test, 80); This should post to google.com with a query of test. Then give me the response. The function I'm using is below. Google doesn't wants a POST request, make it a GET request and it should work. Here's the function's code: snip You copied this straight from the web? If so, then there are probably no bugs in it. Tijnema -- 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] passing sessions with header()
Just stick it on the end of the URL... I'd like to keep it out of the URL if possible... J -Original Message- From: Stut [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 19, 2007 1:45 PM To: John Cc: php-general@lists.php.net Subject: Re: [PHP] passing sessions with header() John wrote: The php.net manual states: quote Session ID is not passed with Location header even if session.use_trans_sid is enabled. It must by passed manually using SID constant. /quote How should the SID be passed manually? I'd like to keep the SID out of the uri, so is a POST variable the best way to handle that? My problem is that I'm trying to keep a session persistent through a header() redirect. which when left to it's own, looses all association to the session . Just stick it on the end of the URL... header('Location: http://domain.com/dir/script.php?'.SID); Or, if you already have a querystring... header('Location: http://domain.com/dir/script.php?a=b;'.SID); -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] If statement duplicating mysql records?
Okay, so I have a question... Probably pretty easy, but why would my if statement show more records then what are in the database? if($row[5] =='Level4'){ // White Highlight echo TRTD bgcolor=.$Level4.$row[0] /td; echo td bgcolor=.$Level4.$row[1] /td; echo td bgcolor=.$Level4.A href ='$row[2]'Instructions/A/ td; echo TD bgcolor=.$Level4.A href='update.php?taskid=$row [0]'Click here!/A; }// End of Level 4 else {// Green Highlight echo TRTD bgcolor=.$unclassified.$row[0] /td; echo td bgcolor=.$unclassified.$row[1] /td; echo td bgcolor=.$unclassified.A href ='$row [2]'Instructions/A/td; echo TD bgcolor=.$unclassified.A href='update.php?taskid=$row [0]'Click here!/A; }// End of Unclassified If I have a record that matches Level4 it will display both with the $Level4 color and the $unclassified color. Ideally it would only show up under the $Level4 category if it's Level4... If that makes sense. Or is there a better way to do it? Thanks! :) And one of these days, I WILL be able to help answer questions on this list too! :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Chat system
Hi, I am looking for a simple php chat system (no registration, no private channels). Unfortunately the ones I've found (phpopenchat, phpfreechat) are too complicate, requiring the user to register or fail to work properly in IE6 or IE7. Any tips? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] passing sessions with header()
John wrote: Just stick it on the end of the URL... I'd like to keep it out of the URL if possible... In that case you don't have a problem. If the session ID is being passed in a cookie then it will survive redirects. -Stut -- http://stut.net/ -Original Message- From: Stut [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 19, 2007 1:45 PM To: John Cc: php-general@lists.php.net Subject: Re: [PHP] passing sessions with header() John wrote: The php.net manual states: quote Session ID is not passed with Location header even if session.use_trans_sid is enabled. It must by passed manually using SID constant. /quote How should the SID be passed manually? I'd like to keep the SID out of the uri, so is a POST variable the best way to handle that? My problem is that I'm trying to keep a session persistent through a header() redirect. which when left to it's own, looses all association to the session . Just stick it on the end of the URL... header('Location: http://domain.com/dir/script.php?'.SID); Or, if you already have a querystring... header('Location: http://domain.com/dir/script.php?a=b;'.SID); -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] If statement duplicating mysql records?
Jason Pruim wrote: Okay, so I have a question... Probably pretty easy, but why would my if statement show more records then what are in the database? if($row[5] =='Level4'){ // White Highlight echo TRTD bgcolor=.$Level4.$row[0] /td; echo td bgcolor=.$Level4.$row[1] /td; echo td bgcolor=.$Level4.A href ='$row[2]'Instructions/A/td; echo TD bgcolor=.$Level4.A href='update.php?taskid=$row[0]'Click here!/A; }// End of Level 4 else {// Green Highlight echo TRTD bgcolor=.$unclassified.$row[0] /td; echo td bgcolor=.$unclassified.$row[1] /td; echo td bgcolor=.$unclassified.A href ='$row[2]'Instructions/A/td; echo TD bgcolor=.$unclassified.A href='update.php?taskid=$row[0]'Click here!/A; }// End of Unclassified Why not do it this way instead. while( $row = mysql_fetch_array($results) ) { $rowColor = $unclassified; // White Highlight if($row[5] =='Level4'){ $rowColor = $Level4; } echo TRTD bgcolor=.$rowColor.$row[0] /td; echo td bgcolor=.$rowColor.$row[1] /td; echo td bgcolor=.$rowColor.A href='$row[2]'Instructions/A/td; echo TD bgcolor=.$rowColor.A href='update.php?taskid=$row[0]'Click here!/A; } If I have a record that matches Level4 it will display both with the $Level4 color and the $unclassified color. Ideally it would only show up under the $Level4 category if it's Level4... If that makes sense. Or is there a better way to do it? Thanks! :) And one of these days, I WILL be able to help answer questions on this list too! :) --PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] pdf and send to printer question
I am trying to get a query to run and outputed to a pdf file I get the following error Fatal error: Call to undefined function pdf_begin_document() in my php.ini I have php_cpdf.dll and php_pdf.dll enabled am I missing something.? also is there a way to send the document I create to the printer instead of the screen? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: If statement duplicating mysql records?
Jason Pruim wrote: Okay, so I have a question... Probably pretty easy, but why would my if statement show more records then what are in the database? if($row[5] =='Level4'){ // White Highlight }// End of Level 4 else {// Green Highlight }// End of Unclassified If I have a record that matches Level4 it will display both with the $Level4 color and the $unclassified color. Ideally it would only show up under the $Level4 category if it's Level4... If that makes sense. I don't think IF is the culprit. I'm guessing you have a bad join in your sql query so you are getting back more records than you expect. Have you run the query directly in to see what your results are? Roberto -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] Comparing string to array
Hi Robin, Tuesday, June 19, 2007, 8:28:50 PM, you wrote: On 19/06/07, Richard Davey [EMAIL PROTECTED] wrote: $userparam = test['sam'][]; // How to check if $userparam exists in the $_POST array // and get all the values from it? full_key_exists(test['sam'][], $_POST) // returns true if key is set full_find_key(test['sam'][], $_POST) // returns value of key or undef. function full_key_exists ($key, $array) { preg_match_all('/[^][]+/', $key, $branch); if (!sizeof($branch[0])) false; foreach ($branch[0] as $index) { if (!(is_array($array) isset($array[$index]))) return false; $array = $array[$index]; } return true; } function full_find_key ($key, $array) { preg_match_all('/[^][]+/', $key, $branch); if (!sizeof($branch[0])) return; foreach ($branch[0] as $index) { if (!(is_array($array) isset($array[$index]))) return; $array = $array[$index]; } return $array; } Now that is one elegant solution. Thank you very much indeed. 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] Chat system
On 6/19/07, robert mena [EMAIL PROTECTED] wrote: Hi, I am looking for a simple php chat system (no registration, no private channels). Unfortunately the ones I've found (phpopenchat, phpfreechat) are too complicate, requiring the user to register or fail to work properly in IE6 or IE7. Any tips? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I have a one that I started putting together a few days ago that uses AJAX. It can accept user registration, multiple rooms, et cetera, but unless the files are included with the distribution, it's a single room without registration. Check it out: http://www.pilotpig.net/gchat/ -- 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
Re: [PHP] Chat system
Hi Daniel, Thanks. How can the user chooses the nickname? How about the list of connected users? On 6/19/07, Daniel Brown [EMAIL PROTECTED] wrote: On 6/19/07, robert mena [EMAIL PROTECTED] wrote: Hi, I am looking for a simple php chat system (no registration, no private channels). Unfortunately the ones I've found (phpopenchat, phpfreechat) are too complicate, requiring the user to register or fail to work properly in IE6 or IE7. Any tips? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I have a one that I started putting together a few days ago that uses AJAX. It can accept user registration, multiple rooms, et cetera, but unless the files are included with the distribution, it's a single room without registration. Check it out: http://www.pilotpig.net/gchat/ -- 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
Re: [PHP] Re: php framework, large site
At 2:20 AM +0800 6/20/07, Crayon Shin Chan wrote: On Tuesday 19 June 2007 06:58, tedd wrote: the *majority* of patents for inventions are due to the efforts of a lone risk taker putting his money, time, and effort on the line trying to invent something. I've no idea what the figures are but I find that hard to believe, do you have any sources to backup that claim? Try reading. The publications are plenty. And, don't ask me for references, I'm not doing your homework. I made the claim, now you prove me wrong, if you can. Perhaps you'll learn something in the process. Just for grins, why don't you list ten basic patients that spawned new technologies, which were produced by large corporations. I think you're going to have a hard time wading through all the small inventors, who spawned giant industries, to find something that a large corporation did that was worthwhile. And, don't look to government for anything worthwhile either (chuckle). Their grant process is a joke for providing funds to small developers -- you should try it sometime. Large organizations (corporate or government) are guided by collective minds without imagination. Good ideas are diluted to the least common denominator of understanding. Like I said before, the brightest ideas have to pass through the dimmest minds to be implemented. If you drown imagination in a quagmire of countless levels of CYA management, then you'll never produce anything worthwhile. The lone individual is the true source of inspiration and imagination and his freedom to act upon his idea is directly proportional to the likelihood of it's success. That fact is very obvious to those of us who have experienced it -- sad that you haven't. And, one *never* could conduct high energy particle physics experiments in my own basement and launch interplanetary space probes from my own backyard. Lighten up, it's satire. Don't get your panties in a knot. I didn't see anything funny, so don't give up your day job. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php framework, large site
At 4:05 PM +0200 6/19/07, Jochem Maas wrote: Robert Cummings wrote: Some of the greatest science comes from those unaware of established rules and theories. Third. not that my complete lack of knowledge theory and complete lack of respect for rules has come to any kind of fruition :-P PS - the troll seems to been subdued? That's only because he released the Kracken (AKA Robert) upon himself. Maybe next time, he'll know who not to pick a fight with. :-) Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Persistent MySQL Connection
Richard Lynch wrote: On Wed, June 13, 2007 8:53 am, PHP Mailing List wrote: I currently running my php as cgi as it is more controllable in shared hosting, the drawback is I cannot use mysql persistent connection so mysql_pconnect() function is not an option. Is there any mysql connection pool product for php running as cgi ? The MySQL list could probably recommend several MySQL connection pooling software packages, with PHP/cgi being largely irrelevant to the question... It's incredibly unlikely that your shared hosting server will actually install any of them, mind you... Persistent connections is probably not the road you should be on in the first place. How long are your connections taking? Hi Lynch, Sorry for very late reply Just see your reply. I think it will take as long as 5 minutes average. Any solution will be very appreciated. Thanks ! Feris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php