|
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 00:58:16 -0000 Issue 3597
php-general-digest-help
lists.php.net
Date: Sat Jul 30 2005 - 19:58:16 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 31 Jul 2005 00:58:16 -0000 Issue 3597
Topics (messages 219670 through 219702):
Re: error checking woes
219670 by: Jack Jackson
Redirect with referer info
219671 by: Dotan Cohen
219672 by: Matt Darby
219673 by: Joe Wollard
219678 by: Dotan Cohen
Running a PHP script everyday
219674 by: sub.pudlz.com
219680 by: James Kaufman
219681 by: sub.pudlz.com
219682 by: Matt Darby
219683 by: André Medeiros
219686 by: Rory Browne
219688 by: M Saleh EG
219696 by: Ryan Grange
219699 by: sub.pudlz.com
219700 by: Robert Cummings
219701 by: sub.pudlz.com
Help with Functions
219675 by: Tom Chubb
219679 by: sub.pudlz.com
219690 by: Rory Browne
219694 by: Tom Chubb
help with print value
219676 by: Jesús Alain Rodríguez Santos
allowing selected file types
219677 by: Sebastian
219684 by: André Medeiros
hide bbcode for spell checking!
219685 by: Sonia
execution time of ';'
219687 by: Andy Pieters
219692 by: Jochem Maas
Re: exec nor shell_exec not doing as expected.
219689 by: Rory Browne
Re: PHP noobie
219691 by: Rory Browne
Re: PHP Spider/Crawler for Emails possible?
219693 by: Jochem Maas
input type=file problem (Maybe 0T)
219695 by: Ryan A
219697 by: Edward Vermillion
219698 by: Ryan A
dynamic two column table
219702 by: Sebastian
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
Okay, last attempt before I hit my head against wall. I thought perhaps
to add the error check to the dropdown function itself:
function GetQuestionsDropdown($cat){
//first get all the questions
$sql = "SELECT * FROM questions WHERE questions.q_cat=$cat AND
questions.q_style=1";
$result = mysql_query($sql);
//now one-by-one go through the questions
while($row = mysql_fetch_assoc($result)) {
//if the form has been submitted, and the question unanswered
//highlight this whole question and answer block in red.
if ($message[$row['q_name']] == 1){
echo "<div class='error'>";
}
//Make a question set div wrapper
echo "<div class='q_set'>\n";
//State the question
echo "<div class='question'>";
echo $row['q_text'] . "</div>";
echo "\n\n";
echo " <div class='answer'>";
echo "\n";
//Create the dropdown for the answers
echo ' <select name="' . $row['q_name'] . '">';
echo "\n";
//get all of the answers for THIS question
$ans_sql = "select * from answers where answers.q_id=" . $row['q_id'];
$ans_result = mysql_query($ans_sql);
echo " <option value=\"\">Select from this list</option>\n";
while($ans_row = mysql_fetch_assoc($ans_result)) {
//list the answers for THIS question
echo " <option ";
echo "value=\"" . $ans_row['a_id'] . "\"";
if ($row['q_name'] == $ans_row['a_id']) {
echo " selected";
}
echo ">" . $ans_row['a_answer'] . "</option>";
echo "\n";
}
echo ' </select>' . "\n" . ' </div>' . "\n";
echo "</div><!--q_set-->\n\n";
//If there *was* an error div, close it
if (sizeof($message[$row['q_name']])){
echo "</div><!--/error-->";
}
//error checking
if ( !strcmp($action,'process') ) {
if(empty($_POST[$row['q_name']])){
$message[$row['q_name']] == "1";
}
}
}
}//function GetQuestionsDropdown
it didn't work either.
Jack Jackson wrote:
> Hi,
> Now that the drop down is working properly (thanks!!), I am trying to
> validate, and having LOTS of trouble. After being ceaselessly derided
> last night on an irc channel for my dimwitedness, I am still not any
> closer.
>
> The code which works is this:
>
> function GetQuestionsDropdown($cat){
> //first get all the questions
>
> $sql = "SELECT * FROM questions WHERE questions.q_cat=$cat AND
> questions.q_style=1";
>
> $result = mysql_query($sql);
> //now one-by-one go through the questions
> while($row = mysql_fetch_assoc($result)) {
>
> //if the form has been submitted, and the question unanswered
> //highlight this whole question and answer block in red.
> if ($message[$row['q_name']] == 1){
> echo "<div class='error'>";
> }
>
> //Make a question set div wrapper
> echo "<div class='q_set'>\n";
> //State the question
> echo "<div class='question'>";
> echo $row['q_text'] . "</div>";
> echo "\n\n";
> echo " <div class='answer'>";
> echo "\n";
>
> //Create the dropdown for the answers
> echo ' <select name="' . $row['q_name'] . '">';
> echo "\n";
>
> //get all of the answers for THIS question
> $ans_sql = "select * from answers where answers.q_id=" . $row['q_id'];
> $ans_result = mysql_query($ans_sql);
>
> echo " <option value=\"\">Select from this list</option>\n";
> while($ans_row = mysql_fetch_assoc($ans_result)) {
>
> //list the answers for THIS question
> echo " <option ";
> echo "value=\"" . $ans_row['a_id'] . "\"";
>
> if ($row['q_name'] == $ans_row['a_id']) {
> echo " selected";
> }
>
> echo ">" . $ans_row['a_answer'] . "</option>";
> echo "\n";
> }
> echo ' </select>' . "\n" . ' </div>' . "\n";
> echo "</div><!--q_set-->\n\n";
> //If there *was* an error div, close it
> if (sizeof($message[$row['q_name']])){
> echo "</div><!--/error-->";
> }
> }
> }//function GetQuestionsDropdown
>
>
> NOW I have to validate after it's submitted. I am trying to look and
> see, if $_POST[$row['q_name']] is empty then make message of the same
> name = 1, so if
>
> if(empty($_POST['partners'])) {
> $message['partners'] = '1'
> }
>
> Then when I restate the dropdown function, and it shows the questions
> again, those error checking things I built in will
> a) show a div class=error around questions with a message
> b) pre-select the previously selected answers (because I have put in
> the thing in the dropdown which says
>
> if ($row['q_name'] == $ans_row['a_id']) { echo " selected";}
>
>
> The validate code I was trying, the subject of such howling on IRC (and
> I know it doesn't work, but not why) was:
>
> function ValidatePost($cat){
> //first get the q_names
> $sql = "SELECT * FROM questions WHERE q_cat=$cat";
> $result = mysql_query($sql);
>
> //go through the question set
> while($row = mysql_fetch_assoc($result)) {
>
> if(empty($_POST[$row['q_name']])){
>
> $message[$row['q_name']] == "1";
> }
> }
> }//function ValidatePost
>
> Can anyone tell me what I am doing wrong?
>
> Thanks!
> JJ
>
attached mail follows:
Hi list,
I need to redirerect a page, and send the referer information along
with the redirect. I have tried:
header("Location: $url");
and
print"<html><head><meta http-equiv='refresh' content='0; URL=$url'
/></head></html>";
Both of them redirect as expected, but the browser (Firefox and Opera)
do not send referer information along with the request. As this is for
link affiliates, I need that referer info sent with the request. How
to do that? Thanks.
Dotan Cohen
Song Lirics http://song-lirics.com/sl/artists.php/b Song Lirics
attached mail follows:
Dotan Cohen wrote:
>Hi list,
>I need to redirerect a page, and send the referer information along
>with the redirect. I have tried:
>header("Location: $url");
>and
>print"<html><head><meta http-equiv='refresh' content='0; URL=$url'
>/></head></html>";
>
>Both of them redirect as expected, but the browser (Firefox and Opera)
>do not send referer information along with the request. As this is for
>link affiliates, I need that referer info sent with the request. How
>to do that? Thanks.
>
>Dotan Cohen
>Song Lirics http://song-lirics.com/sl/artists.php/b Song Lirics
>
>
>
URL parameters.
$url="www.somesite.org?id=asdf&referrer=2345";
header("Location: $url");
attached mail follows:
To obtain a certain portion of the referring url you might look at
parse_url();
See http://us3.php.net/manual/en/function.parse-url.php
- or -
If you want to bounce the user right back to the previous page
including get variables you could just use this snippet.
<?php
$referrer = $_SERVER['HTTP_REFERER'];
header("Location: " . $referrer);
exit;
?>
On Jul 30, 2005, at 9:36 AM, Dotan Cohen wrote:
> Hi list,
> I need to redirerect a page, and send the referer information along
> with the redirect. I have tried:
> header("Location: $url");
> and
> print"<html><head><meta http-equiv='refresh' content='0; URL=$url'
> /></head></html>";
>
> Both of them redirect as expected, but the browser (Firefox and Opera)
> do not send referer information along with the request. As this is for
> link affiliates, I need that referer info sent with the request. How
> to do that? Thanks.
>
> Dotan Cohen
> Song Lirics http://song-lirics.com/sl/artists.php/b Song Lirics
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
On 7/30/05, Joe Wollard <joe.wollard
gmail.com> wrote:
> To obtain a certain portion of the referring url you might look at
> parse_url();
> See http://us3.php.net/manual/en/function.parse-url.php
>
> - or -
>
> If you want to bounce the user right back to the previous page including get
> variables you could just use this snippet.
>
> <?php$referrer = $_SERVER['HTTP_REFERER'];
> header("Location: " . $referrer);
> exit;
> ?>
I must have not phased the question well. I have a page on
http://lyricslist.com that links to http://song-lirics.com and it is
very important that the request to http://song-lirics.com has the
referer part of the request intact. There is no id=xxx or whatever,
the server at http://song-lirics.com looks at the $HTTP_REFERER to
grant points. That works great when on http://lyricslist.com I do a
simple <a href='~'>lyrics</a> to http://song-lirics.com, but I don't
want to do that. Instead, I link to another page on
http://lyricslist.com so that I can record how many people clicked on
the link, and then I want to redirect to http://song-lirics.com
It's just that with the two redirect methods that I know of (header
and meta), the request to http://song-lirics.com gets there with no
referer information, as if the user typed in the address.
If you want to see it, click:
http://song-lirics.com/sl/goto.php/4
You will be redirected to http://dotancohen.com
Look at the source code, in the first few lines you will see:
<!--
Refferer:
User_Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.10)
Gecko/20050720 Fedora/1.0.6-1.1.fc4 Firefox/1.0.6
Time: July 30, 2005, 12:36 pm
-->
No referer! Try clicking around http://dotancohen.com and look at the
source code: they all have referers!
Dotan Cohen
http://ie-only.com
attached mail follows:
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:
On Sat, Jul 30, 2005 at 09:17:20AM -0700, sub
pudlz.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
>
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
attached mail follows:
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
----- Original Message -----
From: "James Kaufman" <jmk
kaufman.eden-prairie.mn.us>
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, sub
pudlz.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
> >
>
> 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
>
>
attached mail follows:
sub
pudlz.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
>
>
>----- Original Message -----
>From: "James Kaufman" <jmk
kaufman.eden-prairie.mn.us>
>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, sub
pudlz.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
>>>
>>>
>>>
>>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
>>
>>
http://www.redhat.com/docs/manuals/linux/RHL-7.2-Manual/custom-guide/cron-task.html
Unless you have a shebang line ("#!/path/to/php/binary")at the top of
your script, you will have to preface your script's path in your cron
entry with the location of the PHP binary:
0 1 1,15 * * /path/to/php/binary /root/scripts/System_Dump.php
Matt Darby
attached mail follows:
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, sub
pudlz.com <sub
pudlz.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
>
>
> ----- Original Message -----
> From: "James Kaufman" <jmk
kaufman.eden-prairie.mn.us>
> 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, sub
pudlz.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
> > >
> >
> > 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
> >
> >
>
attached mail follows:
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.caum
gmail.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, sub
pudlz.com <sub
pudlz.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
> >
> >
> > ----- Original Message -----
> > From: "James Kaufman" <jmk
kaufman.eden-prairie.mn.us>
> > 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, sub
pudlz.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
> > > >
> > >
> > > 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
>
>
attached mail follows:
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.browne
gmail.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.caum
gmail.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, sub
pudlz.com <sub
pudlz.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" <jmk
kaufman.eden-prairie.mn.us>
> > > 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, sub
pudlz.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:
And how do you automate closing the browser when it's job is done? I
believe the wget method mentioned earlier might be more appropriate.
Even Lynx for Windows set to dump output (rather than stay open for
browsing) would be better than leaving IE or FF open.
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.browne
gmail.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.caum
gmail.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, sub
pudlz.com <sub
pudlz.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" <jmk
kaufman.eden-prairie.mn.us>
>>>>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, sub
pudlz.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
>>>>>
>>>>>
attached mail follows:
I can't figure out how to get into command line access through my webhost.
I've tried telnet and it fails.
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:
php: /usr/src/php-4.3.8/php.ini-recommended /usr/src/php-4.3.8/php.ini-dist
/usr/src/php-4.3.8/php.gif /usr/src/php-4.3.8/php4.spec
/usr/src/php-4.3.10/php.ini-recommended /usr/src/php-4.3.10/php.ini-dist
/usr/src/php-4.3.10/php.gif /usr/src/php-4.3.10/php4.spec /usr/bin/php
/usr/lib/php /usr/lib/php.ini /usr/local/bin/php /usr/local/lib/php
/usr/local/lib/php.ini /usr/include/php
I tried them all except the ones with "src" And still get the same message,
but of course it doesn't say /user/bin/php, it says whichever one I put in
the file.
Now the main PHP file calls to 3 other PHP files in it. Do I need to put
that at the top of each of them as well. I didn't think so because they
aren't being executed. They are called using the include statement.
Also when I use #!/usr/include/php I get the response back from the cron
job, but when I use "#!/usr/include/php -q" like the tutorial says nothing
happens. What does the "-q" do?
Andrew Darrow
Kronos1 Productions
www.pudlz.com
----- Original Message -----
From: "André Medeiros" <andre.caum
gmail.com>
To: <sub
pudlz.com>
Cc: <php-general
lists.php.net>
Sent: Saturday, July 30, 2005 10:35 AM
Subject: Re: [PHP] Running a PHP script everyday
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, sub
pudlz.com <sub
pudlz.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
>
>
> ----- Original Message -----
> From: "James Kaufman" <jmk
kaufman.eden-prairie.mn.us>
> 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, sub
pudlz.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
> > >
> >
> > 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
--
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
attached mail follows:
On Sat, 2005-07-30 at 18:21, sub
pudlz.com wrote:
> I can't figure out how to get into command line access through my webhost.
> I've tried telnet and it fails.
>
> 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:
>
> php: /usr/src/php-4.3.8/php.ini-recommended /usr/src/php-4.3.8/php.ini-dist
> /usr/src/php-4.3.8/php.gif /usr/src/php-4.3.8/php4.spec
> /usr/src/php-4.3.10/php.ini-recommended /usr/src/php-4.3.10/php.ini-dist
> /usr/src/php-4.3.10/php.gif /usr/src/php-4.3.10/php4.spec /usr/bin/php
> /usr/lib/php /usr/lib/php.ini /usr/local/bin/php /usr/local/lib/php
> /usr/local/lib/php.ini /usr/include/php
There it is in /usr/local/bin/php
> I tried them all except the ones with "src" And still get the same message,
> but of course it doesn't say /user/bin/php, it says whichever one I put in
> the file.
Are you sure you tried /usr/local/bin/php ??
> Now the main PHP file calls to 3 other PHP files in it. Do I need to put
> that at the top of each of them as well. I didn't think so because they
> aren't being executed. They are called using the include statement.
No, but you will need to use one of the following for them:
include()
include_once()
require()
require_once()
> Also when I use #!/usr/include/php I get the response back from the cron
> job, but when I use "#!/usr/include/php -q" like the tutorial says nothing
> happens. What does the "-q" do?
See:
/usr/local/bin/php --help
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. |
`------------------------------------------------------------'
attached mail follows:
My include statment looks like this:
include "sending.php";
The ones from MimeMail are:
are include(); and require_once();
Heres the response I get when using /usr/local/bin/php:
/bin/sh: public_html/wap/mailer/dailylist.php: /usr/local/bin/php
: bad interpreter: No such file or directory
Maybe I'm messing up my syntax. I have:
#!/usr/local/bin/php
<?php
my code
?>
I did notice that when I FTP into my site I can not get to /usr or any of
its' subfolders. Could this be an access issue?
Andrew Darrow
Kronos1 Productions
www.pudlz.com
----- Original Message -----
From: "Robert Cummings" <robert
interjinn.com>
To: <sub
pudlz.com>
Cc: "PHP-General" <php-general
lists.php.net>
Sent: Saturday, July 30, 2005 3:47 PM
Subject: Re: [PHP] Running a PHP script everyday
> On Sat, 2005-07-30 at 18:21, sub
pudlz.com wrote:
> > I can't figure out how to get into command line access through my
webhost.
> > I've tried telnet and it fails.
> >
> > 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:
> >
> > php: /usr/src/php-4.3.8/php.ini-recommended
/usr/src/php-4.3.8/php.ini-dist
> > /usr/src/php-4.3.8/php.gif /usr/src/php-4.3.8/php4.spec
> > /usr/src/php-4.3.10/php.ini-recommended /usr/src/php-4.3.10/php.ini-dist
> > /usr/src/php-4.3.10/php.gif /usr/src/php-4.3.10/php4.spec /usr/bin/php
> > /usr/lib/php /usr/lib/php.ini /usr/local/bin/php /usr/local/lib/php
> > /usr/local/lib/php.ini /usr/include/php
>
> There it is in /usr/local/bin/php
>
> > I tried them all except the ones with "src" And still get the same
message,
> > but of course it doesn't say /user/bin/php, it says whichever one I put
in
> > the file.
>
> Are you sure you tried /usr/local/bin/php ??
>
> > Now the main PHP file calls to 3 other PHP files in it. Do I need to put
> > that at the top of each of them as well. I didn't think so because they
> > aren't being executed. They are called using the include statement.
>
> No, but you will need to use one of the following for them:
>
> include()
> include_once()
> require()
> require_once()
>
> > Also when I use #!/usr/include/php I get the response back from the cron
> > job, but when I use "#!/usr/include/php -q" like the tutorial says
nothing
> > happens. What does the "-q" do?
>
> See:
>
> /usr/local/bin/php --help
>
> 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. |
> `------------------------------------------------------------'
>
>
>
>
>
> --
> 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
>
>
attached mail follows:
I am trying to start using functions on some pages to layout a header
row in a table.
I have defined the function as below...
<?php
function (headerrow)
{ ?>
<table width="750" border="0" cellpadding="0" cellspacing="0"
bgcolor="#FF0066">
<tr>
<td class="table_head"><?php echo $tablehead; ?></td>
<td width="20"><img src="/nav/images/pspromo_table_rhs.gif"
width="20" height="20"></td>
</tr>
</table>
<?php
}
?>
What I can't seem to work out is a way to set the text. Here I've
echoed the $tablehead value, but it I was to use more than one table
on the same page then it wouldn't work. Can I do something like
headerrow(text goes here) or something?
I can't understand the use of arguments and it's really confusing me!
Any help would be really appreciated.
Thanks,
Tom
attached mail follows:
I would recomend for sanity and clean code that you define your functions
outside of the file you will be calling it from and include that file in any
file you need to call a function from.
Here's a function that I defined in my db.php file.
/***********************************************************
* FUNCTION: DBCheckByMin($min)
* DESCRIPTION: Checks to see if the user's min already exists
* RETURNED: exist (1 or 0)
**********************************************************/
function DBCheckByMin($min)
{
$record = mysql_query( "SELECT `min` FROM `user` WHERE `min` LIKE '$min'" );
for($i=0; $holder[$i]=mysql_fetch_array( $record ); $i++);
if($min==$holder[0][0])
{
$exist=1;
}
else
{
$exist=0;
}
return $exist;
}
The first line of the file I call this function in includes my function
list:
include "db.php";
And my call to the function itself:
$check=DBCheckByMin($min);
Let's say my user is entering his MIN as "1234567890"
What the function does is catch the value of the variable $min which is
1234567890 when it's called and pass it to the function. Then DBCheckByMin
takes the value 1234567890 and assignes it to the variable $min. (I've named
both variables the same so I know what they are) Now that the function has
it's own variable, $min that has a value of "1234567890" It then does some
basic SQL work to find if that MIN already exists in my databse. Then it
sets $exist to either 1 or 0. It sets it to 1 if this is a duplicate entry
and 0 if it's not a duplicate. And let's just say that it did indeed find a
duplicate record so $exist will have the value of 1. Next on the return
line, the function sends back the value of $exist which is 1. Please
remember when I called the function I had a variable before the function was
called "$check=DBCheckByMin($min);" This way $check will catch whatever
value the function returns, in this case, that value is 1. Now that check
has a value which indicates that this user already exists I can send a
message to the user saying that it already exists and to try again.
Did that make a bit more sense about how variables are passed between
functions? It's all in the call and definition.
Andrew Darrow
Kronos1 Productions
www.pudlz.com
----- Original Message -----
From: "Tom Chubb" <tomchubb
gmail.com>
To: <php-general
lists.php.net>
Sent: Saturday, July 30, 2005 9:23 AM
Subject: [PHP] Help with Functions
I am trying to start using functions on some pages to layout a header
row in a table.
I have defined the function as below...
<?php
function (headerrow)
{ ?>
<table width="750" border="0" cellpadding="0" cellspacing="0"
bgcolor="#FF0066">
<tr>
<td class="table_head"><?php echo $tablehead; ?></td>
<td width="20"><img src="/nav/images/pspromo_table_rhs.gif"
width="20" height="20"></td>
</tr>
</table>
<?php
}
?>
What I can't seem to work out is a way to set the text. Here I've
echoed the $tablehead value, but it I was to use more than one table
on the same page then it wouldn't work. Can I do something like
headerrow(text goes here) or something?
I can't understand the use of arguments and it's really confusing me!
Any help would be really appreciated.
Thanks,
Tom
--
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
attached mail follows:
You're declaring your function wrong.
You're doing:
function (function_name)
You should be doing
function function_name($arg1, $arg2, $arg3) // with as many comma
seperated arguments as you want.
or if you don´t want to pass any arguments
function function_name()
Try this out:
function make_table($arg1, $arg2){
?>
<table>
<tr>
<td><?php echo $arg1; ?></td>
<td><?php echo $arg2; ?></td>
</tr>
</table>
<?php
}
note that I have to go back into PHP twice to get the variables.
I could also (although tbh you should wait until you have more
experience before you read on)
function make_table($arg1, $arg2){
echo <<<ENDOFTABLE
<table>
<tr>
<td>$arg1</td>
<td>$arg2</td>
</tr>
</table>
ENDOFTABLE;
}
On 7/30/05, Tom Chubb <tomchubb
gmail.com> wrote:
> I am trying to start using functions on some pages to layout a header
> row in a table.
> I have defined the function as below...
>
> <?php
> function (headerrow)
> { ?>
> <table width="750" border="0" cellpadding="0" cellspacing="0"
> bgcolor="#FF0066">
> <tr>
> <td class="table_head"><?php echo $tablehead; ?></td>
> <td width="20"><img src="/nav/images/pspromo_table_rhs.gif"
> width="20" height="20"></td>
> </tr>
> </table>
> <?php
> }
> ?>
>
>
> What I can't seem to work out is a way to set the text. Here I've
> echoed the $tablehead value, but it I was to use more than one table
> on the same page then it wouldn't work. Can I do something like
> headerrow(text goes here) or something?
> I can't understand the use of arguments and it's really confusing me!
> Any help would be really appreciated.
> Thanks,
>
> Tom
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
Thanks guys for all your help.
I've managed to get it working.
I tried calling the function from within the file and it turned out
that somehow I had messed up my include statement.
I understood about adding argument variables to the syntax, but I
needed to add a text argument as I couldn't think of a way of setting
the variable in a way that I could distinguish between different
values for different tables on the same page.
Anyway, thanks to you all for taking some time to help me out.
T
On 30/07/05, Rory Browne <rory.browne
gmail.com> wrote:
> You're declaring your function wrong.
>
> You're doing:
>
> function (function_name)
>
> You should be doing
>
> function function_name($arg1, $arg2, $arg3) // with as many comma
> seperated arguments as you want.
>
> or if you don´t want to pass any arguments
>
> function function_name()
>
>
> Try this out:
>
> function make_table($arg1, $arg2){
> ?>
> <table>
> <tr>
> <td><?php echo $arg1; ?></td>
> <td><?php echo $arg2; ?></td>
> </tr>
> </table>
> <?php
> }
>
> note that I have to go back into PHP twice to get the variables.
>
> I could also (although tbh you should wait until you have more
> experience before you read on)
>
> function make_table($arg1, $arg2){
> echo <<<ENDOFTABLE
> <table>
> <tr>
> <td>$arg1</td>
> <td>$arg2</td>
> </tr>
> </table>
> ENDOFTABLE;
> }
>
>
>
>
> On 7/30/05, Tom Chubb <tomchubb
gmail.com> wrote:
> > I am trying to start using functions on some pages to layout a header
> > row in a table.
> > I have defined the function as below...
> >
> > <?php
> > function (headerrow)
> > { ?>
> > <table width="750" border="0" cellpadding="0" cellspacing="0"
> > bgcolor="#FF0066">
> > <tr>
> > <td class="table_head"><?php echo $tablehead; ?></td>
> > <td width="20"><img src="/nav/images/pspromo_table_rhs.gif"
> > width="20" height="20"></td>
> > </tr>
> > </table>
> > <?php
> > }
> > ?>
> >
> >
> > What I can't seem to work out is a way to set the text. Here I've
> > echoed the $tablehead value, but it I was to use more than one table
> > on the same page then it wouldn't work. Can I do something like
> > headerrow(text goes here) or something?
> > I can't understand the use of arguments and it's really confusing me!
> > Any help would be really appreciated.
> > Thanks,
> >
> > Tom
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
--
Tom Chubb
tom
ps-promo.co.uk
07915 053312
attached mail follows:
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.
attached mail follows:
i know i shouldn't rely on mime types for file verification but anyways..
I use application/zip which works fine on firefox and only allows zips..
however, on Internet explorer it doesn't work since IE returns
application/x-zip-compressed for zips.. problem with this is it also
allow rar files.. so even checking mime types is just as useless as not
using it.. one mime type allows two different file types. pffft.
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.9.7/60 - Release Date: 7/28/2005
attached mail follows:
You might want to read up on this:
http://en.wikipedia.org/wiki/Magic_number_%28programming%29
On 7/30/05, Sebastian <sebastian
broadbandgaming.net> wrote:
> i know i shouldn't rely on mime types for file verification but anyways..
>
> I use application/zip which works fine on firefox and only allows zips..
> however, on Internet explorer it doesn't work since IE returns
> application/x-zip-compressed for zips.. problem with this is it also
> allow rar files.. so even checking mime types is just as useless as not
> using it.. one mime type allows two different file types. pffft.
>
>
> --
> No virus found in this outgoing 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
>
>
attached mail follows:
This is what it needs to do!
The first tag that is found will set where the parser will insert '<!-- /
sc' before that tag. Any bbcode tags that are in the current tag will be
skipped over until the parser finds the end of the current bbcode tag it is
working on. Once it finds the end of the current tag it will insert 'sc
/ -->' after the end of the current tag. It will continue doing this until
no tags are left to be parsed in the string!
My script is below....
My question...
Is there a better way to do this?
// script!
<?
$res = array ( '<!-- / sc', 'sc / -->', '', '' );
$str = "[quote=tinyman,Jul 29 2005, 11:27 PM]
Visit my site www.site.com . It provide Email Service(4gb), Free Forum, Free
File Hosting, Free Webhosting and Free Blog hosting.
[b][right]149013[/right][/b]
[/quote][email][b]mm
mm.com[/b][/email][code]<? echo 'hi';
?>[/code]
jp
";
echo bbcode_phase ( $str, $res[0], $res[1] );
function bbcode_phase ( $text, $es, $ee )
{
$bb = array ( 'q' => '5|quote',
'r' => '5|right',
'e' => '5|email',
'h' => '4|html',
'p' => '3|php',
'f' => '4|font',
'l' => array ( '4|list', '4|left' ),
's' => '4|size', 'b' => array ( '2|b]|b', '5|bible' ),
'u' => array ( '2|u]|u', '3|url' ),
'c' => array ( '4|code', '5|color', '6|center' ),
'i' => array ( '2|i]|i', '3|img', '6|indent' ) );
$a = ''; // the output string holder
$b = array (); // the current tag info array
$c = 0; // where we are in the substr
$d = strtolower ( $text ); // lower case the string
while ( ( $e = strpos ( $d, '[' ) ) !== false )
{
$a .= substr ( $text, $c, $e );
$c += $e;
/* if we have a current tag do this */
if ( ! empty ( $b ) )
{
/* if we match the end of the current tag process it */
if ( substr ( $d, ( $e + 2 ), $b[0] ) == $b[1] )
{
if ( isset ( $b[2] ) ) // for bbcode tags ([b], [i] ... )
{
$a .= '[/' . strtoupper ( $b[2] ) . ']' . $ee;
$c += ( $b[0] + 2 );
$d = substr ( $d, ( $e + $b[0] + 2 ) );
}
else
{
$a .= '[/' . strtoupper ( $b[1] ) . ']' . $ee;
$c += ( $b[0] + 3 );
$d = substr ( $d, ( $e + $b[0] + 3 ) );
}
$b = array ();
}
else /* not a current tag substr 1 character forward */
{
$a .= substr ( $text, $c, 1 );
$d = substr ( $d, ( $e + 1 ) );
$c += 1;
}
}
else /* no current tag, find one if it is there */
{
$f = false;
$g = substr ( $d, ( $e + 1 ), 1 );
if ( isset ( $bb[$g] ) )
{
/*
* some tags have more than 1 value so they
* are arrays other are just string values.
*/
if ( is_array ( $bb[$g] ) )
{
for ( $i = 0; $i < sizeof ( $bb[$g] ); $i++ )
{
$b = explode ( '|', $bb[$g][$i] );
if ( substr ( $d, ( $e + 1 ), $b[0] ) == $b[1] )
{
$f = true;
break;
}
}
}
else
{
$b = explode ( '|', $bb[$g] );
if ( substr ( $d, ( $e + 1 ), $b[0] ) == $b[1] )
{
$f = true;
}
}
}
/* we have found a starting tag process it */
if ( $f )
{
if ( isset ( $b[2] ) ) // for bbcode tags ([b], [i] ... )
{
$a .= $es . '[' . strtoupper ( $b[2] );
$c += $b[0];
$d = substr ( $d, ( $e + $b[0] ) );
}
else
{
$a .= $es . '[' . strtoupper ( $b[1] );
$c += ( $b[0] + 1 );
$d = substr ( $d, ( $e + 1 + $b[0] ) );
}
}
else /* not a good starting tag substr 1 character forward */
{
$a .= substr ( $text, $c, 1 );
$b = array ();
$d = substr ( $d, ( $e + 1 ) );
$c += 1;
}
}
}
/*
* if the string has more characters after the last
* closing tag put back what is left...
*
*/
if ( ! empty ( $d ) )
{
$a .= substr ( $text, $c );
}
return ( $a );
}
?>
thanks
Sonia
attached mail follows:
Hi all
We develop our software with built-in debug handlers that are very talkative.
Each class registers itself to a central debug handler. When a conditional
define NODEBUG is set, that debughandler just does a return null but
obviously it takes time to perform that call.
We are thinking of doing a search/replace on the source to replace all
$this->debug('...'); with a ; because if I would replace it with a # it would
generate errors in cases like this:
if(conditions ....)
$this->debug('something...');
So here is the question:
Are there any reasons against doing this kind of replace, or is anyone aware
of a better solution?
With kind regards
Andy
--
Registered Linux User Number 379093
Now listening to Virtual Zone - Virtual Zone
amaroK::the Coolest Media Player in the known Universe!
Cockroaches and socialites are the only things that can
stay up all night and eat anything.
Herb Caen
--
-- --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/
--
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQBC68t36Hylol726jIRAtHwAJ0ZwreqdDMle7bEaZNm0x6Mo+XyKACfUTRc
xMMLbLQyf0DSqBSaxMfm5+g=
=iaz9
-----END PGP SIGNATURE-----
attached mail follows:
Andy Pieters wrote:
> Hi all
>
> We develop our software with built-in debug handlers that are very talkative.
> Each class registers itself to a central debug handler. When a conditional
> define NODEBUG is set, that debughandler just does a return null but
> obviously it takes time to perform that call.
>
> We are thinking of doing a search/replace on the source to replace all
> $this->debug('...'); with a ; because if I would replace it with a # it would
> generate errors in cases like this:
>
> if(conditions ....)
> $this->debug('something...');
asumming replacing the call with ; is valid everywhere it's going to a heck of
a lot faster than calling _any_ function.
>
> So here is the question:
>
> Are there any reasons against doing this kind of replace, or is anyone aware
> of a better solution?
1. use a debugger rather than writing lots of code that logs tons of 'cr*p'?
2. always use braces? so that you can do:
if(conditions ....) {
# $this->debug('something...');
}
3. may put special comment markers in your code that allow you
to filter the files when you 'publish' them into a production env.
/*START_DEBUG_BLOCK*/
if(conditions ....)
$this->debug('something...');
/*END_DEBUG_BLOCK*/
i.e strip the blocks completely:
$newFile = preg_replace( '#/\*START_DEBUG_BLOCK\*/.*/\*END_DEBUG_BLOCK\*/#',
'',
file_get_contents( $yourPhpFile ) );
>
> With kind regards
>
>
> Andy
>
attached mail follows:
Does the command work when you try it from the command line?
If so, then try shell_exec("env > some_filename") and show us the results.
If not, then the problem is with your command.
First thing I would check is the existance of /usr/local/bin/mogrify
On 7/29/05, leonski <brotit
netscape.net> wrote:
> Greetings.
>
> I've practically worn my eyeballs out trying to figure out a problem and
> in desperation am posting here in the hope for familiar eyes to guide
> me, so thanks in advance.
>
> check out this code section:
>
> if (file_exists($imagefile)) {
> $execstring = escapeshellarg("/usr/local/bin/mogrify ".$imagefile."
> -resize 95x72! ");
> }
> else echo ("sorry there was a problem with that file");
> // then....2>&1 is assisting the debug
> $op = shell_exec($execstring.' 2>&1');
> echo $op;
>
> pretty simple - uses the ImageMagick: mogrify. Funny enough it doesn't
> work. The output is:
>
> sh: line 1: /usr/local/bin/mogrify /tmp/phpS1KCen -resize 320x240! :
> No such file or directory sh: line 1: /usr/local/bin/mogrify
> /tmp/phpS1KCen -resize 95x72! : No such file or directory
>
> beats me how it gets inside the if, if it doesn't exist!
>
> I have also tried ImageMagick:convert executable with a generated
> tempfile using tempnam() and the file is created in /tmp as expected,
> but is not filled by the convert - it stays empty, fails and doesn't get
> cleaned up.
>
> I cannot give a link to php.ini as its not on a public server. But Safe
> mode is Off, file size limits are OK as $imagefile can be displayed to
> the screen prior to the shell_exec call.
>
> I also tried using GD instead of ImageMagick and could not get
> imagecreatetruecolor to work either.
>
> OS is OS X on my laptop, entropy build of PHP as "Apache/1.3.29 (Darwin)
> PHP/5.0.4"
>
> I really do not know if this is a PHP, Apache or OS issue. Permissions