OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 31 Jul 2005 13:38:46 -0000 Issue 3598

php-general-digest-helplists.php.net
Date: Sun Jul 31 2005 - 08:38:46 CDT


php-general Digest 31 Jul 2005 13:38:46 -0000 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:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


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 <rory.brownegmail.com> 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 <andre.caumgmail.com> 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, subpudlz.com <subpudlz.com> 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" <jmkkaufman.eden-prairie.mn.us>
> > > > To: <php-generallists.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, subpudlz.com 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

attached mail follows:


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, subpudlz.com 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

attached mail follows:


You're talking about a table in a database, correct? Assuming the database
is MySQL, you would:
1. open a connection to the database
2. execute a SQL select statement to fetch the data
3. process the results, formatting them into HTML.

There are a number of tutorials on doing this, but it's only a few lines of
code:

1. Connect to the database:

require( "dbname.inc" ); //stores your hostname, username and password
outside the script.
$db = mysql_pconnect("$host", "$user", "$pass") or die("Unable to connect
to server");

2. Create your query, usually done by first assigning it to a variable.
That way, if you are not getting the results you want it's easy to echo the
SQL to the screen:

$sql = "SELECT month, day, value from sometable order by month, day"; //
use your own field names in place of month, etc.
  $result = mysql_query($sql); // executes the SQL statement
  //echo $result . &nbsp;&nbsp; . mysql_num_rows( $result) . "<br>";

3. test for and process the results. Here we assume a table displayed in
the user's browser.

if( $result && mysql_num_rows( $result) ){ //test that you have a result
AND that number of rows is > 0. Remember the convention that 0 is false.
    while ($myrow = mysql_fetch_array($result)) {
       //assuming you have issued a <table> somewhere above ...
       echo "<tr> <td>" . $myrow['month'] . "</td>"; // the "." (dot)
concatenates in PHP
       echo "<td> . $myrow['day'] . "</td>"; // or should we
say "joins strings and variables"
       echo "<td> . $myrow['value'] . "</td> </tr>"; // and of course,
close the row
    }
}

That's rudimentary. There is no WHERE condition on the SELECT which you
would use if you wanted a particular month or year.

Hope this has been helpful. Check out the various tutorials; there are
probably some written in Spanish. Go to:
http://www.php.net/links.php
and scroll down to Spanish, there are four links there.

Hope this has been helpful - Miles Thompson

At 02:38 PM 7/30/2005, Jesús Alain Rodríguez Santos wrote:
>Sorry for my english, i'm cuban, it's dificult for me explain that in
>english but I'll try:
>
> I have a table columns: month, day and value
>
>||month||day||value
> 7 1 56
> 7 3 34
> 8 4 50
> 9 5 78
> . . .
> . . .
>etc...
>
>I need to get the value for every day, for example:
>for day 1 the value is 56
>for day 3 the value is 67
>for day 4 the value is 50
>
>did you understain, please helpe me
>
>
>
>--
>Este mensaje ha sido analizado por MailScanner
>en busca de virus y otros contenidos peligrosos,
>y se considera que está limpio.
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

attached mail follows:


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
tomps-promo.co.uk