php-general Digest 31 Jul 2005 13:38:46 -0000 Issue 3598
php-general Digest 31 Jul 2005 13:38:46 - Issue 3598 Topics (messages 219703 through 219706): Re: Running a PHP script everyday 219703 by: Miles Thompson 219704 by: Miles Thompson Re: help with print value 219705 by: Miles Thompson Help with a Parse Error 219706 by: Tom Chubb Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: php-general@lists.php.net -- ---BeginMessage--- That's not lame, it's just Windows version of cron. You can also set it up using at from the console, but it still shows up in Task Manager. M. At 04:03 PM 7/30/2005, M Saleh EG wrote: If you're on windows desktop try this... it might sound a lil lame but it works. Schedule a task to open IE or FF and pass a url to the task . That's it. The task will execute that page in a given interval. On 7/30/05, Rory Browne [EMAIL PROTECTED] wrote: If your script needs to be run by the webserver - if for some reason cli won´t work for you, then you could always automate a call to the webserver using wget. You can get wget for win32 as well as Unix/Linux, so you shouldn´t have any problems here. On 7/30/05, André Medeiros [EMAIL PROTECTED] wrote: You can cron the script to run. Do the following: 1) Add #!/usr/bin/php as the first line on your .php file. If /usr/bin/php isn't where your php binary lives, type whereis php to find out 2) Make sure you chmod +x your php script. 3) http://www.linuxforums.org/tutorials/1/tutorial-4017.html On 7/30/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: In my pevious hunt through cron I didn't even notice the PHP CLI. So I will be figuring that out today probably. My server runs on Linux. Not sure which distro though. I'll have to ask. My script will be getting e-mail addresses from my SQL db and sending them a pic of the day. I got the HTML MimeMail 2.5.1 to work perfectly, now I just need to figure out how to make it run without me doing anything. Thanks! Andrew Darrow Kronos1 Productions www.pudlz.com http://www.pudlz.com - Original Message - From: James Kaufman [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Saturday, July 30, 2005 10:07 AM Subject: Re: [PHP] Running a PHP script everyday On Sat, Jul 30, 2005 at 09:17:20AM -0700, [EMAIL PROTECTED] wrote: I have a PHP script that I need to run once a day. I have it currently setup so that I just run it from my cell phone, but I would prefer something automated. I'd looked into a cron job, but that just looks like it's for doing linux command line stuff on my host. I also thought about writing a never ending while loop with an if statement that checks to see if it's time to run the script, then when it is time, it runs. Then checks to see if it's time again. But even assuming I could get it working, do I really want to have a PHP script that runs all the time. This could be bad if it ate up all the CPU on my server. I'm not even sure I have access rights to kill the process once I start it. Any suggestions? Andrew Darrow Kronos1 Productions www.pudlz.com http://www.pudlz.com You don't state what OS you are using, but you certainly can use cron under Linux to run a PHP script. What really matters is what does the PHP script do? For example, I have a PHP script that I run periodically that retrieves data from a database and updates a text file on the disk. What does your script do? -- Jim Kaufman Linux Evangelist public key 0x6D802619 CCNA, CISSP# 65668 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.9.7/60 - Release Date: 7/28/2005 -- 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 -- M.Saleh.E.G 97150-4779817 ---End Message--- ---BeginMessage--- If you're on Windows, use Task Manager and have it start an instance of a web browser, with your URL and script passed to it. or Cron job on server, if you have that level of access. Miles At 01:17 PM 7/30/2005, [EMAIL PROTECTED] wrote: I have a PHP script that I need to run once a day. I have it currently setup so that I just run it from my cell phone, but I would prefer something automated. I'd looked into a cron job, but that just looks like it's for doing linux command line stuff on my host. I also
php-general Digest 1 Aug 2005 03:23:28 -0000 Issue 3599
php-general Digest 1 Aug 2005 03:23:28 - Issue 3599 Topics (messages 219707 through 219729): Re: Help with a Parse Error 219707 by: Edward Vermillion 219708 by: Tom Chubb 219710 by: Jochem Maas 219713 by: Tom Chubb 219717 by: Jochem Maas 219720 by: Jochem Maas xsltprocessor 219709 by: Allan Jardine 219712 by: Jochem Maas 219714 by: Allan Jardine 219715 by: Allan Jardine Re: error checking woes- SOLVED 219711 by: Jack Jackson Amazon Web Services 4 wrapper 219716 by: Paul Waring PDF FDF $_POST 219718 by: Sam Smith Re: input type=file problem (Maybe 0T) 219719 by: David Dorward 219721 by: Jochem Maas Re: Running a PHP script everyday [SOLVED] 219722 by: sub.pudlz.com Re: Running a PHP script everyday 219723 by: Raj Shekhar Re: Question on exec() to call a php script from a php script 219724 by: Raj Shekhar Performace and segfault errors with Php5 + Apache 1.3.x + linux-2.6.x 219725 by: Edwin Barrios Re: preg_match_all question 219726 by: Ethilien what is this: dirname(__FILE__)? 219727 by: Sam Smith 219728 by: Robert Cummings Re: Calendar program like on php.net 219729 by: Roger Thomas Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: php-general@lists.php.net -- ---BeginMessage--- Tom Chubb wrote: I am trying to create my own news system and to start with I'm using static news pages until I get the db working properly. I'm using the following code: ?php if(!isset($_GET['id'])) { $article=$id.php if (file_exists($article)) { include $article; } else { echo The article you've requested does not exist!; } } else { echo You did not select an article; } ? I am testing using the following links... www.myurl.co.uk/index.php www.myurl.co.uk/index.php?id=1 www.myurl.co.uk/index.php?id=2 When I try the first one, I'd expect it to say you did not select an article, but it says Notice: Undefined variable: id in /home/5217/tomchubb/public_html/index.php on line 15 The article you've requested does not exist When I try the third link, I would expect it to say The article you've requested does not exist! but it says: Parse error: parse error in /home/5217/tomchubb/public_html/index.php on line 16 Lines 15 16 are: if (file_exists($article)) { include $article; } else { echo The article you've requested does not exist!; } I don't understand why this isn't working and I've tried looking into this for 2 hours! Can anyone tell me where I'm going wrong please? Thanks, Tom What I notice is that the first error says it's on line 15, then you give lines 15 and 16 in the second example but line 15 doesn't have id in it. Are you sure your looking at the right lines? Try posting the whole script and maybe someone can catch the problem. ---End Message--- ---BeginMessage--- I have changed it a bit, and don't have the old code now!!! I saw a post which identified a problem using isset when $var = ; as it returns true, so I changed my code to use... if ($_GET['id'] != ) { $article=$id.php; if (file_exists($article)) { include $article; } else{ echo The article you've requested does not exist!; } } else { echo No article selected; } This works fine, except that when the url is www.mysite.com/index.php I get the following error... Notice: Undefined index: id in /home/5217/tomchubb/public_html/index.php on line 14 No article selected I kmow this will disappear when I turn off error reporting, but how can I suppress it properly? On 31/07/05, Edward Vermillion [EMAIL PROTECTED] wrote: Tom Chubb wrote: I am trying to create my own news system and to start with I'm using static news pages until I get the db working properly. I'm using the following code: ?php if(!isset($_GET['id'])) { $article=$id.php if (file_exists($article)) { include $article; } else{ echo The article you've requested does not exist!; } } else { echo You did not select an article; } ? I am testing using the following links... www.myurl.co.uk/index.php www.myurl.co.uk/index.php?id=1 www.myurl.co.uk/index.php?id=2 When I try the first one, I'd expect it to say you did not select an article, but it says Notice: Undefined variable: id in /home/5217/tomchubb/public_html/index.php on line 15 The article you've requested does not exist When I try the third link, I would expect it to say The article you've requested does not exist! but it says: Parse error: parse error in /home/5217/tomchubb/public_html/index.php on
[PHP] Help with a Parse Error
I am trying to create my own news system and to start with I'm using static news pages until I get the db working properly. I'm using the following code: ?php if(!isset($_GET['id'])) { $article=$id.php if (file_exists($article)) { include $article; } else{ echo The article you've requested does not exist!; } } else { echo You did not select an article; } ? I am testing using the following links... www.myurl.co.uk/index.php www.myurl.co.uk/index.php?id=1 www.myurl.co.uk/index.php?id=2 When I try the first one, I'd expect it to say you did not select an article, but it says Notice: Undefined variable: id in /home/5217/tomchubb/public_html/index.php on line 15 The article you've requested does not exist When I try the third link, I would expect it to say The article you've requested does not exist! but it says: Parse error: parse error in /home/5217/tomchubb/public_html/index.php on line 16 Lines 15 16 are: if (file_exists($article)) { include $article; } else{ echo The article you've requested does not exist!; } I don't understand why this isn't working and I've tried looking into this for 2 hours! Can anyone tell me where I'm going wrong please? Thanks, Tom -- Tom Chubb [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with a Parse Error
Tom Chubb wrote: I am trying to create my own news system and to start with I'm using static news pages until I get the db working properly. I'm using the following code: ?php if(!isset($_GET['id'])) { $article=$id.php if (file_exists($article)) { include $article; } else { echo The article you've requested does not exist!; } } else { echo You did not select an article; } ? I am testing using the following links... www.myurl.co.uk/index.php www.myurl.co.uk/index.php?id=1 www.myurl.co.uk/index.php?id=2 When I try the first one, I'd expect it to say you did not select an article, but it says Notice: Undefined variable: id in /home/5217/tomchubb/public_html/index.php on line 15 The article you've requested does not exist When I try the third link, I would expect it to say The article you've requested does not exist! but it says: Parse error: parse error in /home/5217/tomchubb/public_html/index.php on line 16 Lines 15 16 are: if (file_exists($article)) { include $article; } else { echo The article you've requested does not exist!; } I don't understand why this isn't working and I've tried looking into this for 2 hours! Can anyone tell me where I'm going wrong please? Thanks, Tom What I notice is that the first error says it's on line 15, then you give lines 15 and 16 in the second example but line 15 doesn't have id in it. Are you sure your looking at the right lines? Try posting the whole script and maybe someone can catch the problem. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with a Parse Error
I have changed it a bit, and don't have the old code now!!! I saw a post which identified a problem using isset when $var = ; as it returns true, so I changed my code to use... if ($_GET['id'] != ) { $article=$id.php; if (file_exists($article)) { include $article; } else{ echo The article you've requested does not exist!; } } else { echo No article selected; } This works fine, except that when the url is www.mysite.com/index.php I get the following error... Notice: Undefined index: id in /home/5217/tomchubb/public_html/index.php on line 14 No article selected I kmow this will disappear when I turn off error reporting, but how can I suppress it properly? On 31/07/05, Edward Vermillion [EMAIL PROTECTED] wrote: Tom Chubb wrote: I am trying to create my own news system and to start with I'm using static news pages until I get the db working properly. I'm using the following code: ?php if(!isset($_GET['id'])) { $article=$id.php if (file_exists($article)) { include $article; } else{ echo The article you've requested does not exist!; } } else { echo You did not select an article; } ? I am testing using the following links... www.myurl.co.uk/index.php www.myurl.co.uk/index.php?id=1 www.myurl.co.uk/index.php?id=2 When I try the first one, I'd expect it to say you did not select an article, but it says Notice: Undefined variable: id in /home/5217/tomchubb/public_html/index.php on line 15 The article you've requested does not exist When I try the third link, I would expect it to say The article you've requested does not exist! but it says: Parse error: parse error in /home/5217/tomchubb/public_html/index.php on line 16 Lines 15 16 are: if (file_exists($article)) { include $article; } else { echo The article you've requested does not exist!; } I don't understand why this isn't working and I've tried looking into this for 2 hours! Can anyone tell me where I'm going wrong please? Thanks, Tom What I notice is that the first error says it's on line 15, then you give lines 15 and 16 in the second example but line 15 doesn't have id in it. Are you sure your looking at the right lines? Try posting the whole script and maybe someone can catch the problem. -- Tom Chubb [EMAIL PROTECTED] 07915 053312 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] xsltprocessor
Hello all, I'm having a real problem with applying an xslt transform to a selected part of an xml document. I load the xml document using simplexml_load_file, and the same with the xsl file. Using the xpath function for simplexml I select a part of the xml document and store it in a different variable. I then apply the xml transform to that variable, however the transform actually applies to the whole xml document, rather than just the selected part in the new variable. I can't figure out why it does this. Does anyone know? The code I'm used is below. $xml = simplexml_load_file ( 'simple_test.xml' ); if ( isset ( $_GET['s'] ) isset ( $_GET['ss'] ) ) foreach ( $xml-xpath( //[EMAIL PROTECTED]'.$_GET['s'].']/ [EMAIL PROTECTED]'.$_GET['ss'].'] ) as $subsection) $content = $subsection; $xsl = simplexml_load_file( 'simple_test.xsl' ); $proc = new XsltProcessor(); $proc-importStylesheet($xsl); echo $proc-transformToXML($content); Thanks for any help Allan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with a Parse Error
Tom Chubb wrote: I have changed it a bit, and don't have the old code now!!! I saw a post which identified a problem using isset when $var = ; as it returns true, so I changed my code to use... the fact that you are using $id suggests you have register_globals on - not recommended practice. and mixing using of auto registered globals ($id) and the equivelant $_GET index ($_GET['id']) is going to lead to confusion somewhere do the line. if ($_GET['id'] != ) { $article=$id.php; if (file_exists($article)) { include $article; } else { echo The article you've requested does not exist!; } } else { echo No article selected; } you hint that the id must always be an integer so sanitize your data as such. to avoid nasty things happening, try like so: if ($cleanID = intval( $_GET['id'] )) { $article = $cleanID.php; if (file_exists($article)) { include $article; } else { echo The article you've requested does not exist!; } } else { echo No article selected; } This works fine, except that when the url is www.mysite.com/index.php I get the following error... Notice: Undefined index: id in /home/5217/tomchubb/public_html/index.php on line 14 No article selected I kmow this will disappear when I turn off error reporting, but how can I suppress it properly? On 31/07/05, Edward Vermillion [EMAIL PROTECTED] wrote: Tom Chubb wrote: I am trying to create my own news system and to start with I'm using static news pages until I get the db working properly. I'm using the following code: ?php if(!isset($_GET['id'])) { $article=$id.php if (file_exists($article)) { include $article; } else{ echo The article you've requested does not exist!; } } else { echo You did not select an article; } ? I am testing using the following links... www.myurl.co.uk/index.php www.myurl.co.uk/index.php?id=1 www.myurl.co.uk/index.php?id=2 When I try the first one, I'd expect it to say you did not select an article, but it says Notice: Undefined variable: id in /home/5217/tomchubb/public_html/index.php on line 15 The article you've requested does not exist When I try the third link, I would expect it to say The article you've requested does not exist! but it says: Parse error: parse error in /home/5217/tomchubb/public_html/index.php on line 16 Lines 15 16 are: if (file_exists($article)) { include $article; } else { echo The article you've requested does not exist!; } I don't understand why this isn't working and I've tried looking into this for 2 hours! Can anyone tell me where I'm going wrong please? Thanks, Tom What I notice is that the first error says it's on line 15, then you give lines 15 and 16 in the second example but line 15 doesn't have id in it. Are you sure your looking at the right lines? Try posting the whole script and maybe someone can catch the problem. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] error checking woes- SOLVED
I did the smart thing last night: nothing. I read some PHP books and then realized that the answer to my error checking was a lot less complex, once again, than I had initially suspected. I finally ended up with: //error checking foreach($_POST as $qname=$value) { if(empty($value)){ $message[$qname]=1; } } I cannot believe what I started with and what I ended up with. Thanks as usual for the help!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] xsltprocessor
Allan Jardine wrote: Hello all, I'm having a real problem with applying an xslt transform to a selected part of an xml document. I load the xml document using simplexml_load_file, and the same with the xsl file. Using the xpath function for simplexml I select a part of the xml document and store it in a different variable. I then apply the xml transform to that variable, however the transform actually applies to the whole xml document, rather than just the selected part in the new variable. I can't figure out why it does this. Does anyone know? The code I'm used is below. $xml = simplexml_load_file ( 'simple_test.xml' ); if ( isset ( $_GET['s'] ) isset ( $_GET['ss'] ) ) foreach ( $xml-xpath( //[EMAIL PROTECTED]'.$_GET['s'].']/ [EMAIL PROTECTED]'.$_GET['ss'].'] ) as $subsection) $content = $subsection; $xsl = simplexml_load_file( 'simple_test.xsl' ); $proc = new XsltProcessor(); $proc-importStylesheet($xsl); echo $proc-transformToXML($content); you might start by using some braces to explicitly delineate the if and foreach block? ...personally I'm not sure exactly what your code should be doing. Thanks for any help Allan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with a Parse Error
Thanks Jochem, useful info. I've changed that now, but why is there still an Undefined index: id error? Any ideas? On 31/07/05, Jochem Maas [EMAIL PROTECTED] wrote: Tom Chubb wrote: I have changed it a bit, and don't have the old code now!!! I saw a post which identified a problem using isset when $var = ; as it returns true, so I changed my code to use... the fact that you are using $id suggests you have register_globals on - not recommended practice. and mixing using of auto registered globals ($id) and the equivelant $_GET index ($_GET['id']) is going to lead to confusion somewhere do the line. if ($_GET['id'] != ) { $article=$id.php; if (file_exists($article)) { include $article; } else{ echo The article you've requested does not exist!; } } else { echo No article selected; } you hint that the id must always be an integer so sanitize your data as such. to avoid nasty things happening, try like so: if ($cleanID = intval( $_GET['id'] )) { $article = $cleanID.php; if (file_exists($article)) { include $article; } else { echo The article you've requested does not exist!; } } else { echo No article selected; } This works fine, except that when the url is www.mysite.com/index.php I get the following error... Notice: Undefined index: id in /home/5217/tomchubb/public_html/index.php on line 14 No article selected I kmow this will disappear when I turn off error reporting, but how can I suppress it properly? On 31/07/05, Edward Vermillion [EMAIL PROTECTED] wrote: Tom Chubb wrote: I am trying to create my own news system and to start with I'm using static news pages until I get the db working properly. I'm using the following code: ?php if(!isset($_GET['id'])) { $article=$id.php if (file_exists($article)) { include $article; } else{ echo The article you've requested does not exist!; } } else { echo You did not select an article; } ? I am testing using the following links... www.myurl.co.uk/index.php www.myurl.co.uk/index.php?id=1 www.myurl.co.uk/index.php?id=2 When I try the first one, I'd expect it to say you did not select an article, but it says Notice: Undefined variable: id in /home/5217/tomchubb/public_html/index.php on line 15 The article you've requested does not exist When I try the third link, I would expect it to say The article you've requested does not exist! but it says: Parse error: parse error in /home/5217/tomchubb/public_html/index.php on line 16 Lines 15 16 are: if (file_exists($article)) { include $article; } else { echo The article you've requested does not exist!; } I don't understand why this isn't working and I've tried looking into this for 2 hours! Can anyone tell me where I'm going wrong please? Thanks, Tom What I notice is that the first error says it's on line 15, then you give lines 15 and 16 in the second example but line 15 doesn't have id in it. Are you sure your looking at the right lines? Try posting the whole script and maybe someone can catch the problem. -- Tom Chubb [EMAIL PROTECTED] 07915 053312 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] xsltprocessor
Hi, you might start by using some braces to explicitly delineate the if and foreach block? ...personally I'm not sure exactly what your code should be doing. Putting the brackets in doesn't make any difference. That part of the code appears to work perfectly - what it does is scan through the xml document looking for a 'section' tag with the attribute id equal to the get variable 's' and with a 'subsection' tag with attribute id equal to the get variable 'ss'. Doing echo $content-asXML(); right after the if and foreach shows that the $content variable does indeed hold the right content. The problem is then applying the xsl transform to what is in that variable. It appears to transform everything in $xml, rather than just what is in $content. $xml = simplexml_load_file ( 'simple_test.xml' ); if ( isset ( $_GET['s'] ) isset ( $_GET['ss'] ) ) { foreach ( $xml-xpath( //[EMAIL PROTECTED]'.$_GET['s'].']/ [EMAIL PROTECTED]'.$_GET['ss'].'] ) as $subsection) { $content = $subsection; } } $xsl = simplexml_load_file( 'simple_test.xsl' ); $proc = new XsltProcessor(); $proc-importStylesheet($xsl); echo $proc-transformToXML($content); Thanks Allan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] xsltprocessor
Hi, The problem is then applying the xsl transform to what is in that variable. It appears to transform everything in $xml, rather than just what is in $content. Managed to solve my own problem... Using: $content = $proc-transformToXML(DomDocument::loadXML($content)); To create an xml dom model that can be operated on by the xslt processor. I still have no idea why it would spit out the whole xml document if its not done like that - but never mind... Thanks Allan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Amazon Web Services 4 wrapper
Does anyone know of an open source wrapper class for the Amazon Web Services API (version 4)? The only ones I can find are either years out of date (such as Amazon_Services in PEAR) and so no longer work, or they require me to parse the XML myself. All I want is something relatively simple that I can give my developer token and a search term (99% of the time this will be the ISBN of a book) and get back a data structure (preferably an associative array) with the product information. Thanks in advance, Paul -- Rogue Tory http://www.roguetory.org.uk pgpKTk92OcyHO.pgp Description: PGP signature
Re: [PHP] Help with a Parse Error
Tom Chubb wrote: Thanks Jochem, useful info. I've changed that now, but why is there still an Undefined index: id error? its a notice technically not an error. and its showing up because you have error reporting set to show notices. to be really purist/correct do it something like this: if (isset($_GET['id']) ($cleanID = intval( $_GET['id'] ))) { $article = $cleanID.php; if (file_exists($article)) { include $article; } else { echo The article you've requested does not exist!; } } else { echo No article selected; } or you can suppress the notice with a @ (know what you are doing when you use the @ symbol), e.g.: if ($cleanID = intval( @$_GET['id'] )) { $article = $cleanID.php; if (file_exists($article)) { include $article; } else { echo The article you've requested does not exist!; } } else { echo No article selected; } Any ideas? On 31/07/05, Jochem Maas [EMAIL PROTECTED] wrote: Tom Chubb wrote: I have changed it a bit, and don't have the old code now!!! I saw a post which identified a problem using isset when $var = ; as it returns true, so I changed my code to use... the fact that you are using $id suggests you have register_globals on - not recommended practice. and mixing using of auto registered globals ($id) and the equivelant $_GET index ($_GET['id']) is going to lead to confusion somewhere do the line. if ($_GET['id'] != ) { $article=$id.php; if (file_exists($article)) { include $article; } else{ echo The article you've requested does not exist!; } } else { echo No article selected; } you hint that the id must always be an integer so sanitize your data as such. to avoid nasty things happening, try like so: if ($cleanID = intval( $_GET['id'] )) { $article = $cleanID.php; if (file_exists($article)) { include $article; } else { echo The article you've requested does not exist!; } } else { echo No article selected; } This works fine, except that when the url is www.mysite.com/index.php I get the following error... Notice: Undefined index: id in /home/5217/tomchubb/public_html/index.php on line 14 No article selected I kmow this will disappear when I turn off error reporting, but how can I suppress it properly? On 31/07/05, Edward Vermillion [EMAIL PROTECTED] wrote: Tom Chubb wrote: I am trying to create my own news system and to start with I'm using static news pages until I get the db working properly. I'm using the following code: ?php if(!isset($_GET['id'])) { $article=$id.php if (file_exists($article)) { include $article; } else{ echo The article you've requested does not exist!; } } else { echo You did not select an article; } ? I am testing using the following links... www.myurl.co.uk/index.php www.myurl.co.uk/index.php?id=1 www.myurl.co.uk/index.php?id=2 When I try the first one, I'd expect it to say you did not select an article, but it says Notice: Undefined variable: id in /home/5217/tomchubb/public_html/index.php on line 15 The article you've requested does not exist When I try the third link, I would expect it to say The article you've requested does not exist! but it says: Parse error: parse error in /home/5217/tomchubb/public_html/index.php on line 16 Lines 15 16 are: if (file_exists($article)) { include $article; } else { echo The article you've requested does not exist!; } I don't understand why this isn't working and I've tried looking into this for 2 hours! Can anyone tell me where I'm going wrong please? Thanks, Tom What I notice is that the first error says it's on line 15, then you give lines 15 and 16 in the second example but line 15 doesn't have id in it. Are you sure your looking at the right lines? Try posting the whole script and maybe someone can catch the problem. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PDF FDF $_POST
I need PHP fill out the form fields and prepare for download a PDF from an HTML form submission. One way would be to use a PDF with pre-configured form fields where an FDF is created from PHP. The FDF 'merges' with the PDF when the FDF is opened. I got all that from: http://koivi.com/fill-pdf-form-fields/. I have the scripts from koivi.com producing the FDF correctly but I don't know what to do with it next. The target PDF would need to be downloaded first because when you open the FDF is says, hey where's the target. fdf_open looked promising but the fdftk is not compiled in on the server. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: input type=file problem (Maybe 0T)
Ryan A wrote: The problem is, if she has tried to upload a pic at the same time and screwed up on the date of birth I am unable to send back the value of the FILE box so that too get populated... I tried setting a VALUE=path/file but that does not work. As has already been pointed out, you can't set the value of the file input. What you can do though is to keep the image uploaded the first time round, and send back a form adding a Keep existing upload (perhaps along with a thumbnail of the image), thus saving the user from uploading the image over and over until they fill in the rest of the form correctly. -- David Dorward http://blog.dorward.me.uk/ http://dorward.me.uk/ Home is where the ~/.bashrc is -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with a Parse Error
Tom Chubb wrote: The purist method is what I wanted. dev'ing with E_ALL is a good thing, but turn off E_NOTICE on productions sites... IMHO in fact make sure your production sites don't output any php errors at all (even if they occur!), sure log them, but don't show - it makes it just a little harder for hackers (as in shitheads who feel the need to try and crack you site - rather than the oldschool meaning) to hack you. I know it sounds a bit silly, but I would like to be able to run all not silly at all. :-) my scripts with error reporting set to e_all without any notices/errors. What you've shown me is perfect, so thanks for your help. T On 31/07/05, Jochem Maas [EMAIL PROTECTED] wrote: Tom Chubb wrote: Thanks Jochem, useful info. I've changed that now, but why is there still an Undefined index: id error? its a notice technically not an error. and its showing up because you have error reporting set to show notices. to be really purist/correct do it something like this: if (isset($_GET['id']) ($cleanID = intval( $_GET['id'] ))) { $article = $cleanID.php; if (file_exists($article)) { include $article; } else { echo The article you've requested does not exist!; } } else { echo No article selected; } or you can suppress the notice with a @ (know what you are doing when you use the @ symbol), e.g.: if ($cleanID = intval( @$_GET['id'] )) { $article = $cleanID.php; if (file_exists($article)) { include $article; } else { echo The article you've requested does not exist!; } } else { echo No article selected; } Any ideas? On 31/07/05, Jochem Maas [EMAIL PROTECTED] wrote: Tom Chubb wrote: I have changed it a bit, and don't have the old code now!!! I saw a post which identified a problem using isset when $var = ; as it returns true, so I changed my code to use... the fact that you are using $id suggests you have register_globals on - not recommended practice. and mixing using of auto registered globals ($id) and the equivelant $_GET index ($_GET['id']) is going to lead to confusion somewhere do the line. if ($_GET['id'] != ) { $article=$id.php; if (file_exists($article)) { include $article; } else{ echo The article you've requested does not exist!; } } else { echo No article selected; } you hint that the id must always be an integer so sanitize your data as such. to avoid nasty things happening, try like so: if ($cleanID = intval( $_GET['id'] )) { $article = $cleanID.php; if (file_exists($article)) { include $article; } else { echo The article you've requested does not exist!; } } else { echo No article selected; } This works fine, except that when the url is www.mysite.com/index.php I get the following error... Notice: Undefined index: id in /home/5217/tomchubb/public_html/index.php on line 14 No article selected I kmow this will disappear when I turn off error reporting, but how can I suppress it properly? On 31/07/05, Edward Vermillion [EMAIL PROTECTED] wrote: Tom Chubb wrote: I am trying to create my own news system and to start with I'm using static news pages until I get the db working properly. I'm using the following code: ?php if(!isset($_GET['id'])) { $article=$id.php if (file_exists($article)) { include $article; } else{ echo The article you've requested does not exist!; } } else { echo You did not select an article; } ? I am testing using the following links... www.myurl.co.uk/index.php www.myurl.co.uk/index.php?id=1 www.myurl.co.uk/index.php?id=2 When I try the first one, I'd expect it to say you did not select an article, but it says Notice: Undefined variable: id in /home/5217/tomchubb/public_html/index.php on line 15 The article you've requested does not exist When I try the third link, I would expect it to say The article you've requested does not exist! but it says: Parse error: parse error in /home/5217/tomchubb/public_html/index.php on line 16 Lines 15 16 are: if (file_exists($article)) { include $article; } else { echo The article you've requested does not exist!; } I don't understand why this isn't working and I've tried looking into this for 2 hours! Can anyone tell me where I'm going wrong please? Thanks, Tom What I notice is that the first error says it's on line 15, then you give lines 15 and 16 in the second example but line 15 doesn't have id in it. Are you sure your looking at the right lines? Try posting the whole script and maybe someone can catch the problem. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: input type=file problem (Maybe 0T)
David Dorward wrote: Ryan A wrote: The problem is, if she has tried to upload a pic at the same time and screwed up on the date of birth I am unable to send back the value of the FILE box so that too get populated... I tried setting a VALUE=path/file but that does not work. As has already been pointed out, you can't set the value of the file input. What you can do though is to keep the image uploaded the first time round, and send back a form adding a Keep existing upload (perhaps along with a thumbnail of the image), thus saving the user from uploading the image over and over until they fill in the rest of the form correctly. alternatively break the form in 2. step 1 fill in all the required stuff, when that passes you checks present step 2, namely a file upload box. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Running a PHP script everyday [SOLVED]
What a convoluted mess. Rather than using the shebang at the begging of the PHP file I had to put it in the cron command /usr/local/bin/php public_html/wap/mailer/dailylist.php It will now run. But then I had to slightly redesign the HTMLMimeMail code. I had to define some of it as functions and include the file as a function definition rather than include the direct code. I also had to change my include statements to this include public_html/wap/mailer/sending.php; With this type of include I can no longer run it from a browser, but I really didn't want to do that anyways. Thanks for all your help. Andrew Darrow Kronos1 Productions www.pudlz.com - Original Message - From: Miles Thompson [EMAIL PROTECTED] To: [EMAIL PROTECTED]; php-general@lists.php.net Sent: Saturday, July 30, 2005 5:57 PM Subject: Re: [PHP] Running a PHP script everyday If you're on Windows, use Task Manager and have it start an instance of a web browser, with your URL and script passed to it. or Cron job on server, if you have that level of access. Miles At 01:17 PM 7/30/2005, [EMAIL PROTECTED] wrote: I have a PHP script that I need to run once a day. I have it currently setup so that I just run it from my cell phone, but I would prefer something automated. I'd looked into a cron job, but that just looks like it's for doing linux command line stuff on my host. I also thought about writing a never ending while loop with an if statement that checks to see if it's time to run the script, then when it is time, it runs. Then checks to see if it's time again. But even assuming I could get it working, do I really want to have a PHP script that runs all the time. This could be bad if it ate up all the CPU on my server. I'm not even sure I have access rights to kill the process once I start it. Any suggestions? Andrew Darrow Kronos1 Productions www.pudlz.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.9.7/60 - Release Date: 7/28/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Running a PHP script everyday
[EMAIL PROTECTED] writes: My host uses cPanel. When I setup the crontab it e-mails me back this response: /bin/sh: public_html/wap/mailer/dailylist.php: /usr/bin/php : bad interpreter: No such file or directory I'm assuming that it means it can't find /user/bin/php I ran a whereis php through a cronjob and got this: Try which php instead. Another option would be to put the php script in the decomentroot of your server. Schedule a cron job on any of your desktop/dev machines to wget that php script. -- Raj Shekhar blog : http://rajshekhar.net/blog home : http://rajshekhar.net Disclaimer : http://rajshekhar.net/disclaimer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Question on exec() to call a php script from a php script
Liang ZHONG [EMAIL PROTECTED] writes: If my php is configured as ( http://liang.ns2user.info/php/info-train06.htm) an apache 2.0 filter module. The php is invoked by apache on request of http client. Can I do an exec() to call another php script to run in the background? If yes, how? This page might be of help http://in2.php.net/manual/en/ref.pcntl.php Though I am quite sure there is an easier way to accomplish whatever you are trying to do by running a background process -- Raj Shekhar blog : http://rajshekhar.net/blog home : http://rajshekhar.net Disclaimer : http://rajshekhar.net/disclaimer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Performace and segfault errors with Php5 + Apache 1.3.x + linux-2.6.x
i'am developing a web framework SifEngine (Secure Web Inteface framework) that implement MVC applaying the security ideas from http://phpsec.org. I'am using DomXML, Sqlite, Mcrypt and PostgreSql. After of post my development on the internet ( i have been thinking to post on PEAR ), i made simple tests of aplications with my framework. During the implementation, i used Slackware 10.1 with kernel 2.4.29 + php5.0.4 + Apache 1.3.2, with no problems. I didn't detect performace problems or segfaults by apache. Then i decided to do the same test but with kernel 2.6.10, wating that no problems occur. However my expectation, on this new configuration all the aplications develped with my framework, had performance issues or in the worst situation produce apache forks to be restarted, or a lot of apache forks. i don't undestand why this occur, i try to use valigrand to verify memorie lacks without results. Someone can help me, with this problem ! On this moment i'm using SIfEngine, to implement my proyects only on kernel 2.4.x ! Thanks ! Atte: Edwin Hernan Barrios Nuñez iBand Networks Ltda. www.iband.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: preg_match_all question
Actually, I meant what is an actual example of a link it will match. like a href=something.htmtext/a for example. Chris Bruce wrote: It matches any link with the exception of https links. On Jul 20, 2005, at 3:36 PM, Ethilien wrote: I don't see anything in this regex that would prevent https from being matched, since you don't specify the pattern of the actual url at all. What is an example of a link that it will match? Chris Bruce wrote: Hello, I am using the following to do link replacing: preg_match_all(/\s*a\s+[^]*href\s*=\s*[\']?([^\' ]+)[\' ]/isU,$file[$x],$matches); It works great for all but 'https' links. I am not that versed in regular expressions. Would anyone know what I need to put in there so that it will match on https links? Thanks, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] what is this: dirname(__FILE__)?
I don't recognize this something(__SOMETHING__) format. I know what it's doing but I don't know how it's doing it. The whole thing is $fdf_dir=dirname(__FILE__).'/results'; and of course it's setting that var $fdf_dir to the path to a file. Is there something significant about the double underscores __? Why the parentheses, it's not a function? Sorry lame question but I don't know this. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what is this: dirname(__FILE__)?
On Sun, 2005-07-31 at 20:04, Sam Smith wrote: I don't recognize this something(__SOMETHING__) format. I know what it's doing but I don't know how it's doing it. Constants of the type __SOMETHING__ are historical constants for retrieving contextual information about the source code in which the constant is found. For instance __FILE__ indicates the name of the source file in which the __FILE__ constant is found. This nomenclature dates back to at least C and is probably kept for historical reasons since everyone knows C is da bomb! The whole thing is $fdf_dir=dirname(__FILE__).'/results'; and of course it's setting that var $fdf_dir to the path to a file. This means it's setting $fdf_dir to the path to a file called results that is in the same directory as the source file containing __FILE__. Is there something significant about the double underscores __? Yep as stated above :) There are numberous such constants such as __LINE__ to retrieve the current source code line number (very useful for debugging at times), __CLASS__, __FUNCTION__ etc. Why the parentheses, it's not a function? dirname() is a function. Sorry lame question but I don't know this. RTFM ;) 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] Calendar program like on php.net
Quoting Jim Moseby [EMAIL PROTECTED]: I'd repost the link for you, but I've already deleted it. Sorry. Look back through the archives. JM I searched for 'Jim Moseby calendar' in the general and Dev mailing list but no go. Anty clue? -- Roger --- Sign Up for free Email at http://ureg.home.net.my/ --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions Issue
phpinfo() says that sessions are disabled. So, between that and the fact I get the undefined function errors when I try to use session_start() or other session commands, I'm under the strong impression that sessions are disabled. So this leads me back to my original questions, can I activate sessions without recompiling? And if I can't, how do I recompile since I used the SuSE cd's and YasT? John Nichel wrote: Tom Ray [Lists] wrote: We built a box about 7 months or so ago using the SuSE 9.1 cd's, straight install from the CDs. While I've read that sessions are turned on by default, when we try to call on the sessions functions (like with phpOpenChat or start_session()) we get calls to undefined function errors. This is leading me to belive that sessions are disabled for some reason. I need to enable the sessions so I have a few questions 1) Can I do this without recompiling? 2) If I can't, how do I recompile this since I used the SuSE cds? It's SuSE 9.1 running Php 4.3.4 with APache 2.0.49 any help would be great! What does phpinfo() say? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions Issue
Tom Ray [Lists] wrote: phpinfo() says that sessions are disabled. So, between that and the fact I get the undefined function errors when I try to use session_start() or other session commands, I'm under the strong impression that sessions are disabled. So this leads me back to my original questions, can I activate sessions without recompiling? And if I can't, how do I recompile since I used the SuSE cd's and YasT? Perhaps SuSE has a separate php-sessions package? It would be a bit crazy to do it that way, but it is possible to build the session extension as a standalone extension. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] error checking a null array
hi, I have checkboxes beging dynamically generated. to seperate tasks in error checking I have added he arrays not just to $_POST but to $_POST[cb] so names (derived from question numbers) are for example: $_POST[cb][7] A dump of $_POST would therefore include something like [cb]= array(1) { [7]= array(1) { [0]= string(3) 124 } } So I did this: //error checking for checkboxes foreach ($cb as $cbkey = $cbvalue) { foreach($cbvalue as $cbkey2=$cb_answers) { if( !array_key_exists($_POST[$cbkey], $cb)); { $message[$cbkey]=1; } } } This almost works. The problem is that if someone doesn't check a checkbox, NOTHING related to the checkbox gets sent to $_POST; if I insert a hidden value of something, then that hidden value gets passed whether the user inputs something or not, since I need an entirely server-side solution. Is there a way to send something to tell the error checker whether for example $_POST[cb][7] is empty or null, so I can set the error message to one if it's empty? Dump of $_POST with no checkboxes checked $_POST: array(4) { [action]= string(7) process [cat]= string(1) 2 [rs]= array(3) { [5]= string(0) [6]= string(0) [9]= string(0) } [b]= string(8) Continue } Dump of $_POST with checkboxes checked array(5) { [action]= string(7) process [cat]= string(1) 2 [cb]= array(2) { [7]= array(5) { [0]= string(1) 3 [1]= string(3) 124 [2]= string(3) 125 [3]= string(3) 127 [4]= string(3) 131 } [8]= array(3) { [0]= string(3) 141 [1]= string(3) 145 [2]= string(1) 4 } } [rs]= array(3) { [5]= string(0) [6]= string(0) [9]= string(0) } [b]= string(8) Continue } Thanks so much In advance -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: error checking a null array
Jack Jackson wrote: hi, I have checkboxes beging dynamically generated. to seperate tasks in error checking I have added he arrays not just to $_POST but to $_POST[cb] so names (derived from question numbers) are for example: $_POST[cb][7] A dump of $_POST would therefore include something like [cb]= array(1) { [7]= array(1) { [0]= string(3) 124 } } So I did this: //error checking for checkboxes foreach ($cb as $cbkey = $cbvalue) { foreach($cbvalue as $cbkey2=$cb_answers) { if( !array_key_exists($_POST[$cbkey], $cb)); { $message[$cbkey]=1; } } } This almost works. The problem is that if someone doesn't check a checkbox, NOTHING related to the checkbox gets sent to $_POST; if I insert a hidden value of something, then that hidden value gets passed whether the user inputs something or not, since I need an entirely server-side solution. Is there a way to send something to tell the error checker whether for example $_POST[cb][7] is empty or null, so I can set the error message to one if it's empty? I think you might find empty() and isset() fairly useful here. Cheers -- David Robley Don't play stupid with me! I'm better at it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: error checking a null array
David Robley wrote: Jack Jackson wrote: hi, I have checkboxes beging dynamically generated. to seperate tasks in error checking I have added he arrays not just to $_POST but to $_POST[cb] so names (derived from question numbers) are for example: $_POST[cb][7] A dump of $_POST would therefore include something like [cb]= array(1) { [7]= array(1) { [0]= string(3) 124 } } So I did this: //error checking for checkboxes foreach ($cb as $cbkey = $cbvalue) { foreach($cbvalue as $cbkey2=$cb_answers) { if( !array_key_exists($_POST[$cbkey], $cb)); { $message[$cbkey]=1; } } } This almost works. The problem is that if someone doesn't check a checkbox, NOTHING related to the checkbox gets sent to $_POST; if I insert a hidden value of something, then that hidden value gets passed whether the user inputs something or not, since I need an entirely server-side solution. Is there a way to send something to tell the error checker whether for example $_POST[cb][7] is empty or null, so I can set the error message to one if it's empty? I think you might find empty() and isset() fairly useful here. Cheers I would have thought so too, but empty doesn't seem to work if it's not there at all, (I guess it figures, how can it be empty if it isn't there) and isset doesn't work if the array is there but null. or something like that. IN any case I've yet to get them working using either. I probably should have said that! Thanks in advance -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php