Re: [PHP] question regarding Reflection
Manish Marathe wrote: Hello All, I am developing a unit test generator for PHP. The generated tests would be PHPUnit2 compatible and I will be using the Reflection API to generate the tests. The tests would be generated only for classes and written on PHP 5.0.3 compatible. My question is to use the Reflection API, I need to import the original class for which I am generating tests. For example to generate a tests for class Company which is in Company.php: include_once('company.php'); $c = new ReflectionClass('Company'); If I have to generate test for many classes at once, it would be foolish to have them included in my file on the runtime. Am I understanding it a complex app can have 100's of classes, not usually all loaded at once but still. the upper limit is depends on how much memory your generation process is allowed to grow to, how often you [need to] run it, how process-intensive it is to run the generation and how big your iron is. you might consider using forking in a master process and letting a series of child processes each handle a chunk of all the classes to generate tests for, basically running in parallel. I don't see how you can avoid loading many classes 'at once', why do you think this is foolish [by definition]? hth. correctly ? Thank you for your help Manish Marathe SpikeSource, Inc. http://developer.spikesource.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about including files and server load
Hi Jay, Friday, October 14, 2005, 2:21:57 PM, you wrote: I was wondering isn't this putting a bigger load on a server by including so many files for each function? Also, I was wondering what everyone's opinion was on this approach in terms of maintenance. Do you think it's better practice to put all your functions in one file or do it in this manner? How many are there? I don't use functions in that way, but I do a similar thing for class files (minus that definedfucntions part of course). You could of course combine them all together, and yes it *would* be faster for the script to execute as there is far less drive activity going on. But then it's a trade-off between maintaining that single massive file, as opposed to updating smaller chunks. If it's a real issue looking at something like Zend Encoder would help. Cheers, Rich -- Zend Certified Engineer http://www.launchcode.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about including files and server load
Richard Davey wrote: Hi Jay, Friday, October 14, 2005, 2:21:57 PM, you wrote: I was wondering isn't this putting a bigger load on a server by including so many files for each function? Also, I was wondering what everyone's opinion was on this approach in terms of maintenance. Do you think it's better practice to put all your functions in one file or do it in this manner? How many are there? I don't use functions in that way, but I do a similar thing for class files (minus that definedfucntions part of course). You could of course combine them all together, and yes it *would* be faster for the script to execute as there is far less drive activity going on. But then it's a trade-off between maintaining that single massive file, as opposed to updating smaller chunks. If it's a real issue looking at something like Zend Encoder would help. Cheers, Rich Isn't it more work for PHP, or rather the Zend engine, to keep track of a bunch of functions that aren't being used, not to mention the memory it takes to load in one huge file. I agree that putting each function in it's own file is going a bit too far in the other direction. I tend to group functions together by purpose into seperate files. Kind of a happy medium. You don't have a bunch of includes in the code and you don't have a bunch of functions in memory that aren't being used. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question
On 10/7/05, Sven Simons [EMAIL PROTECTED] wrote: I've installed PHP using the windows installer I try to open then php pages containing the following script : ?php echo Current IP Address: ; $ipx = getenv(HTTP_CLIENT_IP) ? getenv(HTTP_CLIENT_IP) : 0; $ipx = !$ipx getenv(HTTP_X_FORWARDED_FOR) ? getenv(HTTP_X_FORWARDED_FOR) : 0 ; $ipx = !$ipx getenv(REMOTE_ADDR) ? getenv(REMOTE_ADDR) : 0 ; echo !$ipx ? UNKNOWN : $ipx; echo br; echo Server IP Address: ; $ipx = getenv(SERVER_ADDR) ? getenv(SERVER_ADDR) : 0; echo !$ipx ? UNKNOWN : $ipx; ? It works and gives me a correct current IP address When manually installing PHP it always gives me the status UNKNOWN. Just use the $_SERVER[] superglobal array to grab the stuff you need. Don't use the getenv function. -Mike -- Michael E. Crute Software Developer SoftGroup Development Corporation Linux, because reboots are for installing hardware. In a world without walls and fences, who needs windows and gates?
Re: [PHP] Question
On Fri, October 7, 2005 6:54 am, Sven Simons wrote: When manually installing PHP it always gives me the status UNKNOWN. Definitely check $_SERVER instead of GetEnv to see if it gives you what you want. The only strange thing is that the phpinfo says that the ini file is located in C:\Winnt although it is not there (when installing manually it is in C:\PHP) In the old days, you'd be stuck with copying and maintaining C:\PHP into C:\Winnt Now, there's an Apache directive to let you define where php.ini lives. You'd have to switch from IIS to Apache to use it, though. But that's a good thing :-) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about Rasmus' 30 second AJAX Tutorial
xfedex wrote: I did the Rasmus' 30 second AJAX Tutorial just for testing and everything works fine, by the way... thanks Rasmus, for this and for all !!. My little script have a single input and for every keystroke (calling the javascript function with onkeyup) the value of the input is parsed by another php script that just return the lenght of the string. So, if I start typing the word hello, when i press the h key it displays 1, for ho it displays 2 and so onvery simple, just for testing. But (theres always a but!!) it seems that only work if I call the function sndReq(); with onkeyup. If I call the function from a onsubmit it returns...nothing!. Then alert('response:'+http.responseText); it's EMPTY. Im absolutely sure that the difference between the two scripts is that the one that works is the onkeyup, and the one that not is the onsubmit. So, anybody knows why this is happening? What do you return from the onsubmit? If the onsubmit code evaluates to true then the form will be submitted causing the page source to change which would cause unpredictable results for the AJAX response depending on several race conditions. Can I suggest you let us see the whole form so we can see exactly what the onsubmit code does. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about Rasmus' 30 second AJAX Tutorial
xfedex wrote: Hi, I did the Rasmus' 30 second AJAX Tutorial just for testing and everything works fine, by the way... thanks Rasmus, for this and for all !!. My little script have a single input and for every keystroke (calling the javascript function with onkeyup) the value of the input is parsed by another php script that just return the lenght of the string. So, if I start typing the word hello, when i press the h key it displays 1, for ho it displays 2 and so onvery simple, just for testing. But (theres always a but!!) it seems that only work if I call the function sndReq(); with onkeyup. If I call the function from a onsubmit it returns...nothing!. Then alert('response:'+http.responseText); it's EMPTY. Im absolutely sure that the difference between the two scripts is that the one that works is the onkeyup, and the one that not is the onsubmit. So, anybody knows why this is happening? I'm guessing that trhe onclick and onsumbit handlers you set are hanging on a 'submit' type input? .. if so the form is submitting - in whcih case the AJAX request will arrive back at your page - and the page won't be there (so to speak). try changing your onsubmit to something like: input type=submit value=submit onclick=myAjaxFunction(); return false;/ the return false tells the browser block form submission.. the same technique is used to validate forms and stop submission in case of errors (in such cases the boolean return is conditional e.g.: input type=submit value=submit onsubmit=return myValidationFunction();/ Sorry about my english (I'm from the third world ;) ) whatever happened to the 'second world'? and since when is it a competition? ;-) Regards, (from Argentina) Federico. I find a lot of this AJAX stuff a bit of a hype. Lots of people have been using similar things long before it became AJAX. And it really isn't as complicated as a lot of people make it out to be. Here is a simple example from one of my apps. First the Javascript: function createRequestObject() { var ro; var browser = navigator.appName; if(browser == Microsoft Internet Explorer){ ro = new ActiveXObject(Microsoft.XMLHTTP); }else{ ro = new XMLHttpRequest(); } return ro; } var http = createRequestObject(); function sndReq(action) { http.open('get', 'rpc.php?action='+action); http.onreadystatechange = handleResponse; http.send(null); } function handleResponse() { if(http.readyState == 4){ var response = http.responseText; var update = new Array(); if(response.indexOf('|' != -1)) { update = response.split('|'); document.getElementById(update[0]).innerHTML = update[1]; } } } This creates a request object along with a send request and handle response function. So to actually use it, you could include this js in your page. Then to make one of these backend requests you would tie it to something. Like an onclick event or a straight href like this: a href=javascript:sndReq('foo') [foo]/a That means that when someone clicks on that link what actually happens is that a backend request to rpc.php?action=foo will be sent. In rpc.php you might have something like this: switch($_REQUEST['action']) { case 'foo': /* do something */ echo foo|foo done; break; ... } Now, look at handleResponse. It parses the foo|foo done string and splits it on the '|' and uses whatever is before the '|' as the dom element id in your page and the part after as the new innerHTML of that element. That means if you have a div tag like this in your page: div id=foo /div Once you click on that link, that will dynamically be changed to: div id=foo foo done /div That's all there is to it. Everything else is just building on top of this. Replacing my simple response id|text syntax with a richer XML format and makine the request much more complicated as well. Before you blindly install large AJAX libraries, have a go at rolling your own functionality so you know exactly how it works and you only make it as complicated as you need. Often you don't need much more than what I have shown here. Expanding this approach a bit to send multiple parameters in the request, for example, would be really simple. Something like: function sndReqArg(action,arg) { http.open('get', 'rpc.php?action='+action+'arg='+arg); http.onreadystatechange = handleResponse; http.send(null); } And your handleResponse can easily be expanded to do much more interesting things than just replacing the contents of a div. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about Rasmus' 30 second AJAX Tutorial
On 9/30/05, Jochem Maas [EMAIL PROTECTED] wrote: I'm guessing that trhe onclick and onsumbit handlers you set are hanging on a 'submit' type input? .. if so the form is submitting - in whcih case the AJAX request will arrive back at your page - and the page won't be there (so to speak). try changing your onsubmit to something like: input type=submit value=submit onclick=myAjaxFunction(); return false;/ the return false tells the browser block form submission.. the same technique is used to validate forms and stop submission in case of errors (in such cases the boolean return is conditional e.g.: input type=submit value=submit onsubmit=return myValidationFunction();/ Sorry about my english (I'm from the third world ;) ) whatever happened to the 'second world'? and since when is it a competition? ;-) Ok, its working now... input type=submit value=submit onclick=myAjaxFunction(); return false;/ There was the form submision that was making troubles. Thank you all!! Regards, Fede.
Re: [PHP] Question about Rasmus' 30 second AJAX Tutorial
On Thu, 2005-09-29 at 22:46, xfedex wrote: Hi, I did the Rasmus' 30 second AJAX Tutorial just for testing and everything works fine, by the way... thanks Rasmus, for this and for all !!. My little script have a single input and for every keystroke (calling the javascript function with onkeyup) the value of the input is parsed by another php script that just return the lenght of the string. So, if I start typing the word hello, when i press the h key it displays 1, for ho it displays 2 and so onvery simple, just for testing. But (theres always a but!!) it seems that only work if I call the function sndReq(); with onkeyup. If I call the function from a onsubmit it returns...nothing!. Then alert('response:'+http.responseText); it's EMPTY. Im absolutely sure that the difference between the two scripts is that the one that works is the onkeyup, and the one that not is the onsubmit. So, anybody knows why this is happening? Aside from using ajax to clean the toilet once in a while I'm not really into it. But I do wrangle out some javascript from time to time :) Why are you using onsubmit? Wouldn't onclick work better? 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] Question about Rasmus' 30 second AJAX Tutorial
On 9/29/05, Robert Cummings [EMAIL PROTECTED] wrote: Aside from using ajax to clean the toilet once in a while I'm not really into it. But I do wrangle out some javascript from time to time :) Why are you using onsubmit? Wouldn't onclick work better? Cheers, Rob. Hi Robert, I also try with onclick and i got the same result as with onsubmit, it seems that only work with onkeyup but the point is why? Saludos, Fede.
Re: [PHP] question on order of variables passed to a function
Vidyut Luther wrote: ?php myErrorHandler($errno, $errstr, $errfile, $errline) { switch ($errno) { case E_USER_ERROR: . } ? and then: ?php trigger_error(log(x) for x = 0 is undefined, you used: scale = $scale, E_USER_ERROR); ? So, wouldn't this make $errno in the myErrorHandler be log (x) rather than E_USER_ERROR ? No, because you're calling trigger_error, not myErrorHandler. The order of parameters for trigger_error is as follows[1]: bool trigger_error ( string error_msg [, int error_type] ) trigger_error will, when called, either call your user-defined handler with the correct errno, errstr, errfile, errline etc, or, if you haven't defined one, it will use the error handling methods set up in PHP (log_errors or display_errors). HTH Jasper [1] http://www.php.net/trigger_error -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question about exec() call an CLI php script from Apache CGI/filter module PHP
I forgot to mention that calling from shell directly s.php runs correctly. ~ marvin:~/liang.ns2user.info/php ./s.php This is a PHP-CLI Script!!0123456789 ~ The php configuration of this site is: http://liang.ns2user.info/php/info.php Thank you in advance. Liang I call red.php through apache http request, and red.php make exec('./s.php') call, then I got bunch of s.php processes, and system locked me out any task due to no more processes available. Why this would happen? marvin:~/liang.ns2user.info/php less red.php ?php ignore_user_abort(true); header(Location: redirect2.html); exec('./s.php'); ? marvin:~/liang.ns2user.info/php less s.php #!/usr/local/bin/php -q ?php echo This is a PHP-CLI Script!!; for($i=0;$i10;$i++) { echo $i; sleep(1); } $fp = fopen(/tmp/foo.txt,a); fputs($fp,$i); fclose($fp); ? marvin:~ ps -u liang PID TTY TIME CMD 20368 ?00:00:00 s.php 3184 ?00:00:00 s.php 27596 ?00:00:00 s.php 17509 ?00:00:00 s.php 10471 ?00:00:00 s.php 20244 ?00:00:00 s.php 31762 ?00:00:00 s.php 12067 ?00:00:00 s.php 14125 ?00:00:00 s.php 13003 ?00:00:00 s.php 25257 ?00:00:00 s.php 22482 ?00:00:00 s.php 3117 ?00:00:00 s.php 27203 ?00:00:00 s.php 28537 ?00:00:00 s.php 30534 ?00:00:00 s.php 873 ?00:00:00 s.php 8452 ?00:00:00 s.php 306 ?00:00:00 s.php 15703 ?00:00:00 s.php 24708 ?00:00:00 s.php 5745 ?00:00:00 s.php 11949 ?00:00:00 s.php 34 ?00:00:00 s.php 22545 ?00:00:00 s.php 11775 ?00:00:00 s.php 12333 ?00:00:00 s.php 27383 ?00:00:00 s.php 612 ?00:00:00 s.php 6437 ?00:00:00 s.php 14648 ?00:00:00 s.php defunct 14040 pts/100:00:00 tcsh 14027 pts/100:00:00 ps I am really confused, anybody has any idea? Thank you very much. Liang -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about apache-php concurrent process control
Thank you Richard, I think I'd better explain a little about the project and then you or somebody else might give some good suggestion upon the restrictions of the project. The project is to implement a digital library protocol, called oai_pmh (http://www.openarchives.org/OAI/openarchivesprotocol.html) It acts as a broker for the harvester client to get meta data from libraries that have Z39.50 server. The database resides on libraries, and vary alot in speed, number of records, way to accept connection from z39.50 client. The number of records from some libraries might be over million. So the part that getting data from those libraries behave very differently. The harvester client sends http request, normally through program, like perl LWP. It normally sets 180 time out for connection. According to the protocol, the oai_pmh data provider act on respond to harvester http request, it begin to connect to specific library's z39.50 server, get data in, write them to disk, and translate to another xml format, then send to harvester client. If the records are too many, oai_pmh should send back partial data with resumption token. The harvester can later send out http request with same url but with the resumption token as one of the POST variable to get further data records. This process can be continueing till all the records has been send. Thus I noramlly use perl program to send the http request and get content instead of BROWSER. The behavior of buffer should not due to the setting of the browser. I can not echo the metadata directly back, since xlst need to use to transform and new xml file(s) are writen. The header() redirction is very nature to use if it can close the connection before I do something very time consumming after that. The exec with and the cron job are hard to use, since connection to z39.50 with a lot of state variables like connection id, etc can not easily be passed to another script. The harvester user normally is not a human with browser but a piece of code, while looping and sending out http requests if the page it gets back has resumptionToken tag. (it replace the element between open and close tag of resumptionToken, append to the next http request as POST variable for next records page). But the problem is each http request posts a timeout of 180 seconds. Thus I have to return partical data within 3 minutes while the whole process might take hours or even days. Then the process continue to get data from library server and transform it, then write to disk in a particular directory. The next request with resumption token comes in, the program will check for the existing of the directory and return if yes. If not existing, program will check to return within 3 minutes or send back not available information. Sorry for the long writting. I hope some one has some suggestion for me. Thank you very much. --- I now encounter a problem with flow control of my program with PHP. This is very crucial to the design of a pretty big project. This is what I want to do in the program: ?php do_A(); header(Location: .$result_of_do_A); Depending on the buffering options in php.ini and/or Apache, this may or may not just end your program, as I understand it. Once you send the Location header, everything else is irrelevant, or at least not reliable. You could do: echo $result_of_do_A; flush(); and the user will see what happened with A, while waiting for B. do_B(); ? Since it takes do_B() quite a while to finish, so I want the http client get the partial result from do_A() by redirect a page to them before start do_B(). But it seems that the redirection will only occure after the entire php program finishes, i.e., after do_B(). I sent http request through browser, curl comman line with -N (no buffer) option and with a perl LWP program I wrote. All of them suggest that header(), although is put before do_B() in code, gets executed only after all the php code finished. I add flush() after header() too, but no work. If that is what you are seeing happen, you probably have output buffering turned on The Location: header is acted upon by the BROWSER, not by PHP, not by your server. The BROWSER sees that header and then jumps to somewhere else. My question is: Is there any way that I can return to the client though http response and then continue my progress with my program? You could also look into the pcntl stuff to fork() or, depending on various settings, you might get: exec(do_B() ); to get B to happen in the background. With all that said: As a general rule, when I found myself doing this kind of stuff, I later realized that I hadn't really designed my application very well for an end-user experience. If it takes THAT long to finish B, then you're probably MUCH better off putting something in a ToDo List in your database, and
Re: [PHP] Question about apache-php concurrent process control
Read this chapter of the manual: http://www.php.net/manual/en/features.connection-handling.php Liang ZHONG wrote: I now encounter a problem with flow control of my program with PHP. This is very crucial to the design of a pretty big project. This is what I want to do in the program: ?php do_A(); header(Location: .$result_of_do_A); do_B(); ? Since it takes do_B() quite a while to finish, so I want the http client get the partial result from do_A() by redirect a page to them before start do_B(). But it seems that the redirection will only occure after the entire php program finishes, i.e., after do_B(). I sent http request through browser, curl comman line with -N (no buffer) option and with a perl LWP program I wrote. All of them suggest that header(), although is put before do_B() in code, gets executed only after all the php code finished. I add flush() after header() too, but no work. My question is: Is there any way that I can return to the client though http response and then continue my progress with my program? Thank you very much for your kindly help. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about apache-php concurrent process control
On Tue, July 19, 2005 5:32 am, Liang ZHONG said: It sounds interesting. But since I am pretty new to PHP, I have some questions, naive maybe, about what you wrote. #!/bin/sh\n/path/to/script/Send.php 12 \n What does the Send.php look like? I do not have idea how a shell interprets an php script and what the parameter 12 means here. If you do not mind, could you please also let me look at your Send.php? I dunno what his Send script looks like, but that 12 isn't a 12 at all. It's a 1 with a symbol and then a 2. The symbol probably got eaten by somebody's email program somewhere along the way. See, in some Linux/Un*x shells (errr, like DOS prompt only not broken) there is the idea of standard output which is where your basic output messages go. There is also standard error where your ERROR messages go. On Linux/Unix file systems, stdout (standard output) is bound to a special file which lives in /dev/1 -- it's not really really a file, but a device but to send stuff to the standard output -- which is generally your screen, you can just write it to /dev/1 and it gets there. For shorthand, in shell scripts, you can just use 1 to mean /dev/1 Similarly, standard error is /dev/2 and you can use 2 So, what he really had was 12 which was saying: Take anything that was supposed to go to 1 (standard output) and send it (the symbol) into 2 (standard error) So he's telling the shell (operating system) to combine any normal output into the error output so it's one big mess of output. You can learn more about this stuff (though it may be a bit overwhelming at first) by searching for man bash or reading an introductory Linux textbook or resource on-line. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about apache-php concurrent process control
I now encounter a problem with flow control of my program with PHP. This is very crucial to the design of a pretty big project. This is what I want to do in the program: ?php do_A(); header(Location: .$result_of_do_A); do_B(); ? Since it takes do_B() quite a while to finish, so I want the http client get the partial result from do_A() by redirect a page to them before start do_B(). But it seems that the redirection will only occure after the entire php program finishes, i.e., after do_B(). I sent http request through browser, curl comman line with -N (no buffer) option and with a perl LWP program I wrote. All of them suggest that header(), although is put before do_B() in code, gets executed only after all the php code finished. I add flush() after header() too, but no work. My question is: Is there any way that I can return to the client though http response and then continue my progress with my program? Thank you very much for your kindly help. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about apache-php concurrent process control
http://ca.php.net/manual/en/function.register-shutdown-function.php Cheers, Rob. On Thu, 2005-07-21 at 23:40, Liang ZHONG wrote: I now encounter a problem with flow control of my program with PHP. This is very crucial to the design of a pretty big project. This is what I want to do in the program: ?php do_A(); header(Location: .$result_of_do_A); do_B(); ? Since it takes do_B() quite a while to finish, so I want the http client get the partial result from do_A() by redirect a page to them before start do_B(). But it seems that the redirection will only occure after the entire php program finishes, i.e., after do_B(). I sent http request through browser, curl comman line with -N (no buffer) option and with a perl LWP program I wrote. All of them suggest that header(), although is put before do_B() in code, gets executed only after all the php code finished. I add flush() after header() too, but no work. My question is: Is there any way that I can return to the client though http response and then continue my progress with my program? Thank you very much for your kindly help. -- .. | 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] Question about apache-php concurrent process control
On Thu, July 21, 2005 8:40 pm, Liang ZHONG said: I now encounter a problem with flow control of my program with PHP. This is very crucial to the design of a pretty big project. This is what I want to do in the program: ?php do_A(); header(Location: .$result_of_do_A); Depending on the buffering options in php.ini and/or Apache, this may or may not just end your program, as I understand it. Once you send the Location header, everything else is irrelevant, or at least not reliable. You could do: echo $result_of_do_A; flush(); and the user will see what happened with A, while waiting for B. do_B(); ? Since it takes do_B() quite a while to finish, so I want the http client get the partial result from do_A() by redirect a page to them before start do_B(). But it seems that the redirection will only occure after the entire php program finishes, i.e., after do_B(). I sent http request through browser, curl comman line with -N (no buffer) option and with a perl LWP program I wrote. All of them suggest that header(), although is put before do_B() in code, gets executed only after all the php code finished. I add flush() after header() too, but no work. If that is what you are seeing happen, you probably have output buffering turned on The Location: header is acted upon by the BROWSER, not by PHP, not by your server. The BROWSER sees that header and then jumps to somewhere else. My question is: Is there any way that I can return to the client though http response and then continue my progress with my program? You could also look into the pcntl stuff to fork() or, depending on various settings, you might get: exec(do_B() ); to get B to happen in the background. With all that said: As a general rule, when I found myself doing this kind of stuff, I later realized that I hadn't really designed my application very well for an end-user experience. If it takes THAT long to finish B, then you're probably MUCH better off putting something in a ToDo List in your database, and doing B later in a cron job. Then notify the user through email or some kind of status display that they will see on your site frequently when B is done NEVER make the user sit around waiting for your server. Human time is far far far too precious (and expensive!) to waste it sitting around doing nothing useful waiting for your program to finish. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about apache-php concurrent process control
Thank you Rouvas, I never used the tools you mentioned. But I will definitely give them a try. I wrote a perl script using LWP as an http user agent. and the timing function you suggested. It works well. I am new to this forum, and new to PHP. It seems Rasmus is famous, and I should have shown my respect. Thanks again all of you for your kindly help. Hi Liang, trying to get conclusive results with browsers is futile. Use a command-line tool (like curl) to invoke the web pages and get the results. Or you can use PHP's own function to query the web server and do your own timing with microtime() function or another suitable for your purposes. In order for flush() results to reach you (in a browser) they have to pass from multiple caches like PHP's, Apache's, the occasional proxies and finally the browser's own cache. So you cannot get dependaple results measuring times or responses from your browser. Try the methods above. And a final tip... When Rasmus speaks, you don't question him:-) Period. Have a nice day, -Stathis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question about apache-php concurrent process control
snipIt seems Rasmus is famous, and I should have shown my respect./snip history src = 'php_manual_en.chm' PHP succeeds an older product, named PHP/FI. PHP/FI was created by Rasmus Lerdorf in 1995, initially as a simple set of Perl scripts for tracking accesses to his online resume. He named this set of scripts 'Personal Home Page Tools'. As more functionality was required, Rasmus wrote a much larger C implementation, which was able to communicate with databases, and enabled users to develop simple dynamic Web applications. Rasmus chose to release the source code for PHP/FI for everybody to see, so that anybody can use it, as well as fix bugs in it and improve the code. /history This message has been delivered to the Internet by the Revenue Internet e-mail service * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about apache-php concurrent process control
Hi André, It sounds interesting. But since I am pretty new to PHP, I have some questions, naive maybe, about what you wrote. #!/bin/sh\n/path/to/script/Send.php 12 \n What does the Send.php look like? I do not have idea how a shell interprets an php script and what the parameter 12 means here. If you do not mind, could you please also let me look at your Send.php? Thank you very much. I did something like that for a newsletter sending script. Basiclly, I had two scripts: a) AddEdit.php that would list the newsletter's items and allow it to send b) Send.php that was a script I ran on the background When pressed Send on AddEdit, it would do something like $tempName = tempnam( '/tmp', 'newsletter' ); $fp = fopen( $tempName, 'w+' ); fputs( $fp, #!/bin/sh\n/path/to/script/Send.php 12 \n ); fclose( $fp ); chmod( $tempName, 0755 ); system( $tempName . ' ' ); That way, it would launch the second script into the background, checking if the script altered the newsletter's state for Sent everytime a user saw the newsletter's details. Hope it helped. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question about apache-php concurrent process control
Can somebody here help me to delete my message? People who read this must be laughing at me. :) snipIt seems Rasmus is famous, and I should have shown my respect./snip history src = 'php_manual_en.chm' PHP succeeds an older product, named PHP/FI. PHP/FI was created by Rasmus Lerdorf in 1995, initially as a simple set of Perl scripts for tracking accesses to his online resume. He named this set of scripts 'Personal Home Page Tools'. As more functionality was required, Rasmus wrote a much larger C implementation, which was able to communicate with databases, and enabled users to develop simple dynamic Web applications. Rasmus chose to release the source code for PHP/FI for everybody to see, so that anybody can use it, as well as fix bugs in it and improve the code. /history This message has been delivered to the Internet by the Revenue Internet e-mail service * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about apache-php concurrent process control
I did something like that for a newsletter sending script. Basiclly, I had two scripts: a) AddEdit.php that would list the newsletter's items and allow it to send b) Send.php that was a script I ran on the background When pressed Send on AddEdit, it would do something like $tempName = tempnam( '/tmp', 'newsletter' ); $fp = fopen( $tempName, 'w+' ); fputs( $fp, #!/bin/sh\n/path/to/script/Send.php 12 \n ); fclose( $fp ); chmod( $tempName, 0755 ); system( $tempName . ' ' ); That way, it would launch the second script into the background, checking if the script altered the newsletter's state for Sent everytime a user saw the newsletter's details. Hope it helped. On 7/16/05, Rory Browne [EMAIL PROTECTED] wrote: On 7/16/05, rouvas [EMAIL PROTECTED] wrote: Hi Liang, trying to get conclusive results with browsers is futile. Use a command-line tool (like curl) to invoke the web pages and get the results. Or you can use Although personally I think that telnet-to-port-80 would be a better idea, in this case when you're trying to check what is outputted first. Either that or a TCP sniffer. I also agree with the microtime() suggestion, mentioned below. It will get you around the problem of caches - which is a major problem for something like this. I'm not sure what the situation with apache is regarding caches. PHP's own function to query the web server and do your own timing with microtime() function or another suitable for your purposes. In order for flush() results to reach you (in a browser) they have to pass from multiple caches like PHP's, Apache's, the occasional proxies and finally the browser's own cache. So you cannot get dependaple results measuring times or responses from your browser. Try the methods above. And a final tip... When Rasmus speaks, you don't question him:-) Period. Unless you didn't understand what he said and want clarification. Have a nice day, -Stathis On Saturday 16 July 2005 04:41, Liang ZHONG wrote: Hi Rasmus, You are right. It was the problem with the browser. I used Mozilla Firefox to try, and do not know what consideration it just serialized the identical url http requests. I then turned to use 2 IE 6.0 windows, 2 tabs within Maxthon browser, one IE windows and one Firefox, to test. Then I got the conclusion as you told. Thank you very much for the help. BTW, I could not get the flush() work, neither flush() with ob_flush(). I tried almost all methods mentioned in the followed posts under http://us2.php.net/flush, but none of them can really pushed the buffer out. The site is configurated with http://liang.ns2user.info/php/info.php on Red head, kernel 2.4.29. What can I do to get it work? Thank you again. Liang ZHONG wrote: Could you please explain it a little bit more? I did test this way. The code is the same for a.php and b.php ?php sleep(20); print Done. br /; ? I place request from 2 browser windows. First time, I placed with http://baseURL/a.php with both 2 browsers, starting times have 5 second interval. Then the first Done shows after 20 seconds and the second Done shows 20 seconds after the first Done. Then, I placed one browser with http://baseURL/a.php and the second one with http://baseURL/b.php, with starting time of 5 second interval. Then I got the first browser showing Done after 20 seconds and 5 seconds later, the second browser showed Done, too. Thus it seems that the apache can spoon out multiple php interpreters responding to http requests, while php can not deal with concurrent process from one program. I have no idea what you did to configure it this way. I wouldn't even know how to do that if you asked me to. As far as PHP is concerned it has no idea which processes are handling which script files at any one point. So whether you request a.php and b.php at the same time or a.php twice at the same time, it makes absolutely no difference to PHP. If you are really seeing this, then the limitation is in your browser or somewhere else. Try making a.php output stuff so it becomes easier to see. As in for($i=0;$i20;$i++) { echo $i; flush(); sleep(1); } You should see the counter start counting as soon as you hit the page. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about apache-php concurrent process control
Hi Liang, trying to get conclusive results with browsers is futile. Use a command-line tool (like curl) to invoke the web pages and get the results. Or you can use PHP's own function to query the web server and do your own timing with microtime() function or another suitable for your purposes. In order for flush() results to reach you (in a browser) they have to pass from multiple caches like PHP's, Apache's, the occasional proxies and finally the browser's own cache. So you cannot get dependaple results measuring times or responses from your browser. Try the methods above. And a final tip... When Rasmus speaks, you don't question him:-) Period. Have a nice day, -Stathis On Saturday 16 July 2005 04:41, Liang ZHONG wrote: Hi Rasmus, You are right. It was the problem with the browser. I used Mozilla Firefox to try, and do not know what consideration it just serialized the identical url http requests. I then turned to use 2 IE 6.0 windows, 2 tabs within Maxthon browser, one IE windows and one Firefox, to test. Then I got the conclusion as you told. Thank you very much for the help. BTW, I could not get the flush() work, neither flush() with ob_flush(). I tried almost all methods mentioned in the followed posts under http://us2.php.net/flush, but none of them can really pushed the buffer out. The site is configurated with http://liang.ns2user.info/php/info.php on Red head, kernel 2.4.29. What can I do to get it work? Thank you again. Liang ZHONG wrote: Could you please explain it a little bit more? I did test this way. The code is the same for a.php and b.php ?php sleep(20); print Done. br /; ? I place request from 2 browser windows. First time, I placed with http://baseURL/a.php with both 2 browsers, starting times have 5 second interval. Then the first Done shows after 20 seconds and the second Done shows 20 seconds after the first Done. Then, I placed one browser with http://baseURL/a.php and the second one with http://baseURL/b.php, with starting time of 5 second interval. Then I got the first browser showing Done after 20 seconds and 5 seconds later, the second browser showed Done, too. Thus it seems that the apache can spoon out multiple php interpreters responding to http requests, while php can not deal with concurrent process from one program. I have no idea what you did to configure it this way. I wouldn't even know how to do that if you asked me to. As far as PHP is concerned it has no idea which processes are handling which script files at any one point. So whether you request a.php and b.php at the same time or a.php twice at the same time, it makes absolutely no difference to PHP. If you are really seeing this, then the limitation is in your browser or somewhere else. Try making a.php output stuff so it becomes easier to see. As in for($i=0;$i20;$i++) { echo $i; flush(); sleep(1); } You should see the counter start counting as soon as you hit the page. -Rasmus -- 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] Question about apache-php concurrent process control
On 7/16/05, rouvas [EMAIL PROTECTED] wrote: Hi Liang, trying to get conclusive results with browsers is futile. Use a command-line tool (like curl) to invoke the web pages and get the results. Or you can use Although personally I think that telnet-to-port-80 would be a better idea, in this case when you're trying to check what is outputted first. Either that or a TCP sniffer. I also agree with the microtime() suggestion, mentioned below. It will get you around the problem of caches - which is a major problem for something like this. I'm not sure what the situation with apache is regarding caches. PHP's own function to query the web server and do your own timing with microtime() function or another suitable for your purposes. In order for flush() results to reach you (in a browser) they have to pass from multiple caches like PHP's, Apache's, the occasional proxies and finally the browser's own cache. So you cannot get dependaple results measuring times or responses from your browser. Try the methods above. And a final tip... When Rasmus speaks, you don't question him:-) Period. Unless you didn't understand what he said and want clarification. Have a nice day, -Stathis On Saturday 16 July 2005 04:41, Liang ZHONG wrote: Hi Rasmus, You are right. It was the problem with the browser. I used Mozilla Firefox to try, and do not know what consideration it just serialized the identical url http requests. I then turned to use 2 IE 6.0 windows, 2 tabs within Maxthon browser, one IE windows and one Firefox, to test. Then I got the conclusion as you told. Thank you very much for the help. BTW, I could not get the flush() work, neither flush() with ob_flush(). I tried almost all methods mentioned in the followed posts under http://us2.php.net/flush, but none of them can really pushed the buffer out. The site is configurated with http://liang.ns2user.info/php/info.php on Red head, kernel 2.4.29. What can I do to get it work? Thank you again. Liang ZHONG wrote: Could you please explain it a little bit more? I did test this way. The code is the same for a.php and b.php ?php sleep(20); print Done. br /; ? I place request from 2 browser windows. First time, I placed with http://baseURL/a.php with both 2 browsers, starting times have 5 second interval. Then the first Done shows after 20 seconds and the second Done shows 20 seconds after the first Done. Then, I placed one browser with http://baseURL/a.php and the second one with http://baseURL/b.php, with starting time of 5 second interval. Then I got the first browser showing Done after 20 seconds and 5 seconds later, the second browser showed Done, too. Thus it seems that the apache can spoon out multiple php interpreters responding to http requests, while php can not deal with concurrent process from one program. I have no idea what you did to configure it this way. I wouldn't even know how to do that if you asked me to. As far as PHP is concerned it has no idea which processes are handling which script files at any one point. So whether you request a.php and b.php at the same time or a.php twice at the same time, it makes absolutely no difference to PHP. If you are really seeing this, then the limitation is in your browser or somewhere else. Try making a.php output stuff so it becomes easier to see. As in for($i=0;$i20;$i++) { echo $i; flush(); sleep(1); } You should see the counter start counting as soon as you hit the page. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about apache-php concurrent process control
Liang wrote: I am a programmer and new to php. I wonder what process control can php interpreter do for multithreading . I notice that through http request, php interpreter can execute 2 php programs simataneously, but will only sequentially queued and execute if I try to execute one php code in the same time. Can somebody tell me is it a problem by php design not to be execute code concurrently, or some apache/php configuration problem where I can fix? Apache is a multi-process single-threaded architecture. 1 request, 1 process. Concurrent requests are handled by concurrent processes. What is it you think you need a second thread for during a request? -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about apache-php concurrent process control
As I know, apache-php works this way. When the web server gets an http request with file name extension .php, it will start the php interpreter to process the php file. Now I have a php program does something like this: when it is executing with one parameter p1, the program code goes to contact a database, gets back huge amount of data, writes it to file system. This will take pretty long time to finish. In the mean time, the same php code will be invoked by apache with another request, passing different parameter p2, indicates the code need to run to check the availability and read partial of the data which has already writen to the file system just now. The program location need to be in the same URL, but with only different parameter passing to it. for example: http://baseURL/a.php?v=p1 http://baseURL/a.php?v=p2 I want these 2 process can be run concurrently, but through a small test, I found out that they just sequentially execute one after the other. http://baseURL/a.php http://baseURL/b.php howevery can run concurrently well, it means that apache can invoke multiple php interpreter processes. But I do not know how to make php interpreter to do the same thing. Or 2 php interpreter processes process one php program sepreately without interfer with each other. Hope I have explained myself clearly. Thank you. From: Rasmus Lerdorf [EMAIL PROTECTED] To: Liang [EMAIL PROTECTED] CC: php-general@lists.php.net Subject: Re: [PHP] Question about apache-php concurrent process control Date: Fri, 15 Jul 2005 13:46:37 -0700 Liang wrote: I am a programmer and new to php. I wonder what process control can php interpreter do for multithreading . I notice that through http request, php interpreter can execute 2 php programs simataneously, but will only sequentially queued and execute if I try to execute one php code in the same time. Can somebody tell me is it a problem by php design not to be execute code concurrently, or some apache/php configuration problem where I can fix? Apache is a multi-process single-threaded architecture. 1 request, 1 process. Concurrent requests are handled by concurrent processes. What is it you think you need a second thread for during a request? -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about apache-php concurrent process control
Liang ZHONG wrote: As I know, apache-php works this way. When the web server gets an http request with file name extension .php, it will start the php interpreter to process the php file. Now I have a php program does something like this: when it is executing with one parameter p1, the program code goes to contact a database, gets back huge amount of data, writes it to file system. This will take pretty long time to finish. In the mean time, the same php code will be invoked by apache with another request, passing different parameter p2, indicates the code need to run to check the availability and read partial of the data which has already writen to the file system just now. The program location need to be in the same URL, but with only different parameter passing to it. for example: http://baseURL/a.php?v=p1 http://baseURL/a.php?v=p2 I want these 2 process can be run concurrently, but through a small test, I found out that they just sequentially execute one after the other. Sorry, your test is wrong then. Apache/PHP does not serialize requests like that. If somehow the backend you are collecting data from is serializing the requests, then you are out of luck and frontend threads isn't going to solve that since your threads would simply be serialized as well. You are on the wrong track here. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about apache-php concurrent process control
Could you please explain it a little bit more? I did test this way. The code is the same for a.php and b.php ?php sleep(20); print Done. br /; ? I place request from 2 browser windows. First time, I placed with http://baseURL/a.php with both 2 browsers, starting times have 5 second interval. Then the first Done shows after 20 seconds and the second Done shows 20 seconds after the first Done. Then, I placed one browser with http://baseURL/a.php and the second one with http://baseURL/b.php, with starting time of 5 second interval. Then I got the first browser showing Done after 20 seconds and 5 seconds later, the second browser showed Done, too. Thus it seems that the apache can spoon out multiple php interpreters responding to http requests, while php can not deal with concurrent process from one program. I do not know if it is due to the php's design limitation, or I did not configure the php correctly to fulfill its full functionality? Thank you Liang ZHONG wrote: As I know, apache-php works this way. When the web server gets an http request with file name extension .php, it will start the php interpreter to process the php file. Now I have a php program does something like this: when it is executing with one parameter p1, the program code goes to contact a database, gets back huge amount of data, writes it to file system. This will take pretty long time to finish. In the mean time, the same php code will be invoked by apache with another request, passing different parameter p2, indicates the code need to run to check the availability and read partial of the data which has already writen to the file system just now. The program location need to be in the same URL, but with only different parameter passing to it. for example: http://baseURL/a.php?v=p1 http://baseURL/a.php?v=p2 I want these 2 process can be run concurrently, but through a small test, I found out that they just sequentially execute one after the other. Sorry, your test is wrong then. Apache/PHP does not serialize requests like that. If somehow the backend you are collecting data from is serializing the requests, then you are out of luck and frontend threads isn't going to solve that since your threads would simply be serialized as well. You are on the wrong track here. -Rasmus -- 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] Question about apache-php concurrent process control
Liang ZHONG wrote: Could you please explain it a little bit more? I did test this way. The code is the same for a.php and b.php ?php sleep(20); print Done. br /; ? I place request from 2 browser windows. First time, I placed with http://baseURL/a.php with both 2 browsers, starting times have 5 second interval. Then the first Done shows after 20 seconds and the second Done shows 20 seconds after the first Done. Then, I placed one browser with http://baseURL/a.php and the second one with http://baseURL/b.php, with starting time of 5 second interval. Then I got the first browser showing Done after 20 seconds and 5 seconds later, the second browser showed Done, too. Thus it seems that the apache can spoon out multiple php interpreters responding to http requests, while php can not deal with concurrent process from one program. I have no idea what you did to configure it this way. I wouldn't even know how to do that if you asked me to. As far as PHP is concerned it has no idea which processes are handling which script files at any one point. So whether you request a.php and b.php at the same time or a.php twice at the same time, it makes absolutely no difference to PHP. If you are really seeing this, then the limitation is in your browser or somewhere else. Try making a.php output stuff so it becomes easier to see. As in for($i=0;$i20;$i++) { echo $i; flush(); sleep(1); } You should see the counter start counting as soon as you hit the page. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about apache-php concurrent process control
Hi Rasmus, You are right. It was the problem with the browser. I used Mozilla Firefox to try, and do not know what consideration it just serialized the identical url http requests. I then turned to use 2 IE 6.0 windows, 2 tabs within Maxthon browser, one IE windows and one Firefox, to test. Then I got the conclusion as you told. Thank you very much for the help. BTW, I could not get the flush() work, neither flush() with ob_flush(). I tried almost all methods mentioned in the followed posts under http://us2.php.net/flush, but none of them can really pushed the buffer out. The site is configurated with http://liang.ns2user.info/php/info.php on Red head, kernel 2.4.29. What can I do to get it work? Thank you again. Liang ZHONG wrote: Could you please explain it a little bit more? I did test this way. The code is the same for a.php and b.php ?php sleep(20); print Done. br /; ? I place request from 2 browser windows. First time, I placed with http://baseURL/a.php with both 2 browsers, starting times have 5 second interval. Then the first Done shows after 20 seconds and the second Done shows 20 seconds after the first Done. Then, I placed one browser with http://baseURL/a.php and the second one with http://baseURL/b.php, with starting time of 5 second interval. Then I got the first browser showing Done after 20 seconds and 5 seconds later, the second browser showed Done, too. Thus it seems that the apache can spoon out multiple php interpreters responding to http requests, while php can not deal with concurrent process from one program. I have no idea what you did to configure it this way. I wouldn't even know how to do that if you asked me to. As far as PHP is concerned it has no idea which processes are handling which script files at any one point. So whether you request a.php and b.php at the same time or a.php twice at the same time, it makes absolutely no difference to PHP. If you are really seeing this, then the limitation is in your browser or somewhere else. Try making a.php output stuff so it becomes easier to see. As in for($i=0;$i20;$i++) { echo $i; flush(); sleep(1); } You should see the counter start counting as soon as you hit the page. -Rasmus -- 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] Question to eregi Syntax
Do a search on the php website or the php offline manual for Pattern Syntax -Original Message- From: janbro [mailto:[EMAIL PROTECTED] Sent: 07 July 2005 15:30 To: php-general@lists.php.net Subject: [PHP] Question to eregi Syntax * This e-mail has been received by the Revenue Internet e-mail service. * Hi List, my research hasn't turned anything useful up. Probably 'cause I don't have enough info. I've been playing around with the ereg function. What I was wondering is what is the ^ for like in the below example? ereg('[^[:space:]a-zA-Z0-9_.-]{1,}', $name) thx janbro -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php This message has been delivered to the Internet by the Revenue Internet e-mail service * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about HTTP 301 permanent redirects
Kevin L'Huillier wrote: On 27/06/05, Dr. Brad Lustick [EMAIL PROTECTED] wrote: I'm a novice trying to understand the exact construction of code for doing an HTTP 301 permanent redirect for a server coded in PHP. Could someone please tell me how I would handle the following example? In your case you might want to do something like: $article = $_REQUEST['i']; // some validation of $article if necessary $url = sprintf('/services.php/%s'. $i); header('Location: ' . $url); WRONG. He specifically said please only reply if you know how. Obviously you do not. To do an HTTP/1.1 *301 Permanent Redirect* not a *302 Found* Redirect as you described, that code would need to be altered to: $article = $_REQUEST['i']; // some validation of $article if necessary $url = sprintf('/services.php/%s'. $i); header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . $url); Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about HTTP 301 permanent redirects
Jasper Bryant-Greene wrote: Kevin L'Huillier wrote: On 27/06/05, Dr. Brad Lustick [EMAIL PROTECTED] wrote: I'm a novice trying to understand the exact construction of code for doing an HTTP 301 permanent redirect for a server coded in PHP. Could someone please tell me how I would handle the following example? I don't think the server itself is coded in php - and regardless of the technology used to deliver a site, php is not required to output a HTTP header - although it does make it easy :-) In your case you might want to do something like: $article = $_REQUEST['i']; // some validation of $article if necessary $url = sprintf('/services.php/%s'. $i); header('Location: ' . $url); WRONG. He specifically said please only reply if you know how. Obviously you do not. and you can't ber bothered to read properly either, you reuse the other guys' code but you fail to see it has blatant typos in it - given your resounding WRONG I figure the least you could do it post something that isn't. besides if you ask me, saying things like please only reply if you know how is: a, pretty implicit when asking a question. b, shortsighted c, a little rude d, the OP has the title 'Dr.' - now I have friends who are doctors in various fields, and I expect everyone of them to be able to use google, ... hint hint. thankfully Jasper 'knows how' To do an HTTP/1.1 *301 Permanent Redirect* not a *302 Found* Redirect as you described, that code would need to be altered to: $article = $_REQUEST['i']; // some validation of $article if necessary $url = sprintf('/services.php/%s'. $i); ^ typo! (also where is $i coming from?) header('HTTP/1.1 301 Moved Permanently'); also consider that using 'Status' may be better or possibly both to cover you bases, e.g.: ?php header(HTTP/1.1 301 Moved Permanently); header(Status: 301 Moved Permanently); ? header('Location: ' . $url); Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about HTTP 301 permanent redirects
Jochem Maas wrote: header('HTTP/1.1 301 Moved Permanently'); also consider that using 'Status' may be better or possibly both to cover you bases, e.g.: ?php header(HTTP/1.1 301 Moved Permanently); header(Status: 301 Moved Permanently); ? Waste of time. Go read the HTTP spec. Apologies for missing the typos, I was rather in a hurry. The point is, it wasn't a 301 redirect. Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about HTTP 301 permanent redirects
Jasper Bryant-Greene wrote: Jochem Maas wrote: header('HTTP/1.1 301 Moved Permanently'); also consider that using 'Status' may be better or possibly both to cover you bases, e.g.: ?php header(HTTP/1.1 301 Moved Permanently); header(Status: 301 Moved Permanently); ? Waste of time. Go read the HTTP spec. Apologies for missing the typos, I was rather in a hurry. The point is, it wasn't a 301 redirect. It's not really a waste of time. Some apache/php configurations accept only the first form, some only the second. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about HTTP 301 permanent redirects
Jasper Bryant-Greene wrote: Jochem Maas wrote: header('HTTP/1.1 301 Moved Permanently'); also consider that using 'Status' may be better or possibly both to cover you bases, e.g.: ?php header(HTTP/1.1 301 Moved Permanently); header(Status: 301 Moved Permanently); ? Waste of time. Go read the HTTP spec. Apologies for missing the typos, I that would be the first time in history a web related spec actually worked as stated ON EVERY BROWSER/SERVER. notice the use of the words 'may be' and 'possibly', also you might wish to note it wasn't a spec-driven comment but a 'get-it-working'-driven comment - fact is there are people who have experienced problems with outputting of just the 'HTTP/1.1 301 Moved Permanently' (and it not doing what they want) was rather in a hurry. The point is, it wasn't a 301 redirect very pointy indeed. Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about HTTP 301 permanent redirects
Hi Actually you can get away with this: header(Location: $url,301); This will let php generate the proper headers Also, and I stress this point (again and again), the http specification clearly states that location headers need to have a *fully qualified url* not a site-specific one. Failure to do so puts the proper working of your site in the hands of the end user's browser who may very well fail to redirect because he doesn't find http://yourpage.php. (some browser do handle this correctly, but that's besides the point). HTH Andy -- Registered Linux User Number 379093 -- --BEGIN GEEK CODE BLOCK- Version: 3.1 GAT/O/E$ d-(---)+ s:(+): a--(-)? C$(+++) UL$ P-(+)++ L+++$ E---(-)@ W++$ !N@ o? !K? W--(---) !O !M- V-- PS++(+++) PE--(-) Y+ PGP++(+++) t+(++) 5-- X++ R*(+)@ !tv b-() DI(+) D+(+++) G(+) e$@ h++(*) r--++ y--() -- ---END GEEK CODE BLOCK-- -- Check out these few php utilities that I released under the GPL2 and that are meant for use with a php cli binary: http://www.vlaamse-kern.com/sas/ -- -- pgpQ96QzDJCW7.pgp Description: PGP signature
Re: [PHP] Question about HTTP 301 permanent redirects
On Wednesday 29 June 2005 00:31, Andy Pieters wrote: Hi Actually you can get away with this: header(Location: $url,301); Well it looks like we all make typos Header(Location: $url,true,301); is more like it This will let php generate the proper headers Also, and I stress this point (again and again), the http specification clearly states that location headers need to have a *fully qualified url* not a site-specific one. Failure to do so puts the proper working of your site in the hands of the end user's browser who may very well fail to redirect because he doesn't find http://yourpage.php. (some browser do handle this correctly, but that's besides the point). HTH Andy -- Registered Linux User Number 379093 -- --BEGIN GEEK CODE BLOCK- Version: 3.1 GAT/O/E$ d-(---)+ s:(+): a--(-)? C$(+++) UL$ P-(+)++ L+++$ E---(-)@ W++$ !N@ o? !K? W--(---) !O !M- V-- PS++(+++) PE--(-) Y+ PGP++(+++) t+(++) 5-- X++ R*(+)@ !tv b-() DI(+) D+(+++) G(+) e$@ h++(*) r--++ y--() -- ---END GEEK CODE BLOCK-- -- Check out these few php utilities that I released under the GPL2 and that are meant for use with a php cli binary: http://www.vlaamse-kern.com/sas/ -- -- pgpr00gTfHMlK.pgp Description: PGP signature
Re: [PHP] Question about HTTP 301 permanent redirects
On 27/06/05, Dr. Brad Lustick [EMAIL PROTECTED] wrote: I'm a novice trying to understand the exact construction of code for doing an HTTP 301 permanent redirect for a server coded in PHP. Could someone please tell me how I would handle the following example? http://www.nimblepedic.com/services-bodytools.php?i=bodytools WANT TO DO A HTTP 301 REDIRECT TO: http://www.nimblepedic.com/services.php/body_tools There are a few examples at http://php.net/header In your case you might want to do something like: $article = $_REQUEST['i']; // some validation of $article if necessary $url = sprintf('/services.php/%s'. $i); header('Location: ' . $url); (Also, that's a hell of a signature.) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question to example from manual
On Thu, June 16, 2005 1:31 pm, janbro said: Hi, I've been working on this example and copied it in my webroot, it doesn't give me an output. Does anybody know why? System WinXP Apache 2.0.50 php 5.0.3 thx janbro Example 7-6. Static variables with recursive functions ?php function Test() { static $count = 0; $count++; echo $count; if ($count 10) { Test (); } $count--; } ? You defined the function, but never called it. Add a line that does: Test(); at the end. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question about system function call
On Thu, June 16, 2005 2:43 pm, Tom Cruickshank said: I'm trying to do the following in php. system(/usr/bin/smbutil -v view //[EMAIL PROTECTED]) to be able to view some shares folders on a server. Unfortunately, if I use this command in console, I get prompted for a password. Is there a way in php to wait for a password and enter it automatically? Please let me know. Thanks! smbutil may or may not accept a password as an argument. Something like: smbutil --password=SECRET -v view //[EMAIL PROTECTED] If not, you MIGHT be able to do: system(echo SECRET\n | /usr/bin/smbutil -v view //[EMAIL PROTECTED]); You may need to dink around with the \n part to get it into the shell rather than in the PHP string... system(echo -e \SECRET\\n\ | /usr/bin/smbutil -v view //[EMAIL PROTECTED]); You should use exec instead during experimentation at least, so you can get error messages... Actually, exec is probably better all around, unless you really need passthru for performance reasons... smbutil *might* require a TTY (a REAL logged in person) the way some programs do. If its documenation says so, I think you're out of luck on the password bit. There might be other options, like SSH key-pair authentication or Kereberos or, for all I know, somebody wrote a PHP Samba Module while I wasn't looking... I'd probably never use it, so wouldn't have noticed. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about acessing databases and formatting output
On Mon, May 09, 2005 at 10:41:22PM +0530, bala chandar wrote: On 5/9/05, The Doctor [EMAIL PROTECTED] wrote: On Mon, May 09, 2005 at 08:19:47PM +0530, bala chandar wrote: Hi, On 5/9/05, The Doctor [EMAIL PROTECTED] wrote: On Mon, May 09, 2005 at 08:29:34AM +0530, bala chandar wrote: On 5/9/05, bala chandar [EMAIL PROTECTED] wrote: Hi On 5/9/05, The Doctor [EMAIL PROTECTED] wrote: On Sun, May 08, 2005 at 01:49:08PM -0600, The Doctor wrote: On Sun, May 08, 2005 at 08:56:25PM +0530, bala chandar wrote: On 5/8/05, The Doctor [EMAIL PROTECTED] wrote: On Thu, May 05, 2005 at 05:49:38AM -0600, The Doctor wrote: On Thu, May 05, 2005 at 10:11:14AM +0530, bala chandar wrote: hi, On 5/5/05, The Doctor [EMAIL PROTECTED] wrote: This is probably easy, but how does one access a database, mysql or oracle or postgresql, and present the data in a tabular format? -- check out http://in2.php.net/mysql Looks good to me. So far so good except my blobs are appearing as is instead of as an interpret item. What next? -- what are you storing in BLOB? First a .tgf and then a jpg. hey, check out this. this might help you http://www.zend.com/zend/trick/tricks-sept-2001.php http://forum.100megswebhosting.com/archive/index.php/t-2971.html Is their a way to embed the third column? And what changes do I need to make to the php code? Seems to be correct. Here is what I think: All the non-blobs are working fine; it is the blobs that are turning up as text instead of data. Can you not tell the PHP scripts the following: if a blob then present the data as binary else present the text endif ? I think you cannot judge the content of the blob. for text use the data type text instead of blob Can you please clarify? kindly check this link http://forums.devshed.com/archive/t-63144/UserContributed-PHP-Mysql-and-Images I shall read closely. Today I did generate a script, but I am lacking the fact that I cannot tell the script not to treat the blob differetly: ? session_start(); ? html head titledb -- query_1/title meta name=generator content=PHP Generator Wizard /head style type=text/css body { background-color: #FF; color: #004080; font-family: Arial; font-size: 12px; } .bd { background-color: #FF; color: #004080; font-family: Arial; font-size: 12px; } .tbl { background-color: #FF; } a:link { color: #FF; font-family: Arial; font-size: 12px; } a:active { color: #FF; font-family: Arial; font-size: 12px; } a:visited { color: #800080; font-family: Arial; font-size: 12px; } .hr { background-color: #336699; color: #FF; font-family: Arial; font-size: 12px; } a.hr:link { color: #FF; font-family: Arial; font-size: 12px; } a.hr:active { color: #FF; font-family: Arial; font-size: 12px; } a.hr:visited { color: #FF; font-family: Arial; font-size: 12px; } .dr { background-color: #FF; color: #00; font-family: Arial; font-size: 12px; } .sr { background-color: #CF; color: #00; font-family: Arial; font-size: 12px; } /style table width=100% tr td width=5% /td td bgcolor=#e0e0e0 /td td width=5% /td td width=80% valign=top ? $conn = connect(); $showrecs = 100; $pagerange = 10; $a = @$HTTP_GET_VARS[a]; $recid = @$HTTP_GET_VARS[recid]; $page = @$HTTP_GET_VARS[page]; if (!isset($page)) $page = 1; switch ($a) { case view: viewrec($recid); break; default: select(); break; } mysql_close($conn); ? /td/tr/table /html ? function select() { global $showrecs; global $page; $res = sql_select(); $count = mysql_num_rows($res); if ($count % $showrecs != 0) { $pagecount = intval($count / $showrecs) + 1; } else { $pagecount = intval($count / $showrecs); } $startrec = $showrecs * ($page - 1); @mysql_data_seek($res, $startrec); $reccount = min($showrecs * $page, $count); $fields = array (catno, name1, structure); ? table class=bd border=0 cellspacing=1 cellpadding=4 trtdTable: query_1/td/tr trtdRecords shown: ? echo $startrec + 1 ? - ? echo $reccount ? of ? echo $count ?/td/tr /table hr size=1 noshade ? showpagenav($page, $pagecount); ? br table class=tbl border=0 cellspacing=1 cellpadding=5width=100% tr ? reset($fields); foreach($fields as $val){ ? td class=hr? echo $val ?/td
Re: [PHP] Question about acessing databases and formatting output
On Mon, May 09, 2005 at 08:29:34AM +0530, bala chandar wrote: On 5/9/05, bala chandar [EMAIL PROTECTED] wrote: Hi On 5/9/05, The Doctor [EMAIL PROTECTED] wrote: On Sun, May 08, 2005 at 01:49:08PM -0600, The Doctor wrote: On Sun, May 08, 2005 at 08:56:25PM +0530, bala chandar wrote: On 5/8/05, The Doctor [EMAIL PROTECTED] wrote: On Thu, May 05, 2005 at 05:49:38AM -0600, The Doctor wrote: On Thu, May 05, 2005 at 10:11:14AM +0530, bala chandar wrote: hi, On 5/5/05, The Doctor [EMAIL PROTECTED] wrote: This is probably easy, but how does one access a database, mysql or oracle or postgresql, and present the data in a tabular format? -- check out http://in2.php.net/mysql Looks good to me. So far so good except my blobs are appearing as is instead of as an interpret item. What next? -- what are you storing in BLOB? First a .tgf and then a jpg. hey, check out this. this might help you http://www.zend.com/zend/trick/tricks-sept-2001.php http://forum.100megswebhosting.com/archive/index.php/t-2971.html Is their a way to embed the third column? And what changes do I need to make to the php code? Seems to be correct. Here is what I think: All the non-blobs are working fine; it is the blobs that are turning up as text instead of data. Can you not tell the PHP scripts the following: if a blob then present the data as binary else present the text endif ? -- Member - Liberal International This is [EMAIL PROTECTED] Ici [EMAIL PROTECTED] God Queen and country! Beware Anti-Christ rising! BC, Vote Liberal!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about acessing databases and formatting output
Hi, On 5/9/05, The Doctor [EMAIL PROTECTED] wrote: On Mon, May 09, 2005 at 08:29:34AM +0530, bala chandar wrote: On 5/9/05, bala chandar [EMAIL PROTECTED] wrote: Hi On 5/9/05, The Doctor [EMAIL PROTECTED] wrote: On Sun, May 08, 2005 at 01:49:08PM -0600, The Doctor wrote: On Sun, May 08, 2005 at 08:56:25PM +0530, bala chandar wrote: On 5/8/05, The Doctor [EMAIL PROTECTED] wrote: On Thu, May 05, 2005 at 05:49:38AM -0600, The Doctor wrote: On Thu, May 05, 2005 at 10:11:14AM +0530, bala chandar wrote: hi, On 5/5/05, The Doctor [EMAIL PROTECTED] wrote: This is probably easy, but how does one access a database, mysql or oracle or postgresql, and present the data in a tabular format? -- check out http://in2.php.net/mysql Looks good to me. So far so good except my blobs are appearing as is instead of as an interpret item. What next? -- what are you storing in BLOB? First a .tgf and then a jpg. hey, check out this. this might help you http://www.zend.com/zend/trick/tricks-sept-2001.php http://forum.100megswebhosting.com/archive/index.php/t-2971.html Is their a way to embed the third column? And what changes do I need to make to the php code? Seems to be correct. Here is what I think: All the non-blobs are working fine; it is the blobs that are turning up as text instead of data. Can you not tell the PHP scripts the following: if a blob then present the data as binary else present the text endif ? I think you cannot judge the content of the blob. for text use the data type text instead of blob -- Member - Liberal International This is [EMAIL PROTECTED] Ici [EMAIL PROTECTED] God Queen and country! Beware Anti-Christ rising! BC, Vote Liberal!! -- bala balachandar muruganantham blog lynx http://chandar.blogspot.com web http://www.chennaishopping.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about acessing databases and formatting output
On Mon, May 09, 2005 at 08:19:47PM +0530, bala chandar wrote: Hi, On 5/9/05, The Doctor [EMAIL PROTECTED] wrote: On Mon, May 09, 2005 at 08:29:34AM +0530, bala chandar wrote: On 5/9/05, bala chandar [EMAIL PROTECTED] wrote: Hi On 5/9/05, The Doctor [EMAIL PROTECTED] wrote: On Sun, May 08, 2005 at 01:49:08PM -0600, The Doctor wrote: On Sun, May 08, 2005 at 08:56:25PM +0530, bala chandar wrote: On 5/8/05, The Doctor [EMAIL PROTECTED] wrote: On Thu, May 05, 2005 at 05:49:38AM -0600, The Doctor wrote: On Thu, May 05, 2005 at 10:11:14AM +0530, bala chandar wrote: hi, On 5/5/05, The Doctor [EMAIL PROTECTED] wrote: This is probably easy, but how does one access a database, mysql or oracle or postgresql, and present the data in a tabular format? -- check out http://in2.php.net/mysql Looks good to me. So far so good except my blobs are appearing as is instead of as an interpret item. What next? -- what are you storing in BLOB? First a .tgf and then a jpg. hey, check out this. this might help you http://www.zend.com/zend/trick/tricks-sept-2001.php http://forum.100megswebhosting.com/archive/index.php/t-2971.html Is their a way to embed the third column? And what changes do I need to make to the php code? Seems to be correct. Here is what I think: All the non-blobs are working fine; it is the blobs that are turning up as text instead of data. Can you not tell the PHP scripts the following: if a blob then present the data as binary else present the text endif ? I think you cannot judge the content of the blob. for text use the data type text instead of blob Can you please clarify? -- Member - Liberal International This is [EMAIL PROTECTED] Ici [EMAIL PROTECTED] God Queen and country! Beware Anti-Christ rising! BC, Vote Liberal!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about acessing databases and formatting output
On 5/9/05, The Doctor [EMAIL PROTECTED] wrote: On Mon, May 09, 2005 at 08:19:47PM +0530, bala chandar wrote: Hi, On 5/9/05, The Doctor [EMAIL PROTECTED] wrote: On Mon, May 09, 2005 at 08:29:34AM +0530, bala chandar wrote: On 5/9/05, bala chandar [EMAIL PROTECTED] wrote: Hi On 5/9/05, The Doctor [EMAIL PROTECTED] wrote: On Sun, May 08, 2005 at 01:49:08PM -0600, The Doctor wrote: On Sun, May 08, 2005 at 08:56:25PM +0530, bala chandar wrote: On 5/8/05, The Doctor [EMAIL PROTECTED] wrote: On Thu, May 05, 2005 at 05:49:38AM -0600, The Doctor wrote: On Thu, May 05, 2005 at 10:11:14AM +0530, bala chandar wrote: hi, On 5/5/05, The Doctor [EMAIL PROTECTED] wrote: This is probably easy, but how does one access a database, mysql or oracle or postgresql, and present the data in a tabular format? -- check out http://in2.php.net/mysql Looks good to me. So far so good except my blobs are appearing as is instead of as an interpret item. What next? -- what are you storing in BLOB? First a .tgf and then a jpg. hey, check out this. this might help you http://www.zend.com/zend/trick/tricks-sept-2001.php http://forum.100megswebhosting.com/archive/index.php/t-2971.html Is their a way to embed the third column? And what changes do I need to make to the php code? Seems to be correct. Here is what I think: All the non-blobs are working fine; it is the blobs that are turning up as text instead of data. Can you not tell the PHP scripts the following: if a blob then present the data as binary else present the text endif ? I think you cannot judge the content of the blob. for text use the data type text instead of blob Can you please clarify? kindly check this link http://forums.devshed.com/archive/t-63144/UserContributed-PHP-Mysql-and-Images -- bala balachandar muruganantham blog lynx http://chandar.blogspot.com web http://www.chennaishopping.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about acessing databases and formatting output
On Thu, May 05, 2005 at 05:49:38AM -0600, The Doctor wrote: On Thu, May 05, 2005 at 10:11:14AM +0530, bala chandar wrote: hi, On 5/5/05, The Doctor [EMAIL PROTECTED] wrote: This is probably easy, but how does one access a database, mysql or oracle or postgresql, and present the data in a tabular format? -- Member - Liberal International This is [EMAIL PROTECTED] Ici [EMAIL PROTECTED] God Queen and country! Beware Anti-Christ rising! UK as 5 May 2005 approaches, vote LDem!! check out http://in2.php.net/mysql Looks good to me. So far so good except my blobs are appearing as is instead of as an interpret item. What next? -- bala balachandar muruganantham blog lynx http://chandar.blogspot.com web http://www.chennaishopping.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Member - Liberal International This is [EMAIL PROTECTED] Ici [EMAIL PROTECTED] God Queen and country! Beware Anti-Christ rising! UK as 5 May 2005 approaches, vote LDem!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Member - Liberal International This is [EMAIL PROTECTED] Ici [EMAIL PROTECTED] God Queen and country! Beware Anti-Christ rising! BC, Vote Liberal!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about acessing databases and formatting output
On 5/8/05, The Doctor [EMAIL PROTECTED] wrote: On Thu, May 05, 2005 at 05:49:38AM -0600, The Doctor wrote: On Thu, May 05, 2005 at 10:11:14AM +0530, bala chandar wrote: hi, On 5/5/05, The Doctor [EMAIL PROTECTED] wrote: This is probably easy, but how does one access a database, mysql or oracle or postgresql, and present the data in a tabular format? -- check out http://in2.php.net/mysql Looks good to me. So far so good except my blobs are appearing as is instead of as an interpret item. What next? -- what are you storing in BLOB? -- bala balachandar muruganantham blog lynx http://chandar.blogspot.com web http://www.chennaishopping.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about acessing databases and formatting output
On Sun, May 08, 2005 at 08:56:25PM +0530, bala chandar wrote: On 5/8/05, The Doctor [EMAIL PROTECTED] wrote: On Thu, May 05, 2005 at 05:49:38AM -0600, The Doctor wrote: On Thu, May 05, 2005 at 10:11:14AM +0530, bala chandar wrote: hi, On 5/5/05, The Doctor [EMAIL PROTECTED] wrote: This is probably easy, but how does one access a database, mysql or oracle or postgresql, and present the data in a tabular format? -- check out http://in2.php.net/mysql Looks good to me. So far so good except my blobs are appearing as is instead of as an interpret item. What next? -- what are you storing in BLOB? First a .tgf and then a jpg. -- bala balachandar muruganantham blog lynx http://chandar.blogspot.com web http://www.chennaishopping.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Member - Liberal International This is [EMAIL PROTECTED] Ici [EMAIL PROTECTED] God Queen and country! Beware Anti-Christ rising! BC, Vote Liberal!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about acessing databases and formatting output
On Sun, May 08, 2005 at 01:49:08PM -0600, The Doctor wrote: On Sun, May 08, 2005 at 08:56:25PM +0530, bala chandar wrote: On 5/8/05, The Doctor [EMAIL PROTECTED] wrote: On Thu, May 05, 2005 at 05:49:38AM -0600, The Doctor wrote: On Thu, May 05, 2005 at 10:11:14AM +0530, bala chandar wrote: hi, On 5/5/05, The Doctor [EMAIL PROTECTED] wrote: This is probably easy, but how does one access a database, mysql or oracle or postgresql, and present the data in a tabular format? -- check out http://in2.php.net/mysql Looks good to me. So far so good except my blobs are appearing as is instead of as an interpret item. What next? -- what are you storing in BLOB? First a .tgf and then a jpg. Is their a way to embed the third column? And what changes do I need to make to the php code? -- bala balachandar muruganantham blog lynx http://chandar.blogspot.com web http://www.chennaishopping.com -- -- Member - Liberal International This is [EMAIL PROTECTED] Ici [EMAIL PROTECTED] God Queen and country! Beware Anti-Christ rising! BC, Vote Liberal!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about acessing databases and formatting output
Hi On 5/9/05, The Doctor [EMAIL PROTECTED] wrote: On Sun, May 08, 2005 at 01:49:08PM -0600, The Doctor wrote: On Sun, May 08, 2005 at 08:56:25PM +0530, bala chandar wrote: On 5/8/05, The Doctor [EMAIL PROTECTED] wrote: On Thu, May 05, 2005 at 05:49:38AM -0600, The Doctor wrote: On Thu, May 05, 2005 at 10:11:14AM +0530, bala chandar wrote: hi, On 5/5/05, The Doctor [EMAIL PROTECTED] wrote: This is probably easy, but how does one access a database, mysql or oracle or postgresql, and present the data in a tabular format? -- check out http://in2.php.net/mysql Looks good to me. So far so good except my blobs are appearing as is instead of as an interpret item. What next? -- what are you storing in BLOB? First a .tgf and then a jpg. hey, check out this. this might help you http://www.zend.com/zend/trick/tricks-sept-2001.php Is their a way to embed the third column? And what changes do I need to make to the php code? -- bala balachandar muruganantham blog lynx http://chandar.blogspot.com web http://www.chennaishopping.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about acessing databases and formatting output
On 5/9/05, bala chandar [EMAIL PROTECTED] wrote: Hi On 5/9/05, The Doctor [EMAIL PROTECTED] wrote: On Sun, May 08, 2005 at 01:49:08PM -0600, The Doctor wrote: On Sun, May 08, 2005 at 08:56:25PM +0530, bala chandar wrote: On 5/8/05, The Doctor [EMAIL PROTECTED] wrote: On Thu, May 05, 2005 at 05:49:38AM -0600, The Doctor wrote: On Thu, May 05, 2005 at 10:11:14AM +0530, bala chandar wrote: hi, On 5/5/05, The Doctor [EMAIL PROTECTED] wrote: This is probably easy, but how does one access a database, mysql or oracle or postgresql, and present the data in a tabular format? -- check out http://in2.php.net/mysql Looks good to me. So far so good except my blobs are appearing as is instead of as an interpret item. What next? -- what are you storing in BLOB? First a .tgf and then a jpg. hey, check out this. this might help you http://www.zend.com/zend/trick/tricks-sept-2001.php http://forum.100megswebhosting.com/archive/index.php/t-2971.html Is their a way to embed the third column? And what changes do I need to make to the php code? -- bala balachandar muruganantham blog lynx http://chandar.blogspot.com web http://www.chennaishopping.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about acessing databases and formatting output
On Thu, May 05, 2005 at 10:11:14AM +0530, bala chandar wrote: hi, On 5/5/05, The Doctor [EMAIL PROTECTED] wrote: This is probably easy, but how does one access a database, mysql or oracle or postgresql, and present the data in a tabular format? -- Member - Liberal International This is [EMAIL PROTECTED] Ici [EMAIL PROTECTED] God Queen and country! Beware Anti-Christ rising! UK as 5 May 2005 approaches, vote LDem!! check out http://in2.php.net/mysql Looks good to me. -- bala balachandar muruganantham blog lynx http://chandar.blogspot.com web http://www.chennaishopping.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Member - Liberal International This is [EMAIL PROTECTED] Ici [EMAIL PROTECTED] God Queen and country! Beware Anti-Christ rising! UK as 5 May 2005 approaches, vote LDem!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about acessing databases and formatting output
hi, On 5/5/05, The Doctor [EMAIL PROTECTED] wrote: This is probably easy, but how does one access a database, mysql or oracle or postgresql, and present the data in a tabular format? -- Member - Liberal International This is [EMAIL PROTECTED] Ici [EMAIL PROTECTED] God Queen and country! Beware Anti-Christ rising! UK as 5 May 2005 approaches, vote LDem!! check out http://in2.php.net/mysql -- bala balachandar muruganantham blog lynx http://chandar.blogspot.com web http://www.chennaishopping.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question regarding PDF creation
MĂ¡rio Gamito mailto:[EMAIL PROTECTED] on Monday, April 18, 2005 3:01 AM said: I'm using FPDF (http://www.fpdf.org/) to create a... PDF. First of all thanks for asking this question because I was in need of building PDFs and lo and behold FPDF works great so far! $pdf-Cell(60,10,'Powered by FPDF.',0,1,'C'); $pdf-Cell(40,10,'CV de ' . $full_name . ',' . 0,0 . ',C'); The problem here is that the part ,0,1, is not stringed, while C is. So, what i get in the PDF is I haven't messed around with this package at all yet (I am currently going through the tutorials) but what I notice is that your quotes are messed up (I think). Notice that in the first example it is: ,0,1,'C'); Your example is: 0,0 . ',C'); I think it should be: 0,0,'C'); So I would write your line as: $pdf-Cell(40,10,CV de $full_name ,0,0,'C'); HTH, Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about fsockopen
Date: Sun, 10 Apr 2005 08:00:23 - (UTC) From: [EMAIL PROTECTED] I have several IP in one interface (eth0) in my server and I want make connection to another server (check email, etc) using different ip for every mail server. I was read the document, and there is no way how to make this happen. Any idea? You can do this with the CURL Extension, but then that limits you to the protocols supported by CURL. If that doesn't matter, take a look at CURLOPT_INTERFACE in curl_setopt() I'm afraid, I don't know how to do this with fsockopen() and weather it is possible at all. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about fsockopen
On Sun, April 10, 2005 1:00 am, [EMAIL PROTECTED] said: I have several IP in one interface (eth0) in my server and I want make connection to another server (check email, etc) using different ip for every mail server. I was read the document, and there is no way how to make this happen. Any idea? Errr, ummm, ah... I don't even know how you could do that AT ALL, much less with PHP... But if you can make it work on the command line somehow, I guess you could use http://php.net/exec to do it... *WHY* do you want to do this? -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about fsockopen
[EMAIL PROTECTED] wrote: Dear list, I have several IP in one interface (eth0) in my server and I want make connection to another server (check email, etc) using different ip for every mail server. I was read the document, and there is no way how to make this happen. Any idea? Thank you Take a look here : http://sourceforge.net/projects/snoopy/ , I'm not much sure but I think that it has that feature. -- Josip Dzolonga http://josip.dotgeek.org jdzolonga[at]gmail.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about fsockopen
Dear lists, I have tested it but it's not what I want to do. I am looking for any method to make multi connection with many ip from my box to download email from different mailserver. Thank you David T [EMAIL PROTECTED] wrote: Dear list, I have several IP in one interface (eth0) in my server and I want make connection to another server (check email, etc) using different ip for every mail server. I was read the document, and there is no way how to make this happen. Any idea? Thank you Take a look here : http://sourceforge.net/projects/snoopy/ , I'm not much sure but I think that it has that feature. -- Josip Dzolonga http://josip.dotgeek.org jdzolonga[at]gmail.com -- 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] Question about fsockopen
On Apr 10, 2005 9:12 PM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I have tested it but it's not what I want to do. I am looking for any method to make multi connection with many ip from my box to download email from different mailserver. The method I'd use to fetch mail is fetchmail. http://www.catb.org/~esr/fetchmail/ -- Greg Donald Zend Certified Engineer http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question about shortening a string
-Original Message- From: Steve Slater [mailto:[EMAIL PROTECTED] Sent: Saturday, March 12, 2005 5:29 PM $name_array = explode( ,$name); $short_name = $name_array[0] . end($name_array); And a dozen other ways to do it I'm sure. I just finished a project with a mess of pattern matching so have regex on the brain. :-) Hehe, I know the feeling Ereg solution: eregi(^([a-z] ).* ?([a-z])$, $name, $regs); print the name in short is $regs[1] $regs[2]; But when dealing with names I think Your approach is better since there´s all kinds of chararcters from language to language, in Denmark Ă†Ă¦Ă˜Ă¸Ă…Ă¥, in sweden äÄöÖ and so on. Of course I could do something like: ereg(^(.+ ).* ?(.+)$, $name, $regs); // untested -- Med venlig hilsen / best regards ComX Networks A/S Kim Madsen Systemudvikler Naverland 31 DK-2600 Glostrup www.comx.dk Telefon: +45 70 25 74 74 Telefax: +45 70 25 73 74 E-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about shortening a string
At 11:54 PM 3/11/2005, Stephen Johnson wrote: Just a quick and dirty solution - but couldn't you explode the name into an array and use the first and last array fields ? $name_array = explode( ,$name); $short_name = $name_array[0] . end($name_array); And a dozen other ways to do it I'm sure. I just finished a project with a mess of pattern matching so have regex on the brain. :-) Steve On Mar 11, 2005, at 11:39 PM, Steve Slater wrote: Mario, Many ways to do it, most using regex. This is not as clean as it can be but still shows the idea: ?php $name = Mario Augusto Machado dos Reis Gamito; preg_match (/^(\w+)(\W*)(\w+\W+)*(\w+)$/,$name,$matches); $short_name = $matches[1] $matches[4]; ? This example works for any number of middle names (including zero) and any number of white spaces between words. You can probably get this more elegant, but this is one idea. Steve In Portgal we have big names. My complete name, for instance, is MĂ¡rio Augusto Machado dos Reis Gamito. MĂ¡rio is the Christian name and Gamito - the last one - is always the last name of the father. I have a form where i want to let my users insert their full big name like mine, but i want to shorten them just to the first and the last. For example, if i fill the form with MĂ¡rio Augusto Machado dos Reis Gamito, i want to change this string to only MĂ¡rio Gamito. The total number of names is not fix. Could be 3, 4, 5, 6,... My son name is Manuel Ramos Gamito. Only 3 names. Should be changed to Manuel Gamito, also. I've looked at the strings functions in the manual, made a lot of experiences, but couldn't get there :( Does anyone knows how to do this ? Any help would be apreciated. Warm Regards, MĂ¡rio Gamito -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Steve Slater [EMAIL PROTECTED] PHP / MySQL / Web App Security (LAMP) Training: http://www.handsonsecurity.com/training.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php * Stephen Johnson [EMAIL PROTECTED] http://www.thelonecoder.com --continuing the struggle against bad code-- * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Steve Slater [EMAIL PROTECTED] PHP / MySQL / Web App Security (LAMP) Training: http://www.handsonsecurity.com/training.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about shortening a string
Mario, Many ways to do it, most using regex. This is not as clean as it can be but still shows the idea: ?php $name = Mario Augusto Machado dos Reis Gamito; preg_match (/^(\w+)(\W*)(\w+\W+)*(\w+)$/,$name,$matches); $short_name = $matches[1] $matches[4]; ? This example works for any number of middle names (including zero) and any number of white spaces between words. You can probably get this more elegant, but this is one idea. Steve In Portgal we have big names. My complete name, for instance, is MĂ¡rio Augusto Machado dos Reis Gamito. MĂ¡rio is the Christian name and Gamito - the last one - is always the last name of the father. I have a form where i want to let my users insert their full big name like mine, but i want to shorten them just to the first and the last. For example, if i fill the form with MĂ¡rio Augusto Machado dos Reis Gamito, i want to change this string to only MĂ¡rio Gamito. The total number of names is not fix. Could be 3, 4, 5, 6,... My son name is Manuel Ramos Gamito. Only 3 names. Should be changed to Manuel Gamito, also. I've looked at the strings functions in the manual, made a lot of experiences, but couldn't get there :( Does anyone knows how to do this ? Any help would be apreciated. Warm Regards, MĂ¡rio Gamito -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Steve Slater [EMAIL PROTECTED] PHP / MySQL / Web App Security (LAMP) Training: http://www.handsonsecurity.com/training.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about shortening a string
Just a quick and dirty solution - but couldn't you explode the name into an array and use the first and last array fields ? On Mar 11, 2005, at 11:39 PM, Steve Slater wrote: Mario, Many ways to do it, most using regex. This is not as clean as it can be but still shows the idea: ?php $name = Mario Augusto Machado dos Reis Gamito; preg_match (/^(\w+)(\W*)(\w+\W+)*(\w+)$/,$name,$matches); $short_name = $matches[1] $matches[4]; ? This example works for any number of middle names (including zero) and any number of white spaces between words. You can probably get this more elegant, but this is one idea. Steve In Portgal we have big names. My complete name, for instance, is MĂ¡rio Augusto Machado dos Reis Gamito. MĂ¡rio is the Christian name and Gamito - the last one - is always the last name of the father. I have a form where i want to let my users insert their full big name like mine, but i want to shorten them just to the first and the last. For example, if i fill the form with MĂ¡rio Augusto Machado dos Reis Gamito, i want to change this string to only MĂ¡rio Gamito. The total number of names is not fix. Could be 3, 4, 5, 6,... My son name is Manuel Ramos Gamito. Only 3 names. Should be changed to Manuel Gamito, also. I've looked at the strings functions in the manual, made a lot of experiences, but couldn't get there :( Does anyone knows how to do this ? Any help would be apreciated. Warm Regards, MĂ¡rio Gamito -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Steve Slater [EMAIL PROTECTED] PHP / MySQL / Web App Security (LAMP) Training: http://www.handsonsecurity.com/training.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php * Stephen Johnson [EMAIL PROTECTED] http://www.thelonecoder.com --continuing the struggle against bad code-- * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question re empty query
Jackson Linux wrote: Hi, This: if (isset($_GET['r']) !empty($_GET['r']) ($r = intval($_GET['r'])) ){ $r = {$_GET['r']}; //Set the variable $r to mean the category number for starters WTF is the preceding statement for??? $r is already set if it exists by the expression in the if statement... ($r = intval($_GET['r']) $fields = '*'; $sort = ORDER BY cv.sort; } else { this else block will fire if $r is invalid or not set. that means this is where you should write some code that either redirects to the 'list' page or outputs a list somehow. $where = ''; $fields = 'cv.cv_id,cv.category,dates,cv.job_title,cv.company,cv.job,cv.sort, jobcat.category'; $sort = ORDER BY cv.sort; } //Make the sql based on the joining of the table and intersection table $sql = SELECT cv.cv_id,cv.category,dates,cv.job_title,cv.company,cv.job,cv.sort,jobcat .category FROM cv, cvjobcats, jobcat WHERE cvjobcats.cv_id=cv.cv_id AND cvjobcats.jobcat_id = $r AND jobcat.jobcat_id=cvjobcats.jobcat_id; Works whenever there is an ?r= specified. When there is no r specified it chokes on WHERE cvjobcats.cv_id=cv.cv_id AND cvjobcats.jobcat_id = $r AND jobcat.jobcat_id=cvjobcats.jobcat_id; because there's no value to $r. it also opens me up to allowing anyone to state *anything* after the ?. So can I make an else statement which will say that if there's no r= or a wrong r= or even no ? at all then it should print a menu to $r's which actually exist in the database? How? you already have one - its just that your abusing it to set some completely pointless vars that containing bits of SQL. Thanks in advance!!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question: re: Session-only cookies and Firefox
RGL wrote: Question: Has anybody else noticed session-only cookies not disappearing when using Firefox? Is this a Firefox bug (should they be notified/ or I get latest Firefox) ? Using IE6 I can: setcookie('sesvar', 'this session only', 0, , www.mypersonaldomain.net); This can be read and disappears after the browser has been closed. Doing the same with Firefox 0.8 the cookie can be read, but also can be read when the browser has been closed and a new one opened. It can also be read after logging out, closing the browser and reopening a new browser. Perhaps they are duplicating the old IE bug where having a time, but not a valid path, would make the time element ignored. Change your code to this: setcookie('sesvar', 'this session only', 0, /, www.mypersonaldomain.net); Older IE versions let you have time *AND* path, or neither, but not just time. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question about php.ini
[snip] 1.) rename the php.ini.default to plain php.ini and see if that resolves it. However, I'm not sure what kind of tests can I perform to see that it is working properly? [/snip] How about just making a copy of the file and testing it? Have you run phpinfo() yet? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question about php.ini
[snip] Yup, I have tried making a copy of it. I'm just not exactly sure how to test it? I ran phpinfo() , and it runs even without a php.ini. [/snip] Change something in the configuation file that you know you can run a test on, like safe mode status, then restart Apache and conduct the test. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about php.ini
Stephen Wong wrote: I'm very new to php. Here are some basic info about my server that I am running: Mac OS X 10.3.7 PHP 4.3.10 MySQL 4.0.18 Apache 1.3.33 What I want to do is host a forum on my web page. I can't seem to get it set up, and I notice that I do not have a php.ini file in my /etc directory (This is the Configuration File Path). However, I do have a php.ini.default in the same directory. You don't HAVE to have a php.ini for PHP to run. PHP will simply use its default values if you have no php.ini file for it to load. And your forum software should not require it, in my opinion, but I suppose it's theoretically possible that it does. More likely, it requires specific settings to work, which is also bad. I don't *WANT* to change my php.ini on my whole site for their software to work. Often you can get around this by using an .htaccess file (just create one) in the forum directory to set whatever they need. I seem to have two options: 1.) rename the php.ini.default to plain php.ini and see if that resolves it. However, I'm not sure what kind of tests can I perform to see that it is working properly? http://php.net/phpinfo will tell you which php.ini file is loaded (or if none is loaded) and will tell you everything that is being affected by that file. If you copy php.ini.default to php.ini, it should be EXACTLY the same as it is now -- the .default settings match what PHP does if no file is there. But, of course, after you copy the file there, you can change it, and then it will make a difference. 2.) or I can follow this tutorial at: http://www.dmcinsights.com/phpmysql/phpini.php; which teaches me how to make my own php.ini file. It's probably better to stick with the php.ini file that came with your VERSION of PHP. That might be the php.ini.default you see, or maybe that .default is some old left-over thing from a previous version... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question about php.ini
The phpinfo() will display either the directory in which it expects to find the php.ini file (if the php.ini does not exist) or it will display the full path, including the filename (if the php.ini DOES exist where expected). -Original Message- From: Jay Blanchard [mailto:[EMAIL PROTECTED] Sent: Monday, February 07, 2005 12:53 PM To: Stephen Wong Cc: php-general@lists.php.net Subject: RE: [PHP] Question about php.ini [snip] Yup, I have tried making a copy of it. I'm just not exactly sure how to test it? I ran phpinfo() , and it runs even without a php.ini. [/snip] Change something in the configuation file that you know you can run a test on, like safe mode status, then restart Apache and conduct the test. -- 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] Question about Safe Mode
[snip] So... how do I work around this? Can I get php to write the files so they aren't owned by apache but rather thwn owner of the php script that creates them? [/snip] PHP scripts run by the HTTP server are run as the web server. The web server runs as 'Apache', so Apache needs permissions to do the writing or Safe Mode must be disabled. Read http://us2.php.net/features.safe-mode for more information -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about Safe Mode
Rick Root wrote: I have a little home made CMS that writes files... on the server I've recently installed this CMS on, those files get written as apache:apache ... that file uses include to include other files that are not owned by apache, and this doesn't work. Warning: main(): SAFE MODE Restriction in effect. The script whose uid is 48 is not allowed to access ./inc_pagecontent.php owned by uid 538 in /home/virtual/site36/fst/var/www/html/test.php on line 3 So... how do I work around this? Can I get php to write the files so they aren't owned by apache but rather thwn owner of the php script that creates them? You can use ftp php functions to upload the files from within your script to the desired location. They will be owned by whatever user you used to log in. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question on getting URL
$file = basename(_FILE_); On Sun, 2005-01-30 at 01:26, David Banning wrote: I have a script called index.php on my main page and it actually is used to launch several webpages like so; http://mysite.com/index.php?id=16 When http://mysite.com runs it still uses index.php. but it doesn't show it in the address bar. All it shows is; http://mysite.com What I would like to do is to get the information from the address bar to know when I am on the main page. -- -- Regards, Matthew Fonda -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] question about a cron job
[snip] I've got a question about the following cronjob. #At 3:01 our time, run backups 1 0 * * * /usr/local/bin/php /www/r/rester/htdocs/auto_backup/back_em_up.php /www/r/rester/htdocs/auto_backup/cron.log 21 #At 3:02 clean up sessions folder 2 0 * * * (find /www/r/rester/htdocs/sessions/ -name 'sess_*' -mtime +1 -delete) #this is only for testing a new cronjob, every minute * * * * * /usr/local/bin/php /www/r/rester/htdocs/phpList_cronjob/process_cronjob.php /www/r/rester/htdocs/phpList_cronjob/cron.log 21 The new one doesn't seem to want to run until after 3:01 or 3:02. Shouldn't the sever just run it every minute? [/snip] You have to specify each minute... http://www.unixgeeks.org/security/newbie/unix/cron-1.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question about a cron job
Jay Blanchard wrote: [snip] I've got a question about the following cronjob. #At 3:01 our time, run backups 1 0 * * * /usr/local/bin/php /www/r/rester/htdocs/auto_backup/back_em_up.php /www/r/rester/htdocs/auto_backup/cron.log 21 #At 3:02 clean up sessions folder 2 0 * * * (find /www/r/rester/htdocs/sessions/ -name 'sess_*' -mtime +1 -delete) #this is only for testing a new cronjob, every minute * * * * * /usr/local/bin/php /www/r/rester/htdocs/phpList_cronjob/process_cronjob.php /www/r/rester/htdocs/phpList_cronjob/cron.log 21 The new one doesn't seem to want to run until after 3:01 or 3:02. Shouldn't the sever just run it every minute? [/snip] You have to specify each minute... http://www.unixgeeks.org/security/newbie/unix/cron-1.html I thought the * in the minutes position meant to run the script for all minutes, 0 59. Am I wrong? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question about a cron job
Al wrote: I've got a question about the following cronjob. #At 3:01 our time, run backups 1 0 * * * /usr/local/bin/php /www/r/rester/htdocs/auto_backup/back_em_up.php /www/r/rester/htdocs/auto_backup/cron.log 21 #At 3:02 clean up sessions folder 2 0 * * * (find /www/r/rester/htdocs/sessions/ -name 'sess_*' -mtime +1 -delete) #this is only for testing a new cronjob, every minute * * * * * /usr/local/bin/php /www/r/rester/htdocs/phpList_cronjob/process_cronjob.php /www/r/rester/htdocs/phpList_cronjob/cron.log 21 The new one doesn't seem to want to run until after 3:01 or 3:02. Shouldn't the sever just run it every minute? And, the every minute job doesn't add anything to its log file. Apache on a virtual host. The 3:01 and 3:02 jobs have been running fine for months. Thanks The CRON daemon only refreshes it's job list after a job in the current list is completed. Therefore, the CRON daemon won't notice the every-minute job until 3.01 pm. Erwin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] question about a cron job
#this is only for testing a new cronjob, every minute * * * * * /usr/local/bin/php /www/r/rester/htdocs/phpList_cronjob/process_cronjob.php /www/r/rester/htdocs/phpList_cronjob/cron.log 21 The new one doesn't seem to want to run until after 3:01 or 3:02. Shouldn't the sever just run it every minute? Yes, it should. Cron normally emails any output (including messages to stderr) to the owner of the cron job. In this case you have 21 at the end of your command which should be 21. On my machine executing a command with 21 results in: -bash: syntax error near unexpected token `' which might explain why your job isn't running. If I setup a test job that looks similar to yours, the above error output is emailed to me. Jay Blanchard wrote: You have to specify each minute... * * * * * is sufficient for that. I've got a couple of jobs on a box here that run every minute and that's the way they are entered in my crontab... HTH -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question about a cron job
Erwin Kerk wrote: Al wrote: I've got a question about the following cronjob. #At 3:01 our time, run backups 1 0 * * * /usr/local/bin/php /www/r/rester/htdocs/auto_backup/back_em_up.php /www/r/rester/htdocs/auto_backup/cron.log 21 #At 3:02 clean up sessions folder 2 0 * * * (find /www/r/rester/htdocs/sessions/ -name 'sess_*' -mtime +1 -delete) #this is only for testing a new cronjob, every minute * * * * * /usr/local/bin/php /www/r/rester/htdocs/phpList_cronjob/process_cronjob.php /www/r/rester/htdocs/phpList_cronjob/cron.log 21 The new one doesn't seem to want to run until after 3:01 or 3:02. Shouldn't the sever just run it every minute? And, the every minute job doesn't add anything to its log file. Apache on a virtual host. The 3:01 and 3:02 jobs have been running fine for months. Thanks The CRON daemon only refreshes it's job list after a job in the current list is completed. Therefore, the CRON daemon won't notice the every-minute job until 3.01 pm. Erwin Wow, that is a key point and makes sense. Boy, I read several refs about cronjobs and not one of them mentioned this. So, if I put my 1 minute job first in the list, all should be well? Thanks.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question about a cron job
On Mon, 2005-01-17 at 09:01, Erwin Kerk wrote: Al wrote: I've got a question about the following cronjob. #At 3:01 our time, run backups 1 0 * * * /usr/local/bin/php /www/r/rester/htdocs/auto_backup/back_em_up.php /www/r/rester/htdocs/auto_backup/cron.log 21 #At 3:02 clean up sessions folder 2 0 * * * (find /www/r/rester/htdocs/sessions/ -name 'sess_*' -mtime +1 -delete) #this is only for testing a new cronjob, every minute * * * * * /usr/local/bin/php /www/r/rester/htdocs/phpList_cronjob/process_cronjob.php /www/r/rester/htdocs/phpList_cronjob/cron.log 21 The new one doesn't seem to want to run until after 3:01 or 3:02. Shouldn't the sever just run it every minute? And, the every minute job doesn't add anything to its log file. Apache on a virtual host. The 3:01 and 3:02 jobs have been running fine for months. Thanks The CRON daemon only refreshes it's job list after a job in the current list is completed. Therefore, the CRON daemon won't notice the every-minute job until 3.01 pm. I am not sure I read that correctly. Are you saying that the job cannot be running for the new crontab to be installed? If so, I could see that althought I have never experienced it. If you are saying that each job in the crontab must be run before the new crontab is completed, then I believe you are in error. I have often changed crontab entries to test how a job will operate in the cron environment and never experienced any delay on the acceptance of the new job even though I have hourly and daily jobs there. Bret -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] question about a cron job
Erwin Kerk wrote: The CRON daemon only refreshes it's job list after a job in the current list is completed. Therefore, the CRON daemon won't notice the every-minute job until 3.01 pm. I'm not sure I understand what you're saying above. Can you provide a pointer to documentation about this? The man page for Vixie cron states in part: Additionally, cron checks each minute to see if its spool directory's modtime (or the modtime on /etc/crontab) has changed, and if it has, cron will then examine the modtime on all crontabs and reload those which have changed. Thus cron need not be restarted whenever a crontab file is modified. Vixie cron, at least, refreshes it's job list anytime a crontab is changed, and keeps that job list until the next change is made. Jobs should run according to their way they are scheduled, and shouldn't be affected by the order they are listed in the crontab or when other jobs are completed. Perhaps I'm not understanding what you're saying (if so, my apologies) or perhaps you are using a different flavor of cron that behaves differently. I really only have experience with Vixie cron, but I thought they all pretty much behaved the same way... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question about a cron job
On Monday 17 January 2005 23:19, Al wrote: Erwin Kerk wrote: Al wrote: The CRON daemon only refreshes it's job list after a job in the current list is completed. Therefore, the CRON daemon won't notice the every-minute job until 3.01 pm. Not sure if I've misunderstood what Al is saying but, the cron daemon checks all crontabs for updates *every* minute. So at the most, 2 minutes after you've updated your crontab the changes will take effect. Wow, that is a key point and makes sense. Boy, I read several refs about cronjobs and not one of them mentioned this. So, if I put my 1 minute job first in the list, all should be well? -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- New Year Resolution: Ignore top posted posts -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question about a cron job
Michael Sims wrote: Erwin Kerk wrote: The CRON daemon only refreshes it's job list after a job in the current list is completed. Therefore, the CRON daemon won't notice the every-minute job until 3.01 pm. I'm not sure I understand what you're saying above. Can you provide a pointer to documentation about this? The man page for Vixie cron states in part: Additionally, cron checks each minute to see if its spool directory's modtime (or the modtime on /etc/crontab) has changed, and if it has, cron will then examine the modtime on all crontabs and reload those which have changed. Thus cron need not be restarted whenever a crontab file is modified. say you change the crontab (do a save) in minute 2:49pm, then the file will be checked and reloaded, by the time that thats complete it will be passed 3:00:00pm (or more precisely after the jobtrigger was run), maybe what was meant was; that the 'everyminute' job would therefore trigger for the first time when cron checks jobs on 3:01:00pm? Vixie cron, at least, refreshes it's job list anytime a crontab is changed, and keeps that job list until the next change is made. Jobs should run according to their way they are scheduled, and shouldn't be affected by the order they are listed in the crontab or when other jobs are completed. Perhaps I'm not understanding what you're saying (if so, my apologies) or perhaps you are using a different flavor of cron that behaves differently. I really only have experience with Vixie cron, but I thought they all pretty much behaved the same way... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] question about a cron job
Jochem Maas wrote: Michael Sims wrote: Additionally, cron checks each minute to see if its spool directory's modtime (or the modtime on /etc/crontab) has changed, and if it has, cron will then examine the modtime on all crontabs and reload those which have changed. Thus cron need not be restarted whenever a crontab file is modified. say you change the crontab (do a save) in minute 2:49pm, then the file will be checked and reloaded, by the time that thats complete it will be passed 3:00:00pm (or more precisely after the jobtrigger was run), maybe what was meant was; that the 'everyminute' job would therefore trigger for the first time when cron checks jobs on 3:01:00pm? Oh, I see. At any rate, once it starts running at 3:01 it should then run every minute from that point forward until it's removed from the crontab. I'm not sure that the OP was getting that point. (BTW, I think you meant 2:59pm unless you've got some really slow transfer rates on your hard drives. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question about a cron job
Michael Sims wrote: Erwin Kerk wrote: The CRON daemon only refreshes it's job list after a job in the current list is completed. Therefore, the CRON daemon won't notice the every-minute job until 3.01 pm. I'm not sure I understand what you're saying above. Can you provide a pointer to documentation about this? The man page for Vixie cron states in part: Additionally, cron checks each minute to see if its spool directory's modtime (or the modtime on /etc/crontab) has changed, and if it has, cron will then examine the modtime on all crontabs and reload those which have changed. Thus cron need not be restarted whenever a crontab file is modified. Vixie cron, at least, refreshes it's job list anytime a crontab is changed, and keeps that job list until the next change is made. Jobs should run according to their way they are scheduled, and shouldn't be affected by the order they are listed in the crontab or when other jobs are completed. Perhaps I'm not understanding what you're saying (if so, my apologies) or perhaps you are using a different flavor of cron that behaves differently. I really only have experience with Vixie cron, but I thought they all pretty much behaved the same way... What you said has been my experience in the past. But, it has been a long time since I fiddled with a cron job, so I wasn't certain of my memory. Here is my code; but it doesn't run. I can't tell if there is anything wrong with my crontab or my virtual webhost is faulty. #this is only for testing a new cronjob, every minute. This job replaces its log and error files. * * * * * /usr/local/bin/php /www/r/rester/htdocs/phpList_cronjob/process_cronjob.php /www/r/rester/cronjob_reports/phpList.log 2/www/r/rester/cronjob_reports/phpList.err #At 3:01 our time, run backups. This job replaces its log and error files. 1 0 * * * /usr/local/bin/php /www/r/rester/htdocs/auto_backup/back_em_up.php /www/r/rester/cronjob_reports/auto_backup.log 2/www/r/rester/cronjob_reports/auto_backup.err There is a cronjob_reports folder. I am assuming that the will create the log and err files as needed. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question about a cron job
Michael Sims wrote: Jochem Maas wrote: Michael Sims wrote: Additionally, cron checks each minute to see if its spool directory's modtime (or the modtime on /etc/crontab) has changed, and if it has, cron will then examine the modtime on all crontabs and reload those which have changed. Thus cron need not be restarted whenever a crontab file is modified. say you change the crontab (do a save) in minute 2:49pm, then the file will be checked and reloaded, by the time that thats complete it will be passed 3:00:00pm (or more precisely after the jobtrigger was run), maybe what was meant was; that the 'everyminute' job would therefore trigger for the first time when cron checks jobs on 3:01:00pm? Oh, I see. At any rate, once it starts running at 3:01 it should then run every minute from that point forward until it's removed from the crontab. I'm not sure that the OP was getting that point. (BTW, I think you meant 2:59pm unless you've typo. they did this people skills thing once at a company I worked for, and one of the things they did was to get people to close the eye for exactly 1 minute, I sat there for about 2mins - everyone thought it was very funny. guess I've slowed down (and become more eratic) with age ;-) got some really slow transfer rates on your hard drives. :) or I have a php script designed to hog exactly 99% of all resources for no reason :-) for ten minutes, set in cron to run every hour at 49 mins past. hihi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question: arrays and form elements
[snip] Generally, when I set up a form where, for example, I'll be taking multiple selections from a list I would set the variable / element name as myvar[]. So I have the brackets [] after the variable name to make it an array. What I want to know is there a way to get around the use of this syntax ? If the variable name was just myvar (no brackets) is there a way for me to still grab all the selections and put them into an array ? [/snip] Nope, this is the method for doing what you say. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question: arrays and form elements
Nope. Is there a problem you are having with using that syntax? If you are having trouble with referencing the fields with javascript, you can't use the regular syntax you are used to.: document.formname.fieldname[] That will give you an error because of the brackets. In javascript you'll need to reference field names with brackets like this: document.formname.elements[fieldname[]] On Dec 30, 2004, at 6:48 AM, Stuart Felenstein wrote: Generally, when I set up a form where, for example, I'll be taking multiple selections from a list I would set the variable / element name as myvar[]. So I have the brackets [] after the variable name to make it an array. What I want to know is there a way to get around the use of this syntax ? If the variable name was just myvar (no brackets) is there a way for me to still grab all the selections and put them into an array ? Hope this question is clear. Thank you Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Brent Baisley Systems Architect Landover Associates, Inc. Search Advisory Services for Advanced Technology Environments p: 212.759.6400/800.759.0577 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about dates
On Fri, 24 Dec 2004 08:46:28 -0600, Brent Clements [EMAIL PROTECTED] wrote: How does one over come the issue of unix time not going beyond a certain date? Overcome the issue in what way? A 32bit integer is what it is. ie, when I do echo strtotime(2099-10-08); it outputs -1 So don't use strtotime(). You're never going to fit an integer with more than 32bits into a memory space of 32bits or less without losing bits. The PHP manual seems pretty clear in what to do as far as checking for failure: $str = 'Not Good'; if (($timestamp = strtotime($str)) === -1) { echo The string ($str) is bogus; } else { echo $str == . date('l dS of F Y h:i:s A', $timestamp); } This has to do with the limitations of unix time, so how does one get around it? If it's stored in a db, you can use the date/time fields which usually provide more storage space than 32bits. MySQL has timestamp for example. -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question
I assume by edit you mean change the value to something completely new. If you are having the user input the new value you 1) must make sure it is valid input and 2)move it into the array value (maybe set the array as a session variable so it crosses over to the next page instead of being re initialized). Maybe something like: if(isset($_POST['submit']){ // make sure the input is valid first $_SESSION['config']['email'] = $_POST['email']; $_SESSION['config']['meta_author'] = $_POST['author']; } if (!isset($_SESSION['config'])){ $_SESSION['config']= array( 'email' = 'E-mail', 'meta_author' = 'Author') } input type = hidden name=email type=text value=?php print $config[email];? input type = hidden name=author type=text value=?php print $config[meta_author]; ? Respectfully, Ligaya Turmelle --- Life is a game... so have fun. --- www.PHPCommunity.org Open Source, Open Community Visit for more information or to join the movement Tom Luigjes wrote: Hi, I'm trying to make a little script to edit arrays. For example, i have an array file named config.php, and it holds this: ?php $config = array( 'email' = 'E-mail', 'meta_author' = 'Author', ? I wish to edit this file, through another file, named edit.php, or admin.php, i would like to use forms for it. At the moment i've found out how to show the arrays within a text field, but now i wish to edit them through the same text field. With buttons etc. Here's how i call the arrays from the file: input name=hiddenfield type=text value=?php print $config[email]; ? input name=hiddenfield type=text value=?php print $config[meta_author]; ? Is there anything that can let me edit it? I think i will have to edit it through a form, it might be simple, though it might not be, please help me out! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question in posting form-data
Yao, Minghua wrote: Yes. I did modify the original since I need to send data to a program which takes only form-data. content-disposition: came from RFC 2388. I don't think the program can take application/x-www-form-urlencoded content. Further help needed. Try it the old way -- I suspect you broke things by changing it around... You definitely need the $name= and the urlencode of the value, however. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question in posting form-data
Thank you for your reply. I tried the original code. It worked well. But the site I am trying to send the data to only takes form-data. That is why I modified the code. I tried $name= and urlencode. It didn't help. -Minghua -Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED] Sent: Fri 12/17/2004 11:27 AM To: Yao, Minghua Cc: Erwin Kerk; [EMAIL PROTECTED] Subject: RE: [PHP] Question in posting form-data Yao, Minghua wrote: Yes. I did modify the original since I need to send data to a program which takes only form-data. content-disposition: came from RFC 2388. I don't think the program can take application/x-www-form-urlencoded content. Further help needed. Try it the old way -- I suspect you broke things by changing it around... You definitely need the $name= and the urlencode of the value, however. -- Like Music? http://l-i-e.com/artists.htm
Re: [PHP] Question in posting form-data
Yao, Minghua wrote: Hi, all, I am testing how to post form-data to a host using the following code (test.php): ?php function PostToHost($host, $path, $name, $value) { // Test of posting form-data $fp = fsockopen($host,80); fputs($fp, POST $path HTTP/1.1\n); fputs($fp, Host: $host\n); fputs($fp, Content-Type: multipart/form-data\n); fputs($fp, content-disposition: form-data; name=$name\n); fputs($fp, Connection: close\n\n); fputs($fp, $value\n); $res = ; while(!feof($fp)) { $res .= fgets($fp, 128); } fclose($fp); return $res; } Check your function carefully. Where are you using the $name of the value? Nowhere! Therefore the receiving script cannot identify the value as x. Try: fputs($fp, $name=$value\n); Erwin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question in posting form-data
You also need to URLEncode the $value, either before you pass it in, or inside the function itself. Where did you get this PostToHost function?... Did you modify it? Cuz, like, I don't think this one is very good... Where did that content-disposition: come from? And virtually every FORM on the web has more than one input, so you're going to need to handle that. Google for PostToHost Rasmus Lerdorf to find the original and compare it with yours. Yao, Minghua wrote: Thanks. I changed fputs($fp, $value\n); to fputs($fp, $name=$value\n); But I still got the same message. -Minghua -Original Message- From: Erwin Kerk [mailto:[EMAIL PROTECTED] Sent: Thu 12/16/2004 6:30 AM To: Yao, Minghua Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Question in posting form-data Yao, Minghua wrote: Hi, all, I am testing how to post form-data to a host using the following code (test.php): ?php function PostToHost($host, $path, $name, $value) { // Test of posting form-data $fp = fsockopen($host,80); fputs($fp, POST $path HTTP/1.1\n); fputs($fp, Host: $host\n); fputs($fp, Content-Type: multipart/form-data\n); fputs($fp, content-disposition: form-data; name=$name\n); fputs($fp, Connection: close\n\n); fputs($fp, $value\n); $res = ; while(!feof($fp)) { $res .= fgets($fp, 128); } fclose($fp); return $res; } Check your function carefully. Where are you using the $name of the value? Nowhere! Therefore the receiving script cannot identify the value as x. Try: fputs($fp, $name=$value\n); Erwin -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question
Dennis Yang wrote: I'm using PHP 4.3.2 and using ODBC to connect to my Access database. I want to get the value from this query statement: select count(id) as quantity from danhmucdia. How can I get this value? How can I equalize this value into variable ? It's a query, just like any other query. So you're going to send it to ODBC the same as you send any other query. I don't know the ODBC syntax, but it's going to be something like: $query = select count(id) as quantity from danhmucdia; $id_count_set = odbc_query($query) or trigger_error(odbc_error() . $query, E_USER_ERROR); $id_count = odbc_result($id_count_set, 0, 0); You could also use odbc_fetch_row or odbc_fetch_array. The preceding lines all assume ODBC works the same as MySQL, which may or may not be true to varying degrees of truth. http://php.net/odbc -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question in posting form-data
Yes. I did modify the original since I need to send data to a program which takes only form-data. content-disposition: came from RFC 2388. I don't think the program can take application/x-www-form-urlencoded content. Further help needed. Thanks. -Minghua -Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED] Sent: Thu 12/16/2004 11:46 AM To: Yao, Minghua Cc: Erwin Kerk; [EMAIL PROTECTED] Subject: RE: [PHP] Question in posting form-data You also need to URLEncode the $value, either before you pass it in, or inside the function itself. Where did you get this PostToHost function?... Did you modify it? Cuz, like, I don't think this one is very good... Where did that content-disposition: come from? And virtually every FORM on the web has more than one input, so you're going to need to handle that. Google for PostToHost Rasmus Lerdorf to find the original and compare it with yours. Yao, Minghua wrote: Thanks. I changed fputs($fp, $value\n); to fputs($fp, $name=$value\n); But I still got the same message. -Minghua -Original Message- From: Erwin Kerk [mailto:[EMAIL PROTECTED] Sent: Thu 12/16/2004 6:30 AM To: Yao, Minghua Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Question in posting form-data Yao, Minghua wrote: Hi, all, I am testing how to post form-data to a host using the following code (test.php): ?php function PostToHost($host, $path, $name, $value) { // Test of posting form-data $fp = fsockopen($host,80); fputs($fp, POST $path HTTP/1.1\n); fputs($fp, Host: $host\n); fputs($fp, Content-Type: multipart/form-data\n); fputs($fp, content-disposition: form-data; name=$name\n); fputs($fp, Connection: close\n\n); fputs($fp, $value\n); $res = ; while(!feof($fp)) { $res .= fgets($fp, 128); } fclose($fp); return $res; } Check your function carefully. Where are you using the $name of the value? Nowhere! Therefore the receiving script cannot identify the value as x. Try: fputs($fp, $name=$value\n); Erwin -- Like Music? http://l-i-e.com/artists.htm
RE: [PHP] Question in posting form-data
Thanks. I changed fputs($fp, $value\n); to fputs($fp, $name=$value\n); But I still got the same message. -Minghua -Original Message- From: Erwin Kerk [mailto:[EMAIL PROTECTED] Sent: Thu 12/16/2004 6:30 AM To: Yao, Minghua Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Question in posting form-data Yao, Minghua wrote: Hi, all, I am testing how to post form-data to a host using the following code (test.php): ?php function PostToHost($host, $path, $name, $value) { // Test of posting form-data $fp = fsockopen($host,80); fputs($fp, POST $path HTTP/1.1\n); fputs($fp, Host: $host\n); fputs($fp, Content-Type: multipart/form-data\n); fputs($fp, content-disposition: form-data; name=$name\n); fputs($fp, Connection: close\n\n); fputs($fp, $value\n); $res = ; while(!feof($fp)) { $res .= fgets($fp, 128); } fclose($fp); return $res; } Check your function carefully. Where are you using the $name of the value? Nowhere! Therefore the receiving script cannot identify the value as x. Try: fputs($fp, $name=$value\n); Erwin
Re: [PHP] Question: Repopulating form parameters
On Monday 13 December 2004 18:29, Stuart Felenstein wrote: I think you are missing the point Jason was trying to make, which is the difference between '$Ind' and $Ind. If you look again, you will see that those are handled differently. If you read the post Jason suggested I print out using both single and double quotes. Yes, I really do suggest that you re-read what was said in this thread. Regardless that has very little to do with my question. I believe that in the code you posted previously you was using '$Ind' in strcmp(), in which case it is extremely relevant, that is why I brought it up. Here is just another variation of my multiple select list. option value=?php echo $rsinds-Fields('CareerIDs')??php if ($rsinds-Fields('CareerIDs')== 5) {echo SELECTED;} ??php echo $rsinds-Fields('CareerCategories')?/option Here I was just testing with a specific value. the line == 5 will set the value SELECTED correctly. If I put in 5, 6, or '5,','6', etc, I get an error. However, I don't believe that line works for multiple values. What works is still a mystery to me. For heaven's sake, do you even know what the HTML *should* look like? Did you construct an example to look at? If you're unable to construct your own example just look at someone else's, go find a site that has multi-select listboxes with pre-selected values and examine the HTML source. Once you know what the HTML should look like it would be straightforward to recreate it using PHP. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* If you can count your money, you don't have a billion dollars. -- J. Paul Getty */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question: Repopulating form parameters
On Monday 13 December 2004 19:00, Stuart Felenstein wrote: heaven's sake ? bit over dramatic. The code above is my created html. I've created a number of them, both from a table and just listing out some options. To repeat they all work . Yet all seem to have little in common when the values are dynamic and from an array. What works is still a mystery to me There are countless examples on the web of what works, the HTML specs will tell you what works, an example created from a competent HTML editor is what works. Now if you can recreate something what works, you will have something that works. Where's the mystery in that? I think will call it a day for this thread. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Toes, knees, NIPPLES. Toes, knees, nipples, KNUCKLES ... Nipples, dimples, knuckles, NICKLES, wrinkles, pimples!! */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question: Repopulating form parameters
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm On 12 December 2004 14:27, Stuart Felenstein wrote: --- Jason Wong [EMAIL PROTECTED] wrote: If in doubt, print it out (TM) echo '$Indbr', $Indbr, $Ind; $Ind '1','2','3','4' '1','2','3','4' Funny, they are both the same. Both? There are three things printed out there, so both cannot be right. 2 of the 3 can be the same, or all of them can be the same, but not both. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php