Re: [PHP] passing control to a separate script
At 9:17 PM -0400 5/1/11, Jim Giner wrote: I have a large script that does a certain function for me. I have a second script that gets called and does its thing and when I'm done with it I'd like to pass control to the first script. I don't need this 'included' in my second script - I just want to pass control to it and let it take over again. Is this do-able? Yes, this is do-able. But don't be afraid of the include statement. Here's an example that can be easily made to do what you want: http://www.webbytedd.com/bb/php-run-php/ After the first script runs, it includes the second script that then runs, which then includes the first script to continue. If you don't want to use a $_POST to trigger the critter, then use location, such as: // first script if($to_second_script) { header('Location: http://www.example.com/second.php'); exit(); } // second script if($to_first_script) { header('Location: http://www.example.com/first.php'); exit(); } Either those will work depending upon the trigger you need. Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] passing control to a separate script
On Monday, 2 May 2011 at 02:44, Jim Giner wrote: No - I don't want to include either one in the other one. They are separate > things that interesect once. I really am just trying to do this separately > as I said. > > script1 > work > work > work > (done) > > script2 > do something > user response > do something (write data) > execute script 1 > (done. > > Script 2 doesn't need a response - no return to it. I'm trying to keep from > having the user interact with it one more time just to have a form & button > that uses its' action= to run script 1. In script2 you have the user responding in the middle of execution - this is not possible. PHP runs a script and returns the output to the client. The user then takes action which may cause another PHP script to be executed. There is no way to pause execution of a web-based PHP script and wait for a user action. In what you've given us above I'm unclear on how script1 and script2 interact with each other. Can you elaborate? -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] passing control to a separate script
No - I don't want to include either one in the other one. They are separate things that interesect once. I really am just trying to do this separately as I said. script1 work work work (done) script2 do something user response do something (write data) execute script 1 (done. Script 2 doesn't need a response - no return to it. I'm trying to keep from having the user interact with it one more time just to have a form & button that uses its' action= to run script 1. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] postgresql database access failure
e-letter wrote: > The file was changed: > > ... $value=pg_fetch_result($query,1,1); > echo 'all files' . var_dump($value); > ... > > The resultant web page produces: > > bool(false) all files > > The php file was changed again: > > ... $value=pg_fetch_result($query); > echo 'all files' . var_dump($value); > ... > > The resultant web page produces: > > NULL all files > > The error log shows: > > ...PHP Warning: pg_fetch_result(): supplied argument is not a valid > PostgreSQL result resource... > > The objective is to learn how to extract data from a database and > print to a web browser, but not much progress made so far..! There is a good example of how to use pg_fetch_result in the docs at http://php.net/manual/en/function.pg-fetch-result.php. On the basis of the code shown here, it's a bit hard to determine exactly what your problem is; however the odds are that the error "supplied argument is not a valid PostgreSQL result resource" results from a SQL syntax error, or possibly that you have failed to open a connection to pgsql. However, there are some tools to help you; see http://php.net/manual/en/function.pg-result-error.php For future reference, it helps to post all the code that is relevant to your problem, so in this case it would help, for example, to see how you are making the connection to pgsql and how the $query variable is populated. Cheers -- David Robley A seminar on Time Travel will be held two weeks ago. Today is Boomtime, the 49th day of Discord in the YOLD 3177. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] passing control to a separate script
On Monday, 2 May 2011 at 02:17, Jim Giner wrote: I have a large script that does a certain function for me. I have a second > script that gets called and does its thing and when I'm done with it I'd > like to pass control to the first script. I don't need this 'included' in > my second script - I just want to pass control to it and let it take over > again. > > Is this do-able? To clarify, you have something like this... one.php --- echo 'do one thing'; // pass control to two.php echo 'do another thing'; --- two.php --- echo 'do something else'; // pass control back to one.php --- If that's correct then simply include two.php from one.php, like so... one.php --- echo 'do one thing'; include 'two.php'; echo 'do another thing'; --- If not then I've misunderstood what you're after. Can you give us an example? -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] passing control to a separate script
I have a large script that does a certain function for me. I have a second script that gets called and does its thing and when I'm done with it I'd like to pass control to the first script. I don't need this 'included' in my second script - I just want to pass control to it and let it take over again. Is this do-able? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] postgresql database access failure
The file was changed: ... $value=pg_fetch_result($query,1,1); echo 'all files' . var_dump($value); ... The resultant web page produces: bool(false) all files The php file was changed again: ... $value=pg_fetch_result($query); echo 'all files' . var_dump($value); ... The resultant web page produces: NULL all files The error log shows: ...PHP Warning: pg_fetch_result(): supplied argument is not a valid PostgreSQL result resource... The objective is to learn how to extract data from a database and print to a web browser, but not much progress made so far..! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] postgresql database access failure
On Sun, 2011-05-01 at 09:24 +0100, e-letter wrote: > I looked at the error file located at '/var/log/httpd/error_log', > which identifies an error: > > ...Apache/2.2.6 (Mandriva Linux/PREFORK-8.2mdv2008.0) PHP/5.2.4 with > Suhosin-Patch mod_put/2.0.8 configured -- resuming normal > operations... > > ...PHP Parse error: syntax error, unexpected T_VARIABLE, expecting > ',' or ';'... > > The file was changed as follows which caused the parse error shown > above: > > $db = pg_connect('dbname=webcuttings user=httpd'); > $query = 'SELECT * FROM articles'; > $value=pg_fetch_result($query); > echo 'all files' $value; > ?> > > The file was copied from the manual page, without understanding that > an array was being used. The problem you've got there is a missing string concatenator in your echo line. You should change that line to read: echo 'all files' . $value; note the . character? However, as you said, $value is actually an array, so you would be better of using something like print_r() or var_dump() on it. -- Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] postgresql database access failure
On 30/04/2011, Daniel Brown wrote: > Readers? Sounds like you spend too much time writing newsletters > (to the wrong address, since php-general-digest-h...@lists.php.net is > a self-help command list for digest-form subscriptions). ;-P > > On Sat, Apr 30, 2011 at 04:41, e-letter wrote: >>>$db = pg_connect('dbname=databasename user=username'); >>$query = 'SELECT * FROM databasename'; >>$value=pg_fetch_result($query,1,0); >>echo 'export of database is ',$value,''; >>?> >> >>why does this fail? > > How is it failing? What error(s) are you seeing on screen or in > your log files? Noting that $value would contain an array, is that > the problem? And why are you using ending quotes in your echo? You > should just place the semicolon immediately after $value. > I looked at the error file located at '/var/log/httpd/error_log', which identifies an error: ...Apache/2.2.6 (Mandriva Linux/PREFORK-8.2mdv2008.0) PHP/5.2.4 with Suhosin-Patch mod_put/2.0.8 configured -- resuming normal operations... ...PHP Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';'... The file was changed as follows which caused the parse error shown above: The file was copied from the manual page, without understanding that an array was being used. >> >> >> >> >> The following php code produces the user agent: >> >>>echo '$_SERVER['HTTP_USER_AGENT']'; >>?> > > First of all, no it doesn't. Placed inside single quotes, it'll > not only try to return it verbatim (i.e. - the variable would be > printed to screen), but it'll also cause a parse error, as you reuse > single quotes in the variable key container. > My mistake; with the command: the result is: Opera/9.80 (X11; Linux i686; U; en-GB) Presto/2.6.30 Version/10.61 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: dynamic copyright in page footer?
On 04/30/2011 07:06 PM, David Mehler wrote: Hello, I am trying to use php to put a copyright notice in a page footer. I'm using the date function with the "Y" value for the year. Here's the code: This works great for a site done in 2011 but next year I'm going to want to have 2011 and 2012 in the copyright notice, adding an additional year the site's up. I'd appreciate some suggestions i'm very likely overthinking this. Thanks. Dave. From the view of copyright itself, the year in the notice means 'last modified date', NOT the current year. So I think you may set a timestamp field in your database, with last update time in it, and use the year (not current year), for your notice. -- http://walkinraven.name -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php