Re: [PHP] help with print value

2005-07-30 Thread Miles Thompson


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 .    . mysql_num_rows( $result) . "";

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  somewhere above ...
  echo " " . $myrow['month'] . "";  // the "." (dot) 
concatenates in PHP
  echo " . $myrow['day'] . ""; // or should we 
say "joins strings and variables"
  echo " . $myrow['value'] . " ";  // 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 156
7 334
8 450
9 578
. . .
. . .
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


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Running a PHP script everyday

2005-07-30 Thread Miles Thompson


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



Re: [PHP] Running a PHP script everyday

2005-07-30 Thread Miles Thompson
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 
> > >
> > >
> > > - Original Message -
> > > From: "James Kaufman" <[EMAIL PROTECTED]>
> > > To: 
> > > 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 
> > > > >
> > > >
> > > > 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


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] dynamic two column table

2005-07-30 Thread Sebastian
i know how to break up db results into two tables but im having a hard 
problem with this:


db structure

---
| id | cid | title
---
| 1  | 2  | hardware
| 2  | 3  | software
| 3  | 3  | software
| 4  | 2  | hardware


how can i have hardware on column 1 and software on column 2 using 1 
query? i thought a simple if statement on cid might do it but regardless 
it spreads the results on both columns.


thanx.


--
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



Re: [PHP] Running a PHP script everyday

2005-07-30 Thread sub
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


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" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: "PHP-General" 
Sent: Saturday, July 30, 2005 3:47 PM
Subject: Re: [PHP] Running a PHP script everyday


> On Sat, 2005-07-30 at 18:21, [EMAIL PROTECTED] 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
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Running a PHP script everyday

2005-07-30 Thread Robert Cummings
On Sat, 2005-07-30 at 18:21, [EMAIL PROTECTED] 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.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Running a PHP script everyday

2005-07-30 Thread sub
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" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: 
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, [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
>
>
> - Original Message -
> From: "James Kaufman" <[EMAIL PROTECTED]>
> To: 
> 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
> > >
> >
> > 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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] input type=file problem (Maybe 0T)

2005-07-30 Thread Ryan A

> > setting a VALUE="path/file" but that
> > does not work.



> As far as I know, you
> can't set the initial values for 'file' inputs.
> It's a security thing.


H, you're right,saw the same thing on google after digging a little
deeper, thanks mate.

Cheers,
Ryan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] input type=file problem (Maybe 0T)

2005-07-30 Thread Edward Vermillion

Ryan A wrote:

Hey,

Heres what I am doing, I have a form where a user can enter values and in
the form I have a FILE box so the
user can upload her pic, if she screws up anywhere (eg: putting an alphabet
in her date of birth) I send her back
to the form and her date of birth gets highlighted plus the value she
entered comes in the date of birth and also
an error explanation underneithso far so good.

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.

What am I missing here?

Thanks,
Ryan

As far as I know, you can't set the initial values for 'file' inputs. 
It's a security thing.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Running a PHP script everyday

2005-07-30 Thread Ryan Grange
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 <[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 


- Original Message -
From: "James Kaufman" <[EMAIL PROTECTED]>
To: 
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 

   

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



[PHP] input type=file problem (Maybe 0T)

2005-07-30 Thread Ryan A
Hey,

Heres what I am doing, I have a form where a user can enter values and in
the form I have a FILE box so the
user can upload her pic, if she screws up anywhere (eg: putting an alphabet
in her date of birth) I send her back
to the form and her date of birth gets highlighted plus the value she
entered comes in the date of birth and also
an error explanation underneithso far so good.

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.

What am I missing here?

Thanks,
Ryan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help with Functions

2005-07-30 Thread Tom Chubb
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 <[EMAIL PROTECTED]> 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){
> ?>
>
> 
>
>
> 
> 
>  }
> 
> 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 <<
> 
>$arg1
>$arg2
> 
>
> ENDOFTABLE;
> }
> 
> 
> 
> 
> On 7/30/05, Tom Chubb <[EMAIL PROTECTED]> 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...
> >
> >  > function (headerrow)
> > { ?>
> > > bgcolor="#FF0066">
> >
> >  
> >   > width="20" height="20">
> >
> >
> >  > }
> > ?>
> >
> >
> > 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
[EMAIL PROTECTED]
07915 053312

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Spider/Crawler for Emails possible?

2005-07-30 Thread Jochem Maas

Jay Blanchard wrote:

[snip]
Pardon my ignorance but can you enlighten me a little more please?
Like where can I look for them or how to code?
[/snip]

Start here http://www.php.net/file_get_contents

[snip]
As always all members are more than welcome to ask me for graphics I
hope to 
be benevolent that way.

[/snip]

I had never seen this offer before, but we don't usually barter for
information, just ask questions and they will get answered,usually.



anyone got a MiniCooper or a BMW 116 they wanna swap for some php knowledge?

:-)

on a more serious note - I was wondering what other do/think/don't-say if they
determine that someone who is asking questions seems to be directly or 
indirectly a
competitor (or contracted by one)?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] execution time of ';'

2005-07-30 Thread Jochem Maas

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



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP noobie

2005-07-30 Thread Rory Browne
On 7/30/05, Bob Stia <[EMAIL PROTECTED]> wrote:
> On Friday 29 July 2005 02:55, Jochem Maas wrote:
> > Bob Stia wrote:
> > > Hello PHP list
> > >
> > > First allow me to apologize if this is the wrong place for this and
> > > direct me to the proper place. (be nice now!)
> >
> > this list is really for people who are programmning in php.
> > as you describe it your looking for a php solution as an end user,
> > so no this is not really the right place - although I couldn't
> > really say where you would be better off.
> 
> .
> >
> Hello PHP people,
> 
> First of all let me thank all of the kind people who replied to my call
> for help and intruded into your domain, and there were many of you. It
> is much appreciated. I scrutinized all of your replies and have gained
> some knowledge from your replies.
> 
> Some of you have offered help privately and I may well call upon your
> expertise. May I reserve the right to return to this list with a few
> questions???

You'll always be welcome to ask questions so long as you've made some
effort to find the answer yourself beforehand. You may have noticed
that while your post was slightly OT, nobody objected since you had
previously searched, which is more than a lot of people do.

> 
> Thanks again,
> Bob S.
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help with Functions

2005-07-30 Thread Rory Browne
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){
?>

 


 
 

 
$arg1
$arg2
 

ENDOFTABLE;
}




On 7/30/05, Tom Chubb <[EMAIL PROTECTED]> 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...
> 
>  function (headerrow)
> { ?>
> bgcolor="#FF0066">
>
>  
>   width="20" height="20">
>
>
>  }
> ?>
> 
> 
> 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
> 
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] exec nor shell_exec not doing as expected.

2005-07-30 Thread Rory Browne
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 <[EMAIL PROTECTED]> 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");
> // then2>&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
> are not it, I'm sure, and the user is www quite capable of writing into
> and reading from tmp, so there is no issue there.
> 
> If anybody can tell me what *anything* about this problem, I'd be greatful.
> 
> leonski.
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Running a PHP script everyday

2005-07-30 Thread M Saleh EG
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 
> > >
> > >
> > > - Original Message -
> > > From: "James Kaufman" <[EMAIL PROTECTED]>
> > > To: 
> > > 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 
> > > > >
> > > >
> > > > 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


[PHP] execution time of ';'

2005-07-30 Thread Andy Pieters
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/

--


pgpb1XjyVb78d.pgp
Description: PGP signature


Re: [PHP] Running a PHP script everyday

2005-07-30 Thread Rory Browne
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
> >
> >
> > - Original Message -
> > From: "James Kaufman" <[EMAIL PROTECTED]>
> > To: 
> > 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
> > > >
> > >
> > > 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



[PHP] hide bbcode for spell checking!

2005-07-30 Thread Sonia
This is what it needs to do!

The first tag that is found will set where the parser will insert '' 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!

', '', '' );

$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]

[/[EMAIL PROTECTED]/b][/email][code][/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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] allowing selected file types

2005-07-30 Thread André Medeiros
You might want to read up on this:

http://en.wikipedia.org/wiki/Magic_number_%28programming%29

On 7/30/05, Sebastian <[EMAIL PROTECTED]> 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
> 
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Running a PHP script everyday

2005-07-30 Thread André Medeiros
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
> 
> 
> - Original Message -
> From: "James Kaufman" <[EMAIL PROTECTED]>
> To: 
> 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
> > >
> >
> > 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



Re: [PHP] Running a PHP script everyday

2005-07-30 Thread Matt Darby

[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


- Original Message - 
From: "James Kaufman" <[EMAIL PROTECTED]>

To: 
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

 


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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Running a PHP script everyday

2005-07-30 Thread sub
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" <[EMAIL PROTECTED]>
To: 
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
> > 
> 
> 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
> 
> 

Re: [PHP] Running a PHP script everyday

2005-07-30 Thread James Kaufman
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
> 

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



Re: [PHP] Help with Functions

2005-07-30 Thread sub
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" <[EMAIL PROTECTED]>
To: 
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...




  
  





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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Redirect with referer info

2005-07-30 Thread Dotan Cohen
On 7/30/05, Joe Wollard <[EMAIL PROTECTED]> 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.
> 
>  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 lyrics 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:


No referer! Try clicking around http://dotancohen.com and look at the
source code: they all have referers!

Dotan Cohen
http://ie-only.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] allowing selected file types

2005-07-30 Thread Sebastian

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



[PHP] help with print value

2005-07-30 Thread Jesús Alain Rodríguez Santos
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 156
7 334
8 450
9 578
. . .
. . .
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



[PHP] Help with Functions

2005-07-30 Thread Tom Chubb
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...



 
  
  





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



[PHP] Running a PHP script everyday

2005-07-30 Thread sub
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



Re: [PHP] Redirect with referer info

2005-07-30 Thread Joe Wollard
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.





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"";

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






Re: [PHP] Redirect with referer info

2005-07-30 Thread Matt Darby

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"";

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");

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Redirect with referer info

2005-07-30 Thread Dotan Cohen
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"";

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



Re: [PHP] error checking woes

2005-07-30 Thread Jack Jackson


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 "";
}

//Make a question set div wrapper
echo "\n";
//State the question
echo "";
echo $row['q_text'] . "";
echo "\n\n";
echo " ";
echo "\n";

//Create the dropdown for the answers
echo '  ';
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 "Select from this list\n";
while($ans_row = mysql_fetch_assoc($ans_result)) {

//list the answers for THIS question
echo "" . $ans_row['a_answer'] . "";
echo "\n";
}
echo '  ' . "\n" . ' ' . "\n";
echo "\n\n";
//If there *was* an error div, close it
if (sizeof($message[$row['q_name']])){
echo "";
}
//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 "";
}
   
//Make a question set div wrapper

echo "\n";
//State the question
echo "";
echo $row['q_text'] . "";
echo "\n\n";
echo " ";
echo "\n";
   
//Create the dropdown for the answers

echo '  ';
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 "Select from this list\n";
while($ans_row = mysql_fetch_assoc($ans_result)) {
   
//list the answers for THIS question

echo "" . $ans_row['a_answer'] . "";
echo "\n";
}
echo '  ' . "\n" . ' ' . "\n";
echo "\n\n";
//If there *was* an error div, close it
if (sizeof($message[$row['q_name']])){
echo "";
}
}
}//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



--
PHP General Mailing List (http://ww

[PHP] error checking woes

2005-07-30 Thread Jack Jackson

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 "";
}

//Make a question set div wrapper
echo "\n";
//State the question
echo "";
echo $row['q_text'] . "";
echo "\n\n";
echo " ";
echo "\n";

//Create the dropdown for the answers
echo '  ';
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 "Select from this list\n";
while($ans_row = mysql_fetch_assoc($ans_result)) {

//list the answers for THIS question
echo "" . $ans_row['a_answer'] . "";
echo "\n";
}
echo '  ' . "\n" . ' ' . "\n";
echo "\n\n";
//If there *was* an error div, close it
if (sizeof($message[$row['q_name']])){
echo "";
}
}
}//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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Dropdown Building Function

2005-07-30 Thread Satyam

"Jack Jackson" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Aaron,
> Thanks for showing me this it is very cool indeed.
>
> However maybe I am being dumb and obdurate but what I am really trying to 
> do is build some of these things myself (with, thankfully, help)


Perhaps this can help.  I'm sorry the doc is in Spanish, but the code is not 
so large.

There are two funtions, one to load the data for a dropdown list 
(CargaCombo) and the other to show it.  The reason for this is that a single 
combo might be used in two or more places within a web page so this allow 
for reusability, plus it allows for the display of combos not generated from 
the database but from a plain handcoded  array, such as a list of month 
names.

CargaCombo expects an SQL statement.  It will assume the first field is the 
key of the dropdown box.  It will then concatenate every field from the 
second to whichever to make the description.

MuestraCombo will display the dropdown from an array.  It will assume the 
key of the array to be the value attribute of the  tag and the value 
of the array to be the description.  The first parameter is the name of the 
 tag, the third the key value of the item to be pre-selected and the 
fourth an array of events for the object.  This last one has to be in the 
form of  eventName  => action.

For example:

MuestraCombo('SomeName', array(0=>'No',1=>'Yes'),1,array('onClick' => 
'doSomething();'));


Satyam



/**
 *  Esta función devuelve un array que se puede usar en [EMAIL PROTECTED] 
MuestraCombo 
MuestraCombo} para mostrar un combobox.
 *
 *  La función toma una instrucción de SQL y con ella arma un array donde el 
primer campo que encuentra lo usa como
 *  clave dentro del array y los campos subsiguientes como valor.  Si 
hubiera más de dos campos, concatenará los valores
 *  de los campos desde el segundo en adelante separándolos con barra 
vertical para asignar como valor a la clave dada
 *  por el primer campo. Usualmente se usa con una tabla del tipo Codigo ==> 
Descripción
 *
 *  @param string $sql Instrucción de selección de SQL, debe proveer al 
menos dos campos.
 *  @return array Array con una entrada por registro obtenido, usando el 
campo 0 como clave y los subsiguientes como valor
 */
function &CargaCombo($sql){
 $result = mysql_query($sql) or die ('Error en la consulta: ' . 
mysql_error() . "\r\n$sql");
 while ($line = mysql_fetch_row($result)){
 $s = '';
 for ($i = 1;$i < mysql_num_fields($result);$i++) $s .= ' | ' . 
$line[$i];
 $combo[$line[0]] = substr($s, 3);
 }

 return $combo;
 mysql_free_result($result);
}
/**
 *  Emite el código HTML correspondiente a un ComboBox usando el array que 
se indica.
 *
 *  El array puede haber sido obtenido mediante
 *  [EMAIL PROTECTED] CargaCombo CargaCombo}, o generado por otro medio.
 *  Por cada item del array emitirá un 

[PHP] Re: How to generate MD5 passwords

2005-07-30 Thread Michelle Konzack
Hello Matin,

Am 2005-07-30 03:14:35, schrieb Martin B. Nielsen:
> Are you maybe looking for something like this:
> 
>  $passwords = "test";
> $pass = md5($passwords);
  ^^^
I was missing this.
> echo $pass;
> ?>
> 
> The above will output: 098f6bcd4621d373cade4e832627b4f6 as MD5 hash value.
> For more info, http://se2.php.net/manual/en/function.md5.php

It is exactly what I was searchin for.

> Best regards,
> Martin

Thanks and nice Weekend
Michelle

-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
Michelle Konzack   Apt. 917  ICQ #328449886
   50, rue de Soultz MSM LinuxMichi
0033/3/8845235667100 Strasbourg/France   IRC #Debian (irc.icq.com)


signature.pgp
Description: Digital signature