php-general Digest 16 Feb 2003 22:46:33 -0000 Issue 1887

Topics (messages 135731 through 135785):

Re: call a website from a php script
        135731 by: Ernest E Vogelsinger

htDig on PHP pages
        135732 by: David McInnis

Re: [PHP-DEV] how to call a website from within a php script
        135733 by: Sebastian Bergmann

Re: [PHP-DEV] database select
        135734 by: Sebastian Bergmann

Re: permissions to work with fopen
        135735 by: qt

date calculation
        135736 by: qt
        135741 by: Fred Merritt
        135742 by: Kevin Waterson
        135745 by: qt
        135748 by: Stephen Willcock
        135751 by: qt
        135755 by: olinux
        135779 by: Stephen Willcock
        135780 by: qt

database selection
        135737 by: H Prins
        135739 by: H Prins
        135740 by: Kevin Waterson
        135743 by: Thomas Seifert
        135746 by: H Prins

Re: Variables from the Form wouldn't transfer to my process page
        135738 by: Geckodeep

Re: Help Needed for Beginners trying to configure Correctly
        135744 by: D'habi Arabians

Re: Block direct image loads but allow them in PHP
        135747 by: Michael Mulligan

Re: Forms Help (continued)
        135749 by: Beauford.2002

colorizing output in bash
        135750 by: Ali Chahvand

ereg usage
        135752 by: Peter Gumbrell
        135760 by: Ernest E Vogelsinger
        135771 by: Rick Emery

copy *.* troubles
        135753 by: Malcolm
        135758 by: Jason Wong
        135762 by: Malcolm

What happened to phpEdit???
        135754 by: Al

Inserting records in a particular way in MySQL
        135756 by: Phillip S. Baker
        135761 by: Miles Thompson
        135775 by: Willie G
        135776 by: Willie G

List problem
        135757 by: Beauford.2002
        135759 by: Jason Wong
        135767 by: Ernest E Vogelsinger

Re: .htpasswd and PayPal generated passwords
        135763 by: David Duong
        135764 by: David Duong

How do I set UID and GID to files.
        135765 by: David Duong
        135769 by: Jason Sheets

Checkbox related...
        135766 by: Dhaval Desai
        135768 by: Ernest E Vogelsinger
        135770 by: Dhaval Desai
        135773 by: Ernest E Vogelsinger

multiple select problem
        135772 by: Thomas Moore

loading same page
        135774 by: Edward Peloke

Sax-like : accessing form fields elements
        135777 by: Robert Mena

Re: Result in the same page
        135778 by: Cal Evans

long running PHP application
        135781 by: Ilja Polvanovas

URL of calling page
        135782 by: acleave
        135783 by: Ernest E Vogelsinger
        135784 by: Kevin Waterson
        135785 by: Justin French

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
At 11:40 16.02.2003, christian tischler said:
--------------------[snip]--------------------
>can anybody tell me please how to "call" a website from a php script.
>
>meaning
>if (something happens) {goto www.google.com} else {goto www.yahoo.com}
--------------------[snip]-------------------- 

I believe you mean to redirect the browser to a website?

    header('Location: http://www.google.com/');

Or to "incorporate" (speak steal) the website?

    readfile('http://www.google.com');

Or to fetch the site to analyze it?

    $hf = fopen('http://www.google.com/') or die('Cannot open google');
    $buffer = null;
    while ($chunk = fread($hf, 4096))
        $buffer .= $chunk;
    fclose($hf);
    // analyze and process buffer

Enjoy :)


-- 
   >O     Ernest E. Vogelsinger
   (\)    ICQ #13394035
    ^     http://www.vogelsinger.at/


--- End Message ---
--- Begin Message ---
Most of the content on my site is generated dynamically by PHP out of a
MySQL database.  This is causing me problems when indexing the site.
Since pages are created dynamically htDig records the current date as
the date the document was created.  I need the create date to be the
create date from the date recorded in the database when the document /
record was added and NOT the date/time that PHP generates the document.

I am hoping that I can pass a date / timestamp in the header.

Any ideas?  Or did I confuse everyone.

David McInnis


--- End Message ---
--- Begin Message ---
christian tischler wrote:
> Can anybody tell me how to call a website from within a php script.

  Please ask user questions on the [EMAIL PROTECTED] list.

-- 
  Sebastian Bergmann
  http://sebastian-bergmann.de/                 http://phpOpenTracker.de/

  Did I help you? Consider a gift: http://wishlist.sebastian-bergmann.de/
--- End Message ---
--- Begin Message ---
Hans Prins wrote:
> [...]

  Please ask user questions on the [EMAIL PROTECTED] list.

-- 
  Sebastian Bergmann
  http://sebastian-bergmann.de/                 http://phpOpenTracker.de/

  Did I help you? Consider a gift: http://wishlist.sebastian-bergmann.de/
--- End Message ---
--- Begin Message ---
Tahnk you,

but I don't want to let web user see the log file


"Nicholas Wieland" <[EMAIL PROTECTED]> wrote in message
20030216011528.GA1411@localhost">news:20030216011528.GA1411@localhost...
> On 2003.02.15 20:11 qt wrote:
> > I am planning to make a log file with fopen command.
> >
> > I am succesfully read and write the file with fopen. But as I see
> > fopen is requiring a file with read and write permission for public.
>
> Not for public, for your webserver user, www-data or another similar
> name.
>
> > I was using same method with perl in cgi-bin directory; but I was
> > giving read and write permission for only owner.
> >
> > If I give write and read permission for only owner; fopen command can
> > not read the file.
> >
> > Do you have any idea, how can I make log file with protecting from
> > public?
>
> Give pemissions to your web server user.
>
> Cheers
> Nicholas


--- End Message ---
--- Begin Message ---
Dear Sirs,

How can I add or subtract two date easily. Is therea any lib or function
about this. I can not find any easy way in the manual

Best Regards


--- End Message ---
--- Begin Message --- Qt,
The easiest way is to convert your dates into a serial day number(i.e. the number of days that have elapsed between your date, and some arbitrary date in the dim and distant past - I think PHP uses 25th November, -4714). There are some calendar functions in php that will do this for you. Once you have your dates as a numeric offset, you can subtract them to get a the number of days between the dates, or you can add or subtract a number of days to get a new offset. Once you have the new offset, there are reverse calendar functions in php, to convert your new offset back to a calendar date.

Check out the functions GregorianToJD(), and JDToGregorian(), in the Calendar functions of the PHP manual. If you do not have access to the calendar functions in your version of php, there are also a couple of examples how to do one of the conversions written in PHP, in the user contributed notes of the manual. There are also many published articles describing algorithms on how to do this. I can remember implementing these functions in 1977(Not in PHP of course), from an article published in the journal of the ACM, in 1963.

Hope this helps. . . Fred

Qt wrote:
Dear Sirs,

How can I add or subtract two date easily. Is therea any lib or function
about this. I can not find any easy way in the manual

Best Regards



--- End Message ---
--- Begin Message ---
This one time, at band camp,
"qt" <[EMAIL PROTECTED]> wrote:

> Dear Sirs,
> 
> How can I add or subtract two date easily. Is therea any lib or function
> about this. I can not find any easy way in the manual

if the dates are timestamps, simply

$new = $timestamp2 - $timestamp1;

cheers
Kevin

-- 
 ______                              
(_____ \                             
 _____) )  ____   ____   ____   ____ 
|  ____/  / _  ) / _  | / ___) / _  )
| |      ( (/ / ( ( | |( (___ ( (/ / 
|_|       \____) \_||_| \____) \____)
Kevin Waterson
Port Macquarie, Australia
--- End Message ---
--- Begin Message ---
Dear Kevin,

I used timestamp allready as following;

$today = strtotime ("1 february 2003");
$enddate = strtotime ("1 march 2003");

$diff = $enddate - $today;

But result comes as

2419200

How can I convert that numbers to days

Best Regards



"Kevin Waterson" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> This one time, at band camp,
> "qt" <[EMAIL PROTECTED]> wrote:
>
> > Dear Sirs,
> >
> > How can I add or subtract two date easily. Is therea any lib or function
> > about this. I can not find any easy way in the manual
>
> if the dates are timestamps, simply
>
> $new = $timestamp2 - $timestamp1;
>
> cheers
> Kevin
>
> --
>  ______
> (_____ \
>  _____) )  ____   ____   ____   ____
> |  ____/  / _  ) / _  | / ___) / _  )
> | |      ( (/ / ( ( | |( (___ ( (/ /
> |_|       \____) \_||_| \____) \____)
> Kevin Waterson
> Port Macquarie, Australia


--- End Message ---
--- Begin Message ---
Try:

$today = strtotime ("1 february 2003");
$enddate = strtotime ("2 february 2003");
$diff = $enddate - $today;

Should give you a clue!

SW


"Qt" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Dear Kevin,
>
> I used timestamp allready as following;
>
> $today = strtotime ("1 february 2003");
> $enddate = strtotime ("1 march 2003");
>
> $diff = $enddate - $today;
>
> But result comes as
>
> 2419200
>
> How can I convert that numbers to days
>
> Best Regards
>
>
>
> "Kevin Waterson" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > This one time, at band camp,
> > "qt" <[EMAIL PROTECTED]> wrote:
> >
> > > Dear Sirs,
> > >
> > > How can I add or subtract two date easily. Is therea any lib or
function
> > > about this. I can not find any easy way in the manual
> >
> > if the dates are timestamps, simply
> >
> > $new = $timestamp2 - $timestamp1;
> >
> > cheers
> > Kevin
> >
> > --
> >  ______
> > (_____ \
> >  _____) )  ____   ____   ____   ____
> > |  ____/  / _  ) / _  | / ___) / _  )
> > | |      ( (/ / ( ( | |( (___ ( (/ /
> > |_|       \____) \_||_| \____) \____)
> > Kevin Waterson
> > Port Macquarie, Australia
>
>


--- End Message ---
--- Begin Message ---
Dear Stephen,

Good clue!!

Is it working allways without problem such as 29 feb?

And one more hel how can I write "1 2 2003" instead of  "1 february 2003"

I wrote but directly but doesn' t work

thanks

"Stephen Willcock" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Try:
>
> $today = strtotime ("1 february 2003");
> $enddate = strtotime ("2 february 2003");
> $diff = $enddate - $today;
>
> Should give you a clue!
>
> SW
>
>
> "Qt" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Dear Kevin,
> >
> > I used timestamp allready as following;
> >
> > $today = strtotime ("1 february 2003");
> > $enddate = strtotime ("1 march 2003");
> >
> > $diff = $enddate - $today;
> >
> > But result comes as
> >
> > 2419200
> >
> > How can I convert that numbers to days
> >
> > Best Regards
> >
> >
> >
> > "Kevin Waterson" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > This one time, at band camp,
> > > "qt" <[EMAIL PROTECTED]> wrote:
> > >
> > > > Dear Sirs,
> > > >
> > > > How can I add or subtract two date easily. Is therea any lib or
> function
> > > > about this. I can not find any easy way in the manual
> > >
> > > if the dates are timestamps, simply
> > >
> > > $new = $timestamp2 - $timestamp1;
> > >
> > > cheers
> > > Kevin
> > >
> > > --
> > >  ______
> > > (_____ \
> > >  _____) )  ____   ____   ____   ____
> > > |  ____/  / _  ) / _  | / ___) / _  )
> > > | |      ( (/ / ( ( | |( (___ ( (/ /
> > > |_|       \____) \_||_| \____) \____)
> > > Kevin Waterson
> > > Port Macquarie, Australia
> >
> >
>
>


--- End Message ---
--- Begin Message ---
If you're using a database, it may be able to take
care of this for you. If you're using mysql:

6.3.4 Date and Time Functions
http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html#Date_and_time_functions

olinux 


--- Fred Merritt <[EMAIL PROTECTED]> wrote:
> Qt,
>       The easiest way is to convert your dates into a
> serial day number(i.e. 
> the number of days that have elapsed between your
> date, and some 
> arbitrary date in the dim and distant past - I think
> PHP uses 25th 
> November, -4714).  There are some calendar functions
> in php that will do 
> this for you.  Once you have your dates as a numeric
> offset, you can 
> subtract them to get a the number of days between
> the dates, or you can 
> add or subtract a number of days to get a new
> offset.  Once you have the 
> new offset, there are reverse calendar functions in
> php, to convert your 
> new offset back to a calendar date.
> 
> Check out the functions GregorianToJD(), and
> JDToGregorian(), in the 
> Calendar functions of the PHP manual.  If you do not
> have access to the 
> calendar functions in your version of php, there are
> also a couple of 
> examples how to do one of the conversions written in
> PHP, in the user 
> contributed notes of the manual.  There are also
> many published articles 
> describing algorithms on how to do this.  I can
> remember implementing 
> these functions in 1977(Not in PHP of course), from
> an article published 
> in the journal of the ACM, in 1963.
> 
> Hope this helps. . . Fred
> 
> Qt wrote:
> > Dear Sirs,
> > 
> > How can I add or subtract two date easily. Is
> therea any lib or function
> > about this. I can not find any easy way in the
> manual
> > 
> > Best Regards
> > 

__________________________________________________
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com
--- End Message ---
--- Begin Message ---
Yes, will be OK with all dates (though the valid range of a timestamp is
typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07
GMT.)

The function you want for numeric dates is:
int mktime ( int hour, int minute, int second, int month, int day, int year)

so, in your example (1st Feb 2003):
$mydate = mktime(0,0,0,2,1,2003);

SW


"Qt" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Dear Stephen,
>
> Good clue!!
>
> Is it working allways without problem such as 29 feb?
>
> And one more hel how can I write "1 2 2003" instead of  "1 february 2003"
>
> I wrote but directly but doesn' t work
>
> thanks
>
> "Stephen Willcock" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Try:
> >
> > $today = strtotime ("1 february 2003");
> > $enddate = strtotime ("2 february 2003");
> > $diff = $enddate - $today;
> >
> > Should give you a clue!
> >
> > SW
> >
> >
> > "Qt" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > Dear Kevin,
> > >
> > > I used timestamp allready as following;
> > >
> > > $today = strtotime ("1 february 2003");
> > > $enddate = strtotime ("1 march 2003");
> > >
> > > $diff = $enddate - $today;
> > >
> > > But result comes as
> > >
> > > 2419200
> > >
> > > How can I convert that numbers to days
> > >
> > > Best Regards
> > >
> > >
> > >
> > > "Kevin Waterson" <[EMAIL PROTECTED]> wrote in message
> > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > > This one time, at band camp,
> > > > "qt" <[EMAIL PROTECTED]> wrote:
> > > >
> > > > > Dear Sirs,
> > > > >
> > > > > How can I add or subtract two date easily. Is therea any lib or
> > function
> > > > > about this. I can not find any easy way in the manual
> > > >
> > > > if the dates are timestamps, simply
> > > >
> > > > $new = $timestamp2 - $timestamp1;
> > > >
> > > > cheers
> > > > Kevin
> > > >
> > > > --
> > > >  ______
> > > > (_____ \
> > > >  _____) )  ____   ____   ____   ____
> > > > |  ____/  / _  ) / _  | / ___) / _  )
> > > > | |      ( (/ / ( ( | |( (___ ( (/ /
> > > > |_|       \____) \_||_| \____) \____)
> > > > Kevin Waterson
> > > > Port Macquarie, Australia
> > >
> > >
> >
> >
>
>


--- End Message ---
--- Begin Message ---
No I am not using msql


"Olinux" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> If you're using a database, it may be able to take
> care of this for you. If you're using mysql:
>
> 6.3.4 Date and Time Functions
>
http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html#Dat
e_and_time_functions
>
> olinux
>
>
> --- Fred Merritt <[EMAIL PROTECTED]> wrote:
> > Qt,
> > The easiest way is to convert your dates into a
> > serial day number(i.e.
> > the number of days that have elapsed between your
> > date, and some
> > arbitrary date in the dim and distant past - I think
> > PHP uses 25th
> > November, -4714).  There are some calendar functions
> > in php that will do
> > this for you.  Once you have your dates as a numeric
> > offset, you can
> > subtract them to get a the number of days between
> > the dates, or you can
> > add or subtract a number of days to get a new
> > offset.  Once you have the
> > new offset, there are reverse calendar functions in
> > php, to convert your
> > new offset back to a calendar date.
> >
> > Check out the functions GregorianToJD(), and
> > JDToGregorian(), in the
> > Calendar functions of the PHP manual.  If you do not
> > have access to the
> > calendar functions in your version of php, there are
> > also a couple of
> > examples how to do one of the conversions written in
> > PHP, in the user
> > contributed notes of the manual.  There are also
> > many published articles
> > describing algorithms on how to do this.  I can
> > remember implementing
> > these functions in 1977(Not in PHP of course), from
> > an article published
> > in the journal of the ACM, in 1963.
> >
> > Hope this helps. . . Fred
> >
> > Qt wrote:
> > > Dear Sirs,
> > >
> > > How can I add or subtract two date easily. Is
> > therea any lib or function
> > > about this. I can not find any easy way in the
> > manual
> > >
> > > Best Regards
> > >
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Shopping - Send Flowers for Valentine's Day
> http://shopping.yahoo.com


--- End Message ---
--- Begin Message ---
Hello,

Im trying to select only one row in a mysql database (in this case a poll
with the smallest pollID)...........
Each row has a field called "pollID" which is the primary key and is auto
incremented when a new row is inserted.

I could possible do the following but I think its a bit extensive:

$query = "SELECT * FROM polls ORDER BY pollID ASC";
$result = mysql_query($query);
for ($count = 0; $count < 1 $count++) {
    $data = mysql_fetch_array($result);
    $pollID = $data['pollID'];
}
$query = "SELECT * FROM polls WHERE pollID = $pollID";

Does anyone now a solution for this that requires less code?

Thx

--- End Message ---
--- Begin Message ---
Hello,

Im trying to select only one row in a mysql database (in this case a poll
with the smallest pollID)...........
Each row has a field called "pollID" which is the primary key and is auto
incremented when a new row is inserted.

I could possible do the following but I think its a bit extensive:

$query = "SELECT * FROM polls ORDER BY pollID ASC";
$result = mysql_query($query);
for ($count = 0; $count < 1 $count++) {
    $data = mysql_fetch_array($result);
    $pollID = $data['pollID'];
}
$query = "SELECT * FROM polls WHERE pollID = $pollID";

Does anyone now a solution for this that requires less code?

Thx


--- End Message ---
--- Begin Message ---
This one time, at band camp,
"H Prins" <[EMAIL PROTECTED]> wrote:

> Hello,
> 
> Im trying to select only one row in a mysql database (in this case a poll
> with the smallest pollID)...........


$query = "SELECT * FROM polls ORDER BY pollID ASC LIMIT 1";

Kevin

-- 
 ______                              
(_____ \                             
 _____) )  ____   ____   ____   ____ 
|  ____/  / _  ) / _  | / ___) / _  )
| |      ( (/ / ( ( | |( (___ ( (/ / 
|_|       \____) \_||_| \____) \____)
Kevin Waterson
Port Macquarie, Australia
--- End Message ---
--- Begin Message ---
On Sun, 16 Feb 2003 12:51:58 +0100 [EMAIL PROTECTED] (Hans Prins) wrote:

> Hello,
> 
> Im trying to select only one row in a mysql database (in this case a poll
> with the smallest pollID)...........
> Each row has a field called "pollID" which is the primary key and is auto
> incremented when a new row is inserted.
> 
> I could possible do the following but I think its a bit extensive:
> 
> $query = "SELECT * FROM polls ORDER BY pollID ASC";
> $result = mysql_query($query);
> for ($count = 0; $count < 1 $count++) {
>     $data = mysql_fetch_array($result);
>     $pollID = $data['pollID'];
> }
> $query = "SELECT * FROM polls WHERE pollID = $pollID";
> 
> Does anyone now a solution for this that requires less code?
> 
> Thx
> 
> 

$query = "SELECT * FROM polls ORDER BY pollID ASC LIMIT 1";


Thats the only row.



Regards,
-- 
Thomas Seifert

mailto:[EMAIL PROTECTED]
http://www.MyPhorum.de 
--- End Message ---
--- Begin Message ---
thank you,

that did the trick :)

"Thomas Seifert" <[EMAIL PROTECTED]> schreef in bericht
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Sun, 16 Feb 2003 12:51:58 +0100 [EMAIL PROTECTED] (Hans Prins) wrote:
>
> > Hello,
> >
> > Im trying to select only one row in a mysql database (in this case a
poll
> > with the smallest pollID)...........
> > Each row has a field called "pollID" which is the primary key and is
auto
> > incremented when a new row is inserted.
> >
> > I could possible do the following but I think its a bit extensive:
> >
> > $query = "SELECT * FROM polls ORDER BY pollID ASC";
> > $result = mysql_query($query);
> > for ($count = 0; $count < 1 $count++) {
> >     $data = mysql_fetch_array($result);
> >     $pollID = $data['pollID'];
> > }
> > $query = "SELECT * FROM polls WHERE pollID = $pollID";
> >
> > Does anyone now a solution for this that requires less code?
> >
> > Thx
> >
> >
>
> $query = "SELECT * FROM polls ORDER BY pollID ASC LIMIT 1";
>
>
> Thats the only row.
>
>
>
> Regards,
> --
> Thomas Seifert
>
> mailto:[EMAIL PROTECTED]
> http://www.MyPhorum.de


--- End Message ---
--- Begin Message ---
Hi Jason

Man you are great, well indeed I stumbled on my stupidity by putting the
hidden name instead of making it unique I've rectified it.

The reason for passing this variable to the next page is the cats table is
only needed in the first form and the name of the cat is just printed on the
following page untill the final result page. I could have looked it up again
on the table on my next form part but thinking of saving the resource I
thought of going for the option of passing the variable.



Well I managed to do by passing the variable enclosing it in the Php tag
like this soloution found on the Forum:

<input type="hidden" name="catname" value = "<?echo $catname ; ?>"> at least
t is getting transferred but I have the problem like you mentioned, it is
only showing the last element on the table no matter what is selected on the
drop down menu. I didn't know that I could pass two values together inside
the option tag like you've shown <option value='$catid|$catname'>. If I
choose this would I need to do a while loop to get the catname or will it
find it along the catid.

Let me try without the while loop.



Thanks again Jason.



gd


"Jason Wong" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Sunday 16 February 2003 09:21, Geckodeep wrote:
>
> > My html looks ok.
>
> Are you sure?
>
> > The TEXT variable is $catname and the $rubriqueid is a mistake it is
> > actually $catid but it is not that giving the problem. It is an error
from
> > my part when I posted it.
>
> How are you passing $catname onto the next page? I presume via the hidden
> input element? AFAICS from your code (and you can spot this straight away
> from the HTML source) you only have a hidden input element for the last
value
> of $catname retrieved from the DB. Thus you need to move them inside the
> while-loop. However your hidden input elements are all named 'hidden'
which
> isn't very helpful -- give them unique names.
>
> The real question is why /are/ you passing $catname to the next page?
$catid
> is the unique identifier so why do you need $catname on the next page? You
> can always lookup $catname from the DB on the next page if you need it. If
> you don't want to look it up again then I suggest putting both $catid and
> $catname into the option value ...
>
>   <option value='$catid|$catname'>$catname</option>
>
> ... then extract the two parts on the following page.
>
> Depending on what characters gets stored in $catname you may need to run
it
> through htmlspecialchars().
>
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
> ------------------------------------------
> Search the list archives before you post
> http://marc.theaimsgroup.com/?l=php-general
> ------------------------------------------
> /*
> Q: How did you get into artificial intelligence?
> A: Seemed logical -- I didn't have any real intelligence.
> */
>


--- End Message ---
--- Begin Message ---
----- Original Message -----
From: "Gabor Hojtsy" <[EMAIL PROTECTED]>
To: "D'habi Arabians" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>; "Northwind Arabians" <[EMAIL PROTECTED]>
Sent: Sunday, February 16, 2003 2:14 AM
Subject: Re: Help Needed for Beginners trying to configure Correctly


> Please forward user questions to [EMAIL PROTECTED]
>
> Goba
>
>
> D'habi Arabians wrote:
> > We are using ISS server and using Dreamweaver with the php
> >
> > We cannot get our test message to come up unless we go around msql.dll
> >
> > We have reinstalled everything.  We believe the problem is in
> > The problem is in line 1 of php.exe but we do not know how to comply.
> >
> >
> >
> > WE would really appreciate your help.
> >
> > Liz Kirmis and Pat Hampton
> >
> > This is the error message:
> >
> > X-Powered-By: PHP/4.2.3^C
> >
> > C:\PHP>php.exe
> >
> > Content-type: text/html
> >
> > PHP Warning: Unable to load dynamic library './extensions/msql.dll' -
The speci
> >
> > fied module could not be found.
> >
> > in Unknown on line 0
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
>
>

--- End Message ---
--- Begin Message ---
Thank you, this looks like the kind of thing I'm looking for. I'll have to
give this a shot and see how it goes. :-)

On 02/15/03 8:44 PM, "Justin French" <[EMAIL PROTECTED]> wrote:

> Using Apache's main config file (or at a per-directory level using a
> .htaccess file), you need to black all .jpg, .jpeg, .gif, .png, .bmp, etc
> etc files from being *directly* served via http.
> 
> I'm not too good with Apache yet, but an example would be:
> 
> <Files ~ "\.jpg$">
>   Order Allow,Deny
>   Deny from all
> </Files>
> <Files ~ "\.gif$">
>   Order Allow,Deny
>   Deny from all
> </Files>
> <Files ~ "\.jpeg$">
>   Order Allow,Deny
>   Deny from all
> </Files>
> <Files ~ "\.bmp$">
>   Order Allow,Deny
>   Deny from all
> </Files>
> 
> (you might also choose to block everything in imageDir/, which would also
> include the xml file)
> 
> 
> 
> Then you need to create a script called image.php which:
> 
> a) accepts file=xxxx.xxx in the URL ($_GET)
> b) sets the appropriate image header
> c) passes the image file though
> 
> Instead of you calling
> <img src='imageDir/picture.jpg' />
> 
> You would call
> <img src='image.php?file=imageDir/picture.jpg' />
> 
> 
> You also need to ensure that users can't directly call image.php?file=
> picture.jpg in the browser, which can also be done with apache / .htaccess
> files.
> 
> 
> <Files ~ "\image.php$">
>   Order Allow,Deny
>   Deny from all
> </Files>
> 
> 
> 
> There's plenty of examples of passing images through in the manual... in
> particular one of the user-contributed notes by "lists at darkcore dot net
> 08-Aug-2002 03:24" at http://php.net/header looks about right.
> 
> 
> Justin
> 
> 
> on 16/02/03 3:24 AM, Michael Mulligan ([EMAIL PROTECTED]) wrote:
> 
>> Perhaps you could further describe such a method? I'm sorry, I just don't
>> quite see how this will block the files. Perhaps I should further explain my
>> situation.
>> 
>> The script that I will distribute will always make use of a very particular
>> directory structure. In "imageDir", there will always be a specifically
>> named XML file that points to a bunch of images in the directory. However,
>> given security checks that I put in my script, not all of those images
>> should be publicly viewable. However, if a savvy user were to just load this
>> XML doc up in their web browser, they will have a complete listing of URLs
>> to all of my images. I cannot modify this XML file.  (which is why I want to
>> block a user from loading, say myserver.com/imageDir/picture.jpg)
>> 
>> Will your proposed idea still work in this situation?
>> 
>> Thanks for your help and patience in this matter. :-)
>> 
>> On 02/15/03 11:09 AM, "Marco Tabini" <[EMAIL PROTECTED]> wrote:
>>> Only if you let them. The PHP script allows to put the appropriate
>>> checks in place. For example, if you use sessions, you can verify that
>>> the session is still valid and that the user has, indeed, the right to
>>> access that image. At a later time, even if another user types in the
>>> same URL but does not have a valid session (or a variable inside the
>>> session that contains the right data), you would be able to block him
>>> from reading the image.
>>> 
>>> Cheers,
>>> 
>>> 
>>> Marco
>> 
>> 
>> -m^2
>> 
>> __________
>> Hi! I'm a .signature virus! Copy me into your ~/.signature to help me
>> spread!
>> __________ 
>> 
>> 
> 


                            -m^2

__________
Hi! I'm a .signature virus! Copy me into your ~/.signature to help me
spread!
__________ 


--- End Message ---
--- Begin Message ---
Globals are turned on....

----- Original Message -----
From: "Ray Hunter" <[EMAIL PROTECTED]>
To: "Beauford.2002" <[EMAIL PROTECTED]>
Cc: "PHP General" <[EMAIL PROTECTED]>
Sent: Sunday, February 16, 2003 12:15 AM
Subject: Re: [PHP] Forms Help (continued)


> Do you have globals turned on or off?
>
> Ray
>
> On Sat, 2003-02-15 at 21:19, Beauford.2002 wrote:
> > Has anyone seen or used this script? It looks fairly straight forward,
but I
> > can't get it to work. It is however, exactly what I need. Any help is
> > appreciated.
> >
> > http://codewalkers.com/tutorials.php?show=28&page=1
> >
> >
> >
> > --
> > 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
>
>


--- End Message ---
--- Begin Message ---
Hi ,

i'm using php in the command line and code snippet looks like:

        <?php
                echo "\033[1mTesting\033[0m\n";
                echo "\e[31;1mTesting\e[m\n";
        ?>

I use ANSI sequences to colorize the output in the bash. Well executing 
        echo -e "\e[31;1mTesting\e[m";

in the bash works fine but doesn't in php. The bold stuff work fine
using php and bash , so i was wondering why this behavior shows up.

any clues, or redirections to other mailing lists?

regards Ali
--- End Message ---
--- Begin Message ---
Could someone please tell me why this code is not working:

ereg ('^[A-H]*([0-9]+)-$', $rank, $matches);
    $workshop_ID = $matches[1][2};

where $rank is something like C12-1 and I just need the C12 part.

Many thanks

Peter Gumbrell
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
At 16:18 16.02.2003, Peter Gumbrell said:
--------------------[snip]--------------------
>Could someone please tell me why this code is not working:
>
>ereg ('^[A-H]*([0-9]+)-$', $rank, $matches);
>    $workshop_ID = $matches[1][2};
>
>where $rank is something like C12-1 and I just need the C12 part.
--------------------[snip]-------------------- 

You're missing the "-1" part in your expression:

    ^       Your string begins
    [A-H]*      with no or more letters from A to H
    ([0-9]+)    followed by one or more digits (grouped)
    -        followed by a dash
    $         and the end or the string

Your pattern would match "C12-", but not "C12-1". If you only need the
"C12", your pattern should look something like
    '^([A-H]*[0-9]+)-'
to return the complete letter/digit sequence at the beginning of the
string, up to (but not including) the dash. Omitting the '$' (string end)
character allows for anything after the dash.


-- 
   >O     Ernest E. Vogelsinger
   (\)    ICQ #13394035
    ^     http://www.vogelsinger.at/


--- End Message ---
--- Begin Message ---
The problem is that it's looking for hyphen, - , immediately preceeding the end.  
Remove the $.
----- Original Message ----- 
From: "Peter Gumbrell" <[EMAIL PROTECTED]>
To: "Php-General" <[EMAIL PROTECTED]>
Sent: Sunday, February 16, 2003 9:18 AM
Subject: [PHP] ereg usage


Could someone please tell me why this code is not working:

ereg ('^[A-H]*([0-9]+)-$', $rank, $matches);
    $workshop_ID = $matches[1][2};

where $rank is something like C12-1 and I just need the C12 part.

Many thanks

Peter Gumbrell
[EMAIL PROTECTED]


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



--- End Message ---
--- Begin Message --- Hello List,

I'm having trouble with copy. I have this script that I got from php.net but I can't figure out how to set the path. Right now it doesn't complain but no files are copied. I'm trying to use a dynamically set directory to do this, I have included ml_config to make the vars available. That's why the $listname in the to_path. I want all the files from /maillist to got to /$listname, I've tried all kinds of slashes, dots and anything else but I can't seem to copy any files. It echos files copied at the end but it lies. Here's the script ;

<?
include "ml_config.php";
$from_path ="/aamaillist/maillist05";
$to_path = "/aamaillist/$listname";

function rec_copy ($from_path, $to_path) {
if(!is_dir($to_path))
{
mkdir($to_path, 0777);
}
if ($handle = opendir($from_path))
{
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") { if (is_file($from_path."/".$file))
{
copy($from_path."/".$file,$to_path."/".$file);
}
elseif ( is_dir($from_path."/".$file) )
{
rec_copy($from_path."/".$file,$to_path."/".$file);
}
}
}
}
}
echo "files copied from $from_path<br>";
echo " files copied to $to_path<br>";
echo "$PHP_SELF";
?>
Anyone see obvious errors or offer another way ?

malcolm
--



--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
--- End Message ---
--- Begin Message ---
On Sunday 16 February 2003 23:48, Malcolm wrote:

>   I'm having trouble with copy.  I have this script that I got from php.net
> but I can't figure out how to set the path.  Right now it doesn't complain
> but no files are copied.  I'm trying to use a dynamically set directory to
> do this, I have included ml_config to make the vars available.  That's why
> the $listname in the to_path. I want all the files from /maillist to got to
> /$listname, I've tried all kinds of slashes, dots and anything else but I
> can't seem to copy any files.  

Are you using full paths? Does the directory 'maillist' reside in the root 
directory? If not, try using full paths.

> It echos files copied at the end but it
> lies.

I doubt whether PHP is clever enough to lie. It's only doing what you told it 
to do.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
We're on Token Ring, and it looks like the token got loose.
*/

--- End Message ---
--- Begin Message --- On Mon, 17 Feb 2003 01:59:43 +0800, Jason Wong <[EMAIL PROTECTED]> wrote:

On Sunday 16 February 2003 23:48, Malcolm wrote:

I'm having trouble with copy. I have this script that I got from php.net
but I can't figure out how to set the path. Right now it doesn't complain
but no files are copied. I'm trying to use a dynamically set directory to
do this, I have included ml_config to make the vars available. That's why
the $listname in the to_path. I want all the files from /maillist to got to
/$listname, I've tried all kinds of slashes, dots and anything else but I
can't seem to copy any files.
Are you using full paths? Does the directory 'maillist' reside in the root directory? If not, try using full paths.

Thanks Jason, but I think I've done that. I'm on windows.
I've tried c:\foxy\www\maillist\
c:\\foxy\\www\\maillist\\
.//mailist
/maillist
../maillist

anything I could think of

and tried to go to c:\foxy\www\maillist\$listname (or newlist - the current valuse of $listname)
c:\\foxy\\www\\maillist\\$listname (or newlist - the current valuse of $listname)
.//mailist/$listname (or newlist - the current valuse of $listname)
/maillist/$listname (or newlist - the current valuse of $listname)
../maillist/$listname (or newlist - the current valuse of $listname)

none of these and probaly many others, I lost track, work.


It echos files copied at the end but it
lies.
I doubt whether PHP is clever enough to lie. It's only doing what you told it to do.

 I'm thinking it's smarter than I am.


--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
--- End Message ---
--- Begin Message ---
Their site no longer responds.

Surely, we haven't lost one of the best php editors.

--- End Message ---
--- Begin Message --- Greetings all,

I have some PHP code that is inserting records into a DB.
Most of this is auto increment.

However I know there is allot of breaks in the sequencing.

I am wondering if there is some way to write the SQL code to search through the existing records in the DB and to find where the next available ID is instead of just inserting the next sequence.

So for example if the ID's are.

20453
20454
20458
20459

It would let me know that 20455 is available for use and use the ID number instead of using 20460
Thanks all.


Phillip

+++++++++++++++++++++++++++++++++++++++++++++++++++
IMPORTANT: This email message (including attachments, if any) is intended
for the use of the individual addressee(s) named above and may contain
information that is confidential, privileged or unsuitable for overly sensitive
persons with low self-esteem, no sense of humor or irrational religious
beliefs. If you are not the intended recipient, any dissemination, distribution
or copying of this email is not authorized (either explicitly or implicitly) and
constitutes an irritating social faux pas. Unless the word absquatulation
has been used in its correct context somewhere other than in this warning,
it does not have any legal or no grammatical use and may be ignored. No
animals were harmed in the transmission of this email, although the barking
dachshund next door is living on borrowed time, let me tell you. Those of
you with an overwhelming fear of the unknown will be gratified to learn that
there is no hidden message revealed by reading this warning backwards,
so just ignore that Alert Notice from Microsoft. However, by pouring a
complete circle of salt around yourself and your computer you can ensure
that no harm befalls you, your family or your pets. If you have received this
email in error, please add some nutmeg and egg whites, whisk and place
in a warm oven for 40 minutes.
+++++++++++++++++++++++++++++++++++++++++++++++++++

--- End Message ---
--- Begin Message ---
Phillip,

It doesn't matter, obviously you're not using the autoincrement ID for a foreign key. All this does is identify a record.

If you did a SELECT and found a missing sequence number, what's to say that value would not be inserted by another user before your INSERT? If you have not set up the table with a MyISAM, MySQL will eventually use the missing numbers.

These are only identifying tags, with no intrinsic meaning.

Miles


At 09:37 AM 2/16/2003 -0800, Phillip S. Baker wrote:
Greetings all,

I have some PHP code that is inserting records into a DB.
Most of this is auto increment.

However I know there is allot of breaks in the sequencing.

I am wondering if there is some way to write the SQL code to search through the existing records in the DB and to find where the next available ID is instead of just inserting the next sequence.

So for example if the ID's are.

20453
20454
20458
20459

It would let me know that 20455 is available for use and use the ID number instead of using 20460
Thanks all.


Phillip

<snip overly long sig>

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

--- End Message ---
--- Begin Message ---
Phillip,

You will have to change your code, so the primary key is not an auto
incremented value.  If you don't, the auto increment will over-ride the 'get
next' function.  Here is what I use in my code.  You just need to change it
for your table.

//----- GetNextKey -----//
function getnextkey(){

        $db = new db();

        $query = "select max(MemberKey) lastkey from Members";

        $result=exequery($query);

        if(@mysql_num_rows($result) >0){
                $numrows=mysql_num_rows($result);
                $flds=mysql_num_fields($result);
                //Should only be one row, but just in case
                for($r=0; $r < $numrows; $r++){
                        $row=mysql_fetch_array($result);
                        $lastkey = StripSlashes($row["lastkey"]);
                }
        } else {
                return 1;
        }

        if (is_numeric($lastkey)) {
                return $lastkey+1;
        } else {
                return 1;
        }

        $db->closedb();
}


-----Original Message-----
From: Phillip S. Baker [mailto:[EMAIL PROTECTED]]
Sent: Sunday, February 16, 2003 12:37 PM
To: PHP Email List
Subject: [PHP] Inserting records in a particular way in MySQL


Greetings all,

I have some PHP code that is inserting records into a DB.
Most of this is auto increment.

However I know there is allot of breaks in the sequencing.

I am wondering if there is some way to write the SQL code to search through
the existing records in the DB and to find where the next available ID is
instead of just inserting the next sequence.

So for example if the ID's are.

20453
20454
20458
20459

It would let me know that 20455 is available for use and use the ID number
instead of using 20460
Thanks all.


Phillip

+++++++++++++++++++++++++++++++++++++++++++++++++++
IMPORTANT: This email message (including attachments, if any) is intended
for the use of the individual addressee(s) named above and may contain
information that is confidential, privileged or unsuitable for overly
sensitive
persons with low self-esteem, no sense of humor or irrational religious
beliefs. If you are not the intended recipient, any dissemination,
distribution
or copying of this email is not authorized (either explicitly or
implicitly) and
constitutes an irritating social faux pas. Unless the word absquatulation
has been used in its correct context somewhere other than in this warning,
it does not have any legal or no grammatical use and may be ignored. No
animals were harmed in the transmission of this email, although the barking
dachshund next door is living on borrowed time, let me tell you. Those of
you with an overwhelming fear of the unknown will be gratified to learn that
there is no hidden message revealed by reading this warning backwards,
so just ignore that Alert Notice from Microsoft. However, by pouring a
complete circle of salt around yourself and your computer you can ensure
that no harm befalls you, your family or your pets. If you have received
this
email in error, please add some nutmeg and egg whites, whisk and place
in a warm oven for 40 minutes.
+++++++++++++++++++++++++++++++++++++++++++++++++++


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



--- End Message ---
--- Begin Message ---
Miles,

I never use auto increment.  Not because of gaps, but in case I need to
reload the table.  They do have meaning if they are foreign keys to another
table.

- Larry


-----Original Message-----
From: Miles Thompson [mailto:[EMAIL PROTECTED]]
Sent: Sunday, February 16, 2003 1:14 PM
To: Phillip S. Baker; PHP Email List
Subject: Re: [PHP] Inserting records in a particular way in MySQL



Phillip,

It doesn't matter, obviously you're not using the autoincrement ID for a
foreign key. All this does is identify a record.

If you did a SELECT and found a missing sequence number, what's to say that
value would not be inserted by another user before your INSERT? If you have
not set up the table with a MyISAM, MySQL will eventually use the missing
numbers.

These are only identifying tags, with no intrinsic meaning.

Miles


At 09:37 AM 2/16/2003 -0800, Phillip S. Baker wrote:
>Greetings all,
>
>I have some PHP code that is inserting records into a DB.
>Most of this is auto increment.
>
>However I know there is allot of breaks in the sequencing.
>
>I am wondering if there is some way to write the SQL code to search
>through the existing records in the DB and to find where the next
>available ID is instead of just inserting the next sequence.
>
>So for example if the ID's are.
>
>20453
>20454
>20458
>20459
>
>It would let me know that 20455 is available for use and use the ID number
>instead of using 20460
>Thanks all.
>
>
>Phillip
>
><snip overly long sig>
>
>--
>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



--- End Message ---
--- Begin Message ---
Does anyone else get bounced messages saying they can't send email to
[EMAIL PROTECTED] when sending email to the list? Every email I send to
the list I get this.  I don't get this when sending email to anyone else or
any other list.

TIA


--- End Message ---
--- Begin Message ---
On Monday 17 February 2003 01:54, Beauford.2002 wrote:
> Does anyone else get bounced messages saying they can't send email to
> [EMAIL PROTECTED] when sending email to the list? Every email I send
> to the list I get this.  I don't get this when sending email to anyone else
> or any other list.

Yes, just ignore it. It'll sort itself out over time.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
"Time is an illusion.  Lunchtime doubly so."
-- Ford Prefect, _Hitchhiker's Guide to the Galaxy_
*/

--- End Message ---
--- Begin Message ---
At 18:54 16.02.2003, Beauford.2002 said:
--------------------[snip]--------------------
>Does anyone else get bounced messages saying they can't send email to
>[EMAIL PROTECTED] when sending email to the list? Every email I send to
>the list I get this.  I don't get this when sending email to anyone else or
>any other list.
--------------------[snip]-------------------- 

Yes, always as any other poster... I've added this to my auto-trash filter.


-- 
   >O     Ernest E. Vogelsinger
   (\)    ICQ #13394035
    ^     http://www.vogelsinger.at/


--- End Message ---
--- Begin Message ---
Try http://www.php.net/md5.

Use md5 to encrypt the password, then when you need to check from login just
encrypt what is given, and see if this matches the md5 found in the
database.

- David

"Rob Packer" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>     I use PayPal to generate a username and password and then write them
to
> the .htpasswd file. If I were to switch to using a database (because
> .htaccess seems to always prompt twice!) how would I perform the
comparison
> for the passwords? It would seem that everytime you generate an encrypted
> password it's different. So how would you compare them? Also, does anyone
> know what the encryption method used by PayPal is?
>
> Thanks for any help...
>
> Robert Packer
>
>


--- End Message ---
--- Begin Message ---
btw - What do you mean by paypal generated passwords?  I am interested in
using PayPal as an alternative to my current credit card handler.

Just a link is appreciated.

- David


"Rob Packer" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>     I use PayPal to generate a username and password and then write them
to
> the .htpasswd file. If I were to switch to using a database (because
> .htaccess seems to always prompt twice!) how would I perform the
comparison
> for the passwords? It would seem that everytime you generate an encrypted
> password it's different. So how would you compare them? Also, does anyone
> know what the encryption method used by PayPal is?
>
> Thanks for any help...
>
> Robert Packer
>
>


--- End Message ---
--- Begin Message ---
See topic.


--- End Message ---
--- Begin Message ---
Use the chown function, chown is documented at
http://www.php.net/manual/en/function.chown.php


Jason
On Sat, 2003-02-15 at 21:00, David Duong wrote:
> See topic.
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message --- Hi everybody,

I have a form with 5 checkboxes. I want to make sure that a user checks atleast 2 boxes before he can proceed. How can that be made possible.

Thank you

-Dhaval





_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail

--- End Message ---
--- Begin Message ---
At 19:57 16.02.2003, Dhaval Desai said:
--------------------[snip]--------------------
>I have a form with 5 checkboxes. I want to make sure that a user checks 
>atleast 2 boxes before he can proceed. How can that be made possible.
--------------------[snip]-------------------- 

You have 2 options:

1) Client-side JavaScript: in the forms OnSubmit handler, loop your
checkboxes and make sure at least 2 are checked. If the precondition is not
met, return false from the onSubmit handler.

2) Server-Side via PHP: make an array of all available checkboxes, and walk
this array to see if you have at least 2 of these checkboxes set in your
$_REQUEST array. If the precondition is not met, retransmit the original
form without proceeding.

I'd prefer a combination of both - the JS method saves the user an
unnecessary form transmission, speeding up his entry. The server-side
script method makes sure there's no malicious user trying to trick the
system *g*


-- 
   >O     Ernest E. Vogelsinger
   (\)    ICQ #13394035
    ^     http://www.vogelsinger.at/


--- End Message ---
--- Begin Message --- How do we do it using the first option i.e javascript to count how many boxes are checked...could you give some example...

Thanx

-Dhaval






From: "David McInnis" <[EMAIL PROTECTED]>
To: "'Dhaval Desai'" <[EMAIL PROTECTED]>
Subject: RE: [PHP] Checkbox related...
Date: Sun, 16 Feb 2003 10:59:17 -0800

You can use javascript to count the number of items checked or you can
check the size of your array once the form has been submitted to the
server.

David

-----Original Message-----
From: Dhaval Desai [mailto:[EMAIL PROTECTED]]
Sent: Sunday, February 16, 2003 10:58 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Checkbox related...

Hi everybody,

I have a form with 5 checkboxes. I want to make sure that a user checks
atleast 2 boxes before he can proceed. How can that be made possible.

Thank you

-Dhaval





_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*
http://join.msn.com/?page=features/junkmail


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

_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail

--- End Message ---
--- Begin Message ---
At 20:34 16.02.2003, Dhaval Desai said:
--------------------[snip]--------------------
>How do we do it using the first option i.e javascript to count how many 
>boxes are checked...could you give some example...
--------------------[snip]-------------------- 

Warning - untested:

<script language="JavaScript">
function validateChecks()
{
    aboxes = Array('box1','box2','box3','box4','box5');
    hF = document.forms['myform'];
    if (hF) {
        for (i = 0, count=0; i < aboxes.length; i++) {
           hBox = hF.elements[aboxes[i]];
           if (hBox.checked) {
               ++count;
               if (count >= 2)
                   return true;
           }
        }
    }
    return false;
}
</script>

----

<form name="myform" onSubmit="validateChecks()">
<input type="checkbox" name="box1" value="1">
<input type="checkbox" name="box2" value="1">
<input type="checkbox" name="box3" value="1">
<input type="checkbox" name="box4" value="1">
<input type="checkbox" name="box5" value="1">
<input type="submit">
</form>

----

I believe you get the idea...


-- 
   >O     Ernest E. Vogelsinger
   (\)    ICQ #13394035
    ^     http://www.vogelsinger.at/


--- End Message ---
--- Begin Message ---
I had code working that was passing multiple select values to another screen from a 
form...

In the URL on the next page I see a bunch of characters, so it doesn't work...
%5C%22year_model_id%5B%5D%5C%22=60776 

Anyone know what this is and how to fix it??? It was working fine for months and just 
stopped working one day.

Much appreciated...
thanks,
-tom

<FORM>
<SELECT NAME=\"year_model_id[]\" SIZE=30 MULTIPLE>
EOL
<?
 while(list($year_model_id, $year, $make, $model) = mysql_fetch_row($result)) {
    <code here>
 }
 print "</SELECT>";

<submit button...>

</FORM>











--- End Message ---
--- Begin Message ---
hello,

I have a very simply page, the users can signup for a certain time to volunteer, when 
they hit submit, the page reloads but I want their time to be inserted in the db and 
then displayed.  After I hit submit, it brings me back to the page but their info 
isn't there until I refresh.  Sometimes their data never shows up yet I can print off 
the sql statements, run them against the db and see all the data...is the script just 
loading to fast?  I have only tested this running locally.

Thanks,
Eddie

<?
require("connection.php");
 if ($bikers){$SQL = "insert into bbreak(name,time) values ('$name','$time') ";
             $result = mysql_db_query($db,"$SQL",$connection);
            }


?>

<center>
    Please sign up for the hours that you can work.  We need a minimum of 3 men there 
for each shift. They will be doing the tire pressure checks and any other minor 
maintenance that might be required. Ladies are also urged to come as we are hoping 
there will be women bikers that we can minister to in whatever way is needed.  Anyone 
can come anytime but we need to have enough commitments that we know the break will be 
staffed adequately every shift.
    We cannot give away anything that would compete with the drinks and snacks that 
are sold at the rest stop but we can give away ice water and possibly coffee. Thanks 
for your help!
 <br>
 <br>
 <br>
<br>
<center>
<FORM name="bikers" action="bikers.php" method=post>
 Name <input type='text' name='name' maxlength='25'>
Time <SELECT name="time">
                    <OPTION value=288 selected>Friday, February 28, 8 a.m.-12 
p.m.</OPTION>
                    <OPTION value=2812>Friday, February 28, 12 p.m.-4 p.m.</OPTION>
                    <OPTION value=284>Friday, February 28, 4 p.m.-8 p.m.</OPTION>
                    <OPTION value=18>Saturday, March 1, 8 a.m.-12 p.m.</OPTION>
                    <OPTION value=112>Saturday, March 1, 12 p.m.-4 p.m.</OPTION>
                    <OPTION value=14>Saturday, March 1, 4 p.m.-8 p.m.</OPTION>
                    <OPTION value=28>Sunday, March 2, 8 a.m.-12 p.m.</OPTION>
                    <OPTION value=212>Sunday, March 2, 12 p.m.-4 p.m.</OPTION>
                    <OPTION value=24>Sunday, March 2, 4 p.m.-8 p.m.</OPTION>
                    </SELECT>
<INPUT type=submit value=SignUp name=bikers>


<table width='95%'>
    <tr bgColor=#990000><td>
         <?
             $SQL = "select * from bbreak where time=288 ";
             $result = mysql_db_query($db,"$SQL",$connection);
             $myrow = mysql_fetch_array($result);
         ?>
          <center>
          <font face='arial' size='3' color='ffffff'>Friday February 28th 8 AM to Noon
          </td></tr>
          <? while ($myrow = mysql_fetch_array($result)){
             print "<tr><td><center>";
             print $myrow["name"];
             print "</tr></td>";
                                                         }
          ?>

 </table>
<table width='95%'>
    <tr bgColor=#999999><td>
         <?
             $SQL1 = "select * from bbreak where time=2812 ";
             $result1 = mysql_db_query($db,"$SQL1",$connection);
             $myrow1 = mysql_fetch_array($result1);

         ?>
          <center>
          <font face='arial' size='3' color='ffffff'>Friday February 28th 12 p.m  to 4 
p.m.
          </td></tr>
          <? while ($myrow1 = mysql_fetch_array($result1)){
             print "<tr><td><center>";
             print $myrow1["name"];
             print "</tr></td>";
                                                         }
          ?>

 </table>

 <table width='95%'>
    <tr bgColor=#000066><td>
         <?
             $SQL2 = "select * from bbreak where time=284";
             $result2 = mysql_db_query($db,"$SQL2",$connection);
             $myrow2 = mysql_fetch_array($result2);

         ?>
          <center>
          <font face='arial' size='3' color='ffffff'>Friday February 28th 4 p.m. to 8 
p.m.
          </td></tr>
          <? while ($myrow2 = mysql_fetch_array($result2)){
             print "<tr><td><center>";
             print $myrow2["name"];
             print "</tr></td>";
                                                         }
          ?>

 </table>

<table width='95%'>
    <tr bgColor=#990000><td>
         <?
             $SQL3 = "select * from bbreak where time=18";
             $result3 = mysql_db_query($db,"$SQL3",$connection);
             $myrow3 = mysql_fetch_array($result3);

         ?>
          <center>
          <font face='arial' size='3' color='ffffff'>Saturday March 1st 8 AM to Noon
          </td></tr>
          <? while ($myrow3 = mysql_fetch_array($result3)){
             print "<tr><td><center>";
             print $myrow3["name"];
             print "</tr></td>";
                                                         }
          ?>

 </table>
<table width='95%'>
    <tr bgColor=#999999><td>
         <?
             $SQL4 = "select * from bbreak where time=112";
             $result4 = mysql_db_query($db,"$SQL4",$connection);
             $myrow4 = mysql_fetch_array($result4);

         ?>
          <center>
          <font face='arial' size='3' color='ffffff'>Saturday March 1st 12 p.m  to 4 
p.m.
          </td></tr>
          <? while ($myrow4 = mysql_fetch_array($result4)){
             print "<tr><td><center>";
             print $myrow4["name"];
             print "</tr></td>";
                                                         }
          ?>

 </table>

 <table width='95%'>
    <tr bgColor=#000066><td>
         <?
             $SQL5 = "select * from bbreak where time=14";
             $result5 = mysql_db_query($db,"$SQL5",$connection);
             $myrow5 = mysql_fetch_array($result5);

         ?>
          <center>
          <font face='arial' size='3' color='ffffff'>Saturday March 1st 4 p.m. to 8 
p.m.
          </td></tr>
          <? while ($myrow5 = mysql_fetch_array($result5)){
             print "<tr><td><center>";
             print $myrow5["name"];
             print "</tr></td>";
                                                         }
          ?>

 </table>
<table width='95%'>
    <tr bgColor=#990000><td>
         <?
             $SQL6 = "select * from bbreak where time=28";
             $result6 = mysql_db_query($db,"$SQL6",$connection);
             $myrow6 = mysql_fetch_array($result6);
         ?>
          <center>
          <font face='arial' size='3' color='ffffff'>Sunday March 2nd 8 AM to Noon
          </td></tr>
          <? while ($myrow6 = mysql_fetch_array($result6)){
             print "<tr><td><center>";
             print $myrow6["name"];
             print "</tr></td>";
                                                         }
          ?>

 </table>
<table width='95%'>
    <tr bgColor=#999999><td>
         <?
             $SQL = "select * from bbreak where time=212";
             $result = mysql_db_query($db,"$SQL",$connection);
             $myrow = mysql_fetch_array($result);
         ?>
          <center>
          <font face='arial' size='3' color='ffffff'>Sunday March 2nd 12 p.m  to 4 p.m.
          </td></tr>
          <? while ($myrow = mysql_fetch_array($result)){
             print "<tr><td><center>";
             print $myrow["name"];
             print "</tr></td>";
                                                         }
          ?>

 </table>

 <table width='95%'>
    <tr bgColor=#000066><td>
         <?
             $SQL = "select * from bbreak where time=24 ";
             $result = mysql_db_query($db,"$SQL",$connection);
             $myrow = mysql_fetch_array($result);
         ?>
          <center>
          <font face='arial' size='3' color='ffffff'>Sunday March 2nd 4 p.m. to 8 p.m.
          </td></tr>
          <? while ($myrow = mysql_fetch_array($result)){
             print "<tr><td><center>";
             print $myrow["name"];
             print "</tr></td>";
                                                         }
          ?>

 </table>

</BODY>
</HTML>

--- End Message ---
--- Begin Message ---
Hi,

I am developing an application which will have to
parse a html page and extract information about the
forms found.

I tried the HTMLSAX class
(http://www.phpclasses.org/browse.html/package/678.html)
which is ok except by the fact that I can not retrieve
the default/checked status from the elements.

Ie. <select name=foo><option value=bar ckecked>

Any ideias ?

Since the html will usually be ill-formed a standard
DOM-tree (with builtin functions at least) wont be possible.

__________________________________________________
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com
--- End Message ---
--- Begin Message ---
John,

header(location:) is the way I'm doing it. I check for the Submit button, if
it was pressed and the processing succeeded, I redirect.  If processing
fails (validation, error in connecting to the database, etc.) I redisplay
the same page with all the same variables that the user just input.  I give
them a message telling them what went wrong and allow them to fix it.

If you find a better way, please share. It would be nice to have something
like <jsp:forward>
=C=


-----Original Message-----
From: John Hicks [mailto:[EMAIL PROTECTED]]
Sent: Saturday, February 15, 2003 11:56 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Result in the same page


Cal--

I just posted this reply to your reply on php.general.

--John


From: [EMAIL PROTECTED] (John Hicks)
Newsgroups: php.general
Subject: Re: [PHP] Result in the same page
References: <[EMAIL PROTECTED]>
<[EMAIL PROTECTED]>
NNTP-Posting-Host: 68.165.13.138
Message-ID: <[EMAIL PROTECTED]>

I, too, like the idea of keeping my processing code in the same file
as the form being processed. But I'm trying to figure out how to
transfer control to the next page based on the result of the forms
processing.

In JSP, i would use <jsp:forward>, which is basically a "Go to"
command. The only reference I can find to "transfer of control" in PHP
is the header(location: ) function. But that requires a complete
server/browser/server interchange.

There must be a more direct way to transfer control in PHP. Would
someone please tell me what it is?

Thanks in advance,

Frappy

[EMAIL PROTECTED] (Cal Evans) wrote in message
news:<[EMAIL PROTECTED]>...
> Yes, just user $_SERVER['PHP_SELF'] as the action of your form. This will
> cause the page to call itself. Then you can branch your processing on the
> existence of a SUBMIT button (or whatever) and handle the query.
>
> I do all my pages this way because it keeps all the code in a single page.
> It's easier for me to find it that way.
>
> =C=
>
> *
> * Cal Evans
> * Stay plugged into your audience.
> * http://www.christianperformer.com

--- End Message ---
--- Begin Message ---
Does anybody have minds about problems running long running PHP scripts as
standalone programs (ex. like servers, daemons). For example there is a
"simple TCP/IP server" in Sockets chapter of the Manual. Have anybody any
ideas how long can the script run ? is there any garbage collector in PHP,
if it is, is it enough solution? Can the script run for unlimited time ? is
there any restrictions ? Is it stable enough ?


--- End Message ---
--- Begin Message ---
I believe there's a way in PHP to get the URL of the page that called the 
current page but can't find it.  Is there such a function?  Or would I have to 
use another script (like Javascript)?

What I mean is if I click on a link on index.html to jeremiah.php I can call 
the function and find out I just came from index.html (and not henry.php or 
fred.php).

Thank you.

Allan Cleaveland
Webmaster and Computer Technician
Math Department
Univeristy of Arkansas

--- End Message ---
--- Begin Message ---
At 22:58 16.02.2003, acleave said:
--------------------[snip]--------------------
>I believe there's a way in PHP to get the URL of the page that called the 
>current page but can't find it.  Is there such a function?  Or would I
>have to 
>use another script (like Javascript)?
--------------------[snip]-------------------- 

http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server

$_SERVER['HTTP_REFERER']

The address of the page (if any) which referred the user agent to the
current page. This is set by the user agent. Not all user agents will set
this, and some provide the ability to modify HTTP_REFERER as a feature. In
short, it cannot really be trusted. 



-- 
   >O     Ernest E. Vogelsinger
   (\)    ICQ #13394035
    ^     http://www.vogelsinger.at/


--- End Message ---
--- Begin Message ---
This one time, at band camp,
acleave <[EMAIL PROTECTED]> wrote:

> I believe there's a way in PHP to get the URL of the page that called the 
> current page but can't find it.  Is there such a function?  Or would I have to 
> use another script (like Javascript)?

$_SERVER['HTTP_REFERER']

Kevin

-- 
 ______                              
(_____ \                             
 _____) )  ____   ____   ____   ____ 
|  ____/  / _  ) / _  | / ___) / _  )
| |      ( (/ / ( ( | |( (___ ( (/ / 
|_|       \____) \_||_| \____) \____)
Kevin Waterson
Port Macquarie, Australia
--- End Message ---
--- Begin Message ---
on 17/02/03 9:25 AM, Kevin Waterson ([EMAIL PROTECTED]) wrote:

> This one time, at band camp,
> acleave <[EMAIL PROTECTED]> wrote:
> 
>> I believe there's a way in PHP to get the URL of the page that called the
>> current page but can't find it.  Is there such a function?  Or would I have
>> to 
>> use another script (like Javascript)?
> 
> $_SERVER['HTTP_REFERER']
> 
> Kevin

But it's not ALWAYS set by the browser, so don't rely on it for anything
mission critical on your site.

Justin

--- End Message ---

Reply via email to