php-general Digest 22 Feb 2003 13:05:48 -0000 Issue 1898
Topics (messages 136577 through 136619):
ssi problem
136577 by: Hans Prins
Re: ob_gzhandler problems under 4.3.0???
136578 by: Gerard Samuel
Re: including in shtml
136579 by: Tom Rogers
136581 by: Hans Prins
136588 by: Matt Honeycutt
136590 by: Tom Rogers
136600 by: John W. Holmes
136602 by: Matt Honeycutt
136604 by: John W. Holmes
Re: Convert *.PST Files to Something Else (LDAP...)
136580 by: David T-G
Re: Logging Referer
136582 by: Justin French
136585 by: Matt Honeycutt
136594 by: Tom Rogers
preg_match question: locating unmatched HTML tags
136583 by: Andy Crain
136603 by: John W. Holmes
136615 by: Ernest E Vogelsinger
Re: Mysql DB connect failure
136584 by: Tom Rogers
Re: user registration system
136586 by: olinux
Array instead of Switch
136587 by: Chris
136593 by: David T-G
136596 by: David Otton
136598 by: John W. Holmes
136614 by: Markas
PHP Job Opening
136589 by: Chris
PHP running on Win 2000 and IIS
136591 by: Denis L. Menezes
136599 by: John W. Holmes
136612 by: Leo Spalteholz
Utah PHP User
136592 by: Ray Hunter
Re: "Constants" for dummies, please?
136595 by: Philip Olson
Re: passing variables to flash
136597 by: Lord Loh.
Re: MAC address user recognition?
136601 by: Larry Brown
Re: session expiration
136605 by: John W. Holmes
Re: Memory used by script...
136606 by: John W. Holmes
Re: selection in form-field
136607 by: John W. Holmes
cookie problem..
136608 by: Terry Lau
136616 by: Lord Loh.
dynamic website screenshot/screen capture
136609 by: olinux
136610 by: Justin French
MSSQL Stored procedure return values
136611 by: Leo Spalteholz
Re: Getting a Multiple Select Form Field's Value
136613 by: Markas
is_writable for a dir?
136617 by: David T-G
Problem with Arrays?
136618 by: Patrick Teague
136619 by: Ernest E Vogelsinger
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 ---
Could anyone please shed some light on the following issue?
I have a problem with including a "test.php" into a "test.shtml" and passing
a variable to the "test.shtml" which should be available and processed in
the "test.php"
the "test.php" document includes the following:
-----------------------------------------------------------
<?php
if ($HTTP_GET_VARS['theValue']) {
print $HTTP_GET_VARS['theValue'];
} else {
print"
<form method=\"GET\" action=\"test.shtml\">
<input type=\"text\" name=\"theValue\" size=\"20\">
<input type=\"submit\" value=\"Submit\" name=\"submit_button\">
</form>
";
}
?>
the "test.shtml" document includes the following:
-------------------------------------------------------------
<html>
<head>
<title>poll</title>
</head>
<body>
<!--#include virtual="test.php" -->
</body>
</html>
I've also tried using the POST method but I got an error stating that post
is not a valid method in shtml.
I have also considered a session variable but since a session needs to
initiated or continued before anything is output to the browser that wont
work (I think).
does anyone have a solution to get this to work?
thanks,
Hans
--- End Message ---
--- Begin Message ---
Thanks. Worked like a charm...
Jason Sheets wrote:
PHP is starting output buffering automatically for you and then you are
starting it in your script as well, that is why you are receiving the
message ob_gzhandler can not be used twice.
Use ob_get_level to check if output buffering is not already started.
<?php
// start output buffering if it is not already running
if (0 == ob_get_level()) {
ob_start('ob_gzhandler');
}
?>
You may want additional logic that checks to see if the output buffer
hander is ob_gzhandler.
Jsaon
--
Gerard Samuel
http://www.trini0.org:81/
http://test1.trini0.org:81/
--- End Message ---
--- Begin Message ---
Hi,
Saturday, February 22, 2003, 8:22:44 AM, you wrote:
HP> anyone?
HP> "Hans Prins" <[EMAIL PROTECTED]> schreef in bericht
HP> news:[EMAIL PROTECTED]
>> Hello,
>>
>> I have a problem with including a "test.php" into a "test.shtml" and
HP> passing
>> a variable to the "test.shtml" which should be processed in the "test.php"
>>
>> the "test.php" document includes the following:
>> -----------------------------------------------------------
>>
>> <?php
>>
>> if ($HTTP_GET_VARS['theValue']) {
>> print $HTTP_GET_VARS['theValue'];
>> } else {
>> print"
>> <form method=\"GET\" action=\"test.shtml\">
>> <input type=\"text\" name=\"theValue\" size=\"20\">
>> <input type=\"submit\" value=\"Submit\" name=\"submit_button\">
>> </form>
>> ";
>> }
>>
>> ?>
>>
>> the "test.shtml" document includes the following:
>> -------------------------------------------------------------
>>
>> <html>
>> <head>
>> <title>poll</title>
>> </head>
>> <body>
>> <!--#include virtual="test.php" -->
>> </body>
>> </html>
>>
>> I've also tried using the POST method but I got an error stating that post
>> is not a valid method in shtml.
>>
>> I have also considered a session variable but since a session needs to
>> initiated or continued before anything is output to the browser that wont
>> work (I think).
>>
>> does anyone have a solution to get this to work?
>>
>> thanks,
>> Hans
>>
>>
Why are you trying to mix shtml and php ?
--
regards,
Tom
--- End Message ---
--- Begin Message ---
Im trying to write a poll script that is easy to intergrate into other
documents of a site and thought that since shtml is a much used method, I
want to make it available.
"Hans Prins" <[EMAIL PROTECTED]> schreef in bericht
news:[EMAIL PROTECTED]
> Hello,
>
> I have a problem with including a "test.php" into a "test.shtml" and
passing
> a variable to the "test.shtml" which should be processed in the "test.php"
>
> the "test.php" document includes the following:
> -----------------------------------------------------------
>
> <?php
>
> if ($HTTP_GET_VARS['theValue']) {
> print $HTTP_GET_VARS['theValue'];
> } else {
> print"
> <form method=\"GET\" action=\"test.shtml\">
> <input type=\"text\" name=\"theValue\" size=\"20\">
> <input type=\"submit\" value=\"Submit\" name=\"submit_button\">
> </form>
> ";
> }
>
> ?>
>
> the "test.shtml" document includes the following:
> -------------------------------------------------------------
>
> <html>
> <head>
> <title>poll</title>
> </head>
> <body>
> <!--#include virtual="test.php" -->
> </body>
> </html>
>
> I've also tried using the POST method but I got an error stating that post
> is not a valid method in shtml.
>
> I have also considered a session variable but since a session needs to
> initiated or continued before anything is output to the browser that wont
> work (I think).
>
> does anyone have a solution to get this to work?
>
> thanks,
> Hans
>
>
--- End Message ---
--- Begin Message ---
If you figure out how to do this successfully, please share. I'm forced
to use SHTML for my error pages (404.shtml and whatnot), but I'd like to
get those to interact with PHP as well.
---Matt
-----Original Message-----
From: Hans Prins [mailto:[EMAIL PROTECTED]
Sent: Friday, February 21, 2003 8:30 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: including in shtml
Im trying to write a poll script that is easy to intergrate into other
documents of a site and thought that since shtml is a much used method,
I
want to make it available.
"Hans Prins" <[EMAIL PROTECTED]> schreef in bericht
news:[EMAIL PROTECTED]
> Hello,
>
> I have a problem with including a "test.php" into a "test.shtml" and
passing
> a variable to the "test.shtml" which should be processed in the
"test.php"
>
> the "test.php" document includes the following:
> -----------------------------------------------------------
>
> <?php
>
> if ($HTTP_GET_VARS['theValue']) {
> print $HTTP_GET_VARS['theValue'];
> } else {
> print"
> <form method=\"GET\" action=\"test.shtml\">
> <input type=\"text\" name=\"theValue\" size=\"20\">
> <input type=\"submit\" value=\"Submit\" name=\"submit_button\">
> </form>
> ";
> }
>
> ?>
>
> the "test.shtml" document includes the following:
> -------------------------------------------------------------
>
> <html>
> <head>
> <title>poll</title>
> </head>
> <body>
> <!--#include virtual="test.php" -->
> </body>
> </html>
>
> I've also tried using the POST method but I got an error stating that
post
> is not a valid method in shtml.
>
> I have also considered a session variable but since a session needs to
> initiated or continued before anything is output to the browser that
wont
> work (I think).
>
> does anyone have a solution to get this to work?
>
> thanks,
> Hans
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hi,
Saturday, February 22, 2003, 12:29:36 PM, you wrote:
HP> Im trying to write a poll script that is easy to intergrate into other
HP> documents of a site and thought that since shtml is a much used method, I
HP> want to make it available.
HP> "Hans Prins" <[EMAIL PROTECTED]> schreef in bericht
HP> news:[EMAIL PROTECTED]
>> Hello,
>>
>> I have a problem with including a "test.php" into a "test.shtml" and
HP> passing
>> a variable to the "test.shtml" which should be processed in the "test.php"
>>
>> the "test.php" document includes the following:
>> -----------------------------------------------------------
>>
>> <?php
>>
>> if ($HTTP_GET_VARS['theValue']) {
>> print $HTTP_GET_VARS['theValue'];
>> } else {
>> print"
>> <form method=\"GET\" action=\"test.shtml\">
>> <input type=\"text\" name=\"theValue\" size=\"20\">
>> <input type=\"submit\" value=\"Submit\" name=\"submit_button\">
>> </form>
>> ";
>> }
>>
>> ?>
>>
>> the "test.shtml" document includes the following:
>> -------------------------------------------------------------
>>
>> <html>
>> <head>
>> <title>poll</title>
>> </head>
>> <body>
>> <!--#include virtual="test.php" -->
>> </body>
>> </html>
>>
>> I've also tried using the POST method but I got an error stating that post
>> is not a valid method in shtml.
>>
>> I have also considered a session variable but since a session needs to
>> initiated or continued before anything is output to the browser that wont
>> work (I think).
>>
>> does anyone have a solution to get this to work?
>>
>> thanks,
>> Hans
>>
>>
POST won't work easily with .shtml files so you are limited to GET and its
length limitations but the following works for me:
//test.php
<?php
if(isset($_SERVER['QUERY_STRING_UNESCAPED'])){
parse_str($_SERVER['QUERY_STRING_UNESCAPED']);
if(!empty($theValue)){
echo 'Value = '.stripslashes($theValue).'<br>';
}
}
print'
<form method="get" action="test.shtml">
<input type="text" name="theValue" size="20">
<input type="submit" value="Submit" name="submit_button">
</form>
';
?>
(parse string seems to like adding slashes)
To use post you will have to post to a .php file to do the processing and
redirect to the .shtml file.
--
regards,
Tom
--- End Message ---
--- Begin Message ---
> If you figure out how to do this successfully, please share. I'm
forced
> to use SHTML for my error pages (404.shtml and whatnot), but I'd like
to
> get those to interact with PHP as well.
Most any web server will allow you to set a URL as the error handler, so
you can have it as a PHP page. Is there a specific reason why you can't?
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
--- End Message ---
--- Begin Message ---
I'll check, but I'm pretty sure my host only allows me to edit the
existing *.shtml files to customize my error pages. I don't think it
will allow me to set the error pages to different URL's.
---Matt
-----Original Message-----
From: John W. Holmes [mailto:[EMAIL PROTECTED]
Sent: Friday, February 21, 2003 11:45 PM
To: 'Matt Honeycutt'; [EMAIL PROTECTED]
Subject: RE: [PHP] Re: including in shtml
> If you figure out how to do this successfully, please share. I'm
forced
> to use SHTML for my error pages (404.shtml and whatnot), but I'd like
to
> get those to interact with PHP as well.
Most any web server will allow you to set a URL as the error handler, so
you can have it as a PHP page. Is there a specific reason why you can't?
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
--- End Message ---
--- Begin Message ---
> anyone?
Do you want everyone on the list to send you a message saying they're
not sure what to do?? Just be patient and if someone has an idea,
they'll let you know.
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
>
> "Hans Prins" <[EMAIL PROTECTED]> schreef in bericht
> news:[EMAIL PROTECTED]
> > Hello,
> >
> > I have a problem with including a "test.php" into a "test.shtml" and
> passing
> > a variable to the "test.shtml" which should be processed in the
> "test.php"
> >
> > the "test.php" document includes the following:
> > -----------------------------------------------------------
> >
> > <?php
> >
> > if ($HTTP_GET_VARS['theValue']) {
> > print $HTTP_GET_VARS['theValue'];
> > } else {
> > print"
> > <form method=\"GET\" action=\"test.shtml\">
> > <input type=\"text\" name=\"theValue\" size=\"20\">
> > <input type=\"submit\" value=\"Submit\" name=\"submit_button\">
> > </form>
> > ";
> > }
> >
> > ?>
> >
> > the "test.shtml" document includes the following:
> > -------------------------------------------------------------
> >
> > <html>
> > <head>
> > <title>poll</title>
> > </head>
> > <body>
> > <!--#include virtual="test.php" -->
> > </body>
> > </html>
> >
> > I've also tried using the POST method but I got an error stating
that
> post
> > is not a valid method in shtml.
> >
> > I have also considered a session variable but since a session needs
to
> > initiated or continued before anything is output to the browser that
> wont
> > work (I think).
> >
> > does anyone have a solution to get this to work?
> >
> > thanks,
> > Hans
--- End Message ---
--- Begin Message ---
Michael --
...and then Michael A Smith said...
%
% Hi,
Hi!
%
% Is there any way using PHP (or any thing else, preferably PHP) to
% convert a MS Outlook *.PST file to another file that would be usable by
Converting from Outhouse comes up a lot on the mutt-users list. To date
the only thing of which I know that will do it is Netscape, and therefore
presumably Mozilla; NS has an import function. You might pull down the
Moz source code and start reading :-)
HTH & HAND & Good luck
:-D
--
David T-G * There is too much animal courage in
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED] -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!
pgp00000.pgp
Description: PGP signature
--- End Message ---
--- Begin Message ---
on 22/02/03 10:19 AM, Matt Honeycutt ([EMAIL PROTECTED]) wrote:
> I'd also like for it to log the referer,
> but because the counter is triggered via an <img> tag, the referer is always
> the page that has the <img> tag. Is there any other way to grab the referer
> that actually sent the user to the page that contains the counter? I'd like
> for the counter to work even when included in static HTML pages, so the
> including page cannot use any PHP to help facilitate this logging
> functionality.
No, not easily :)
On PHP pages, you could get the referrer, and append it to the URL, forcing
the "correct" REFERRER through to the img script:
<img src="makeMyCounter.php?ref=<?=$_SERVER['HTTP_REFERRER']?>">
And you *could* choose to force .html files through the PHP parser, so
foo.html could use the above code.
I think the other alternative is to use javascript to build the img tag,
because I'm pretty sure JS can figure out the referrer.
But this has the obvious downside of JS being NO WHERE NEAR guaranteed to be
on each browser.
I think i'm missing something though, because I *think* those free
counter/stat programs DO log a referrer... wait -- just checked
thecounter.com, and they DO use JS for the referrer.
Justin
--- End Message ---
--- Begin Message ---
Yeah, I had thought about using JavaScript. I had hoped that there was
another way, but if there is, I can't figure it out.
---Matt
-----Original Message-----
From: Justin French [mailto:[EMAIL PROTECTED]
Sent: Friday, February 21, 2003 8:37 PM
To: Matt Honeycutt; Php-General
Subject: Re: [PHP] Logging Referer
on 22/02/03 10:19 AM, Matt Honeycutt ([EMAIL PROTECTED]) wrote:
> I'd also like for it to log the referer,
> but because the counter is triggered via an <img> tag, the referer is
always
> the page that has the <img> tag. Is there any other way to grab the
referer
> that actually sent the user to the page that contains the counter?
I'd like
> for the counter to work even when included in static HTML pages, so
the
> including page cannot use any PHP to help facilitate this logging
> functionality.
No, not easily :)
On PHP pages, you could get the referrer, and append it to the URL,
forcing
the "correct" REFERRER through to the img script:
<img src="makeMyCounter.php?ref=<?=$_SERVER['HTTP_REFERRER']?>">
And you *could* choose to force .html files through the PHP parser, so
foo.html could use the above code.
I think the other alternative is to use javascript to build the img tag,
because I'm pretty sure JS can figure out the referrer.
But this has the obvious downside of JS being NO WHERE NEAR guaranteed
to be
on each browser.
I think i'm missing something though, because I *think* those free
counter/stat programs DO log a referrer... wait -- just checked
thecounter.com, and they DO use JS for the referrer.
Justin
--- End Message ---
--- Begin Message ---
Hi,
Saturday, February 22, 2003, 9:19:13 AM, you wrote:
MH> Hi all,
MH> I'm working on adding some logging functionality to a PHP image counter
MH> script that I wrote. The counter outputs an image representing the current
MH> number of hits and is used via an <img> tag. After it displays the image,
MH> the counter collects information about the user (browser version and OS,
MH> date and time of visit, ip, etc). I'd also like for it to log the referer,
MH> but because the counter is triggered via an <img> tag, the referer is always
MH> the page that has the <img> tag. Is there any other way to grab the referer
MH> that actually sent the user to the page that contains the counter? I'd like
MH> for the counter to work even when included in static HTML pages, so the
MH> including page cannot use any PHP to help facilitate this logging
MH> functionality.
MH> I hope all that makes sense.
MH> Anyone have any suggestions on how to achieve what I'm after?
MH> ---Matt
Probably the only way is with javascript..I did this a while back (php v2 :)
<!-- Start of Counter Code -->
<SCRIPT><!--
NS2=0
f=""+escape(document.referrer)
if (f == ""){f="unknown"}
function prnt(n) {document.write(n,"\n");}
if (navigator.appName == "Netscape" && navigator.appVersion.charAt(0) == "2") {NS2=1}
if (NS2 == 0) {r=f+"+9";prnt("<IMG BORDER=0
SRC=\"http://domain.com.au/stats/invisman.phtml?"+r+"\">")}
//--></SCRIPT>
<NOSCRIPT>
<IMG SRC="http://domain.com.au/stats/invisman.phtml?unknown+9" BORDER=0></A>
</NOSCRIPT>
<!-- End of Counter Code -->
(the +9 was a page id, invisman.phtml returned a transparent gif)
--
regards,
Tom
--- End Message ---
--- Begin Message ---
My apologies in advance if this too basic or there's a solution easily
found out there, but after lots of searching, I'm still lost.
I'm trying to build a regexp that would parse user-supplied text and
identify cases where HTML tags are left open or are not properly
matched-e.g., <b> tags without closing </b> tags. This is for a sort of
message board type of application, and I'd like to allow users to use
some HTML, but just would like to check to ensure that no stray tags are
input that would screw up the rest of the page's display. I'm new to
regular expressions, and the one below is as far as I've gotten. If
anyone has any suggestions, they'd be very much appreciated.
Thanks,
Andy
$suspect_tags = "b|i|u|strong|em|font|a|ol|ul|blockquote ";
$pattern = '/<(' . $suspect_tags . '[^>]*>)(.*)(?!<\/\1)/Ui';
if (preg_match($pattern,$_POST['entry'],$matches)) {
//do something to report the unclosed tags
} else {
echo 'Input looks fine. No unmatched tags.';
}
--- End Message ---
--- Begin Message ---
> I'm trying to build a regexp that would parse user-supplied text and
> identify cases where HTML tags are left open or are not properly
> matched-e.g., <b> tags without closing </b> tags. This is for a sort
of
> message board type of application, and I'd like to allow users to use
> some HTML, but just would like to check to ensure that no stray tags
are
> input that would screw up the rest of the page's display. I'm new to
> regular expressions, and the one below is as far as I've gotten. If
> anyone has any suggestions, they'd be very much appreciated.
Letting users enter HTML is a bad idea. Even if you only let them use
<b> tags, they can still put ONCLICK and mouseover effects for the bold
text to screw with your other users.
Use a BB style code, such as [b] for bold, [i] for italics, etc. This
way, you only match pairs and replace them with HTML and use
htmlentities on anything else. This way an unmatched [b] tag won't be
replaced with <b> and mess up your code.
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
--- End Message ---
--- Begin Message ---
At 03:35 22.02.2003, Andy Crain said:
--------------------[snip]--------------------
>My apologies in advance if this too basic or there's a solution easily
>found out there, but after lots of searching, I'm still lost.
>
>I'm trying to build a regexp that would parse user-supplied text and
>identify cases where HTML tags are left open or are not properly
>matched-e.g., <b> tags without closing </b> tags. This is for a sort of
>message board type of application, and I'd like to allow users to use
>some HTML, but just would like to check to ensure that no stray tags are
>input that would screw up the rest of the page's display. I'm new to
>regular expressions, and the one below is as far as I've gotten. If
>anyone has any suggestions, they'd be very much appreciated.
>
>$suspect_tags = "b|i|u|strong|em|font|a|ol|ul|blockquote ";
>$pattern = '/<(' . $suspect_tags . '[^>]*>)(.*)(?!<\/\1)/Ui';
>if (preg_match($pattern,$_POST['entry'],$matches)) {
> //do something to report the unclosed tags
>} else {
> echo 'Input looks fine. No unmatched tags.';
>}
--------------------[snip]--------------------
Hi,
I don't believe you can create a regular expression to look for something
that's NOT there.
I'd take this approach (tested with drawbacks, see below):
function check_tags($text) {
$suspect_tags = "b|i|u|strong|em|font|a|ol|ul|blockquote";
$re_find = '/<\s*(' . $suspect_tags . ').*?>(.*)/is';
while (preg_match($re_find,$text,$matches)) {
// a suspect tag was found, check if closed
$suspect = $matches[1];
$text = $matches[2];
$re_close = '/<\s*\/\s*' . $suspect . '\s*?>(.*)/is';
if (preg_match($re_close, $text, $matches)) {
// fine, found matching closer, continue loop
$text = $matches[1];
}
else {
// not closed - return to report it
return $suspect;
}
}
return null;
}
$text = <<<EOT
This text contains < font
size=+4 > an
unclosed suspect </fint>tag.
EOT;
$tag = check_tags($text);
if ($tag) echo "Unmatched: \"$tag\"\n";
else echo "Perfect!\n";
The drawbacks: This approach is softly targeted at unintended typos, such
as in the example text. It won't catch deliberate attacks, such as
Blindtext <font color="red><font size=+22>Hehe I've got you</font>
because it is missing the second font opener. To catch these attacks you'd
need to build a source tree of the text in question.
HTH,
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/
--- End Message ---
--- Begin Message ---
Hi,
Saturday, February 22, 2003, 2:26:35 AM, you wrote:
M> I see that its looking for mysql.sock in /tmp/mysql.sock
M> but I searched on my system and only found mysql.sock in /var/lib/mysql/
M> is there a section where I need to change this setting? or a conf file?
M> "Hans Prins" <[EMAIL PROTECTED]> wrote in message
M> news:[EMAIL PROTECTED]
>> > Would you care to explain to the rest of the list how you intend to use
>> > mysql_error () to return connection failure information?
>> >
>> > It returns the text of the error message from previous MySQL operation
>> > Description: string mysql_error ( [resource link_identifier])
>> >
>> > Seems to me that without a connection, we wouldn't have a valid
>> > link_identifier.
>>
>> maybe so, but it works nonetheless.............
>>
>> if for example the username stated in the connection initialization was
>> wrong it will print an error like:
>>
>> "Access denied for user: '[EMAIL PROTECTED]' (Using password: YES)"
>>
>> MI,
>>
>> my code would look somethign like this:
>>
>> $link = @mysql_pconnect("localhost", "test1", "test1");
>>
>> // If connection failed...
>> if (!$link) {
>> // Inform user of error and quit
>> print "Couldn't connect to database server<br>\n";
>> print mysql_error();
>> exit;
>> }
>>
>>
>>
>> "Jason K Larson" <[EMAIL PROTECTED]> schreef in bericht
>> news:[EMAIL PROTECTED]
>> > Would you care to explain to the rest of the list how you intend to use
>> > mysql_error () to return connection failure information?
>> >
>> > It returns the text of the error message from previous MySQL operation
>> > Description: string mysql_error ( [resource link_identifier])
>> >
>> > Seems to me that without a connection, we wouldn't have a valid
>> > link_identifier.
>> >
>> > What you probably should attempt going for is getting something back
>> > from PHP itself regarding the error returned when the mysql_connect
>> failed.
>> >
>> > Here's a snippet from:
>> > http://www.php.net/manual/en/language.operators.errorcontrol.php
>> >
>> > If the track_errors feature is enabled, any error message generated by
>> > the expression will be saved in the global variable $php_errormsg. This
>> > variable will be overwritten on each error, so check early if you want
>> > to use it.
>> >
>> > Hope that clears things up a bit.
>> >
>> > Regards,
>> > Jason k Larson
>> >
>> >
>> >
>> > Hans Prins wrote:
>> > > did you try:
>> > > print mysql_error();
>> > >
>> > > "Ml" <[EMAIL PROTECTED]> schreef in bericht
>> > > news:[EMAIL PROTECTED]
>> > >
>> >
>> >
>>
>>
In php.ini
mysql.default_socket = /var/lib/mysql/mysql.sock
--
regards,
Tom
--- End Message ---
--- Begin Message ---
this is decent
A Complete, Secure User Login System
by tim perdue
http://phpbuilder.com/columns/tim20000505.php3
and of course - hotscripts.com
--- Dennis Gearon <[EMAIL PROTECTED]> wrote:
> Anybody know of a good user registration system,
> using emailed web addresses for verification of
> email address?
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/
--- End Message ---
--- Begin Message ---
Let's say I need to take one of 20 actions depending on a form selection. I
could use a switch statement with 20 cases, but I could also do something
like:
// Pretend this comes from a form
$formchoice = "mars";
$response = array(
"mars" => "go_mars()",
"mercury" => "go_mercury()",
"earth" => "go_earth()");
foreach ($response as $choice => $action)
{
if (strtoupper($formchoice) == strtoupper($choice))
{
eval("$action;");
}
}
But are there even better ways?
--- End Message ---
--- Begin Message ---
Chris, et al --
...and then Chris said...
%
% Let's say I need to take one of 20 actions depending on a form selection. I
% could use a switch statement with 20 cases, but I could also do something
% like:
%
% // Pretend this comes from a form
% $formchoice = "mars";
%
%
% $response = array(
% "mars" => "go_mars()",
% "mercury" => "go_mercury()",
% "earth" => "go_earth()");
%
% foreach ($response as $choice => $action)
% {
% if (strtoupper($formchoice) == strtoupper($choice))
% {
% eval("$action;");
% }
% }
%
% But are there even better ways?
I'm just pulling this out of my ear, but assuming the structure you gave
what about a simple
eval("$response[$formchoice];") ;
to match if it matches and do nothing if it doesn't? In fact, I got
curious, so here is some test code I just whipped up; note that when the
choice is 'comet' nothing happens.
function go_mars()
{ print "Welcome to mars, dude!\n" ; }
$formchoice = "comet" ;
$response = array
(
"mars" => "go_mars()" ,
"mercury" => "go_mercury()" ,
// continue ad nauseam
) ;
print "Will we eval?\n" ;
eval ("$response[$formchoice];") ;
print "DONE!\n" ;
Seems like this ought to be pretty safe since you're writing the go_*
functions and otherwise nothing matches and you eval a "".
HTH & HAND
:-D
--
David T-G * There is too much animal courage in
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED] -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!
pgp00001.pgp
Description: PGP signature
--- End Message ---
--- Begin Message ---
On 22 Feb 2003 03:28:22 -0000, you wrote:
>Let's say I need to take one of 20 actions depending on a form selection. I
>could use a switch statement with 20 cases, but I could also do something
>like:
>
>// Pretend this comes from a form
>$formchoice = "mars";
>
>
>$response = array(
> "mars" => "go_mars()",
> "mercury" => "go_mercury()",
> "earth" => "go_earth()");
>
>foreach ($response as $choice => $action)
>{
> if (strtoupper($formchoice) == strtoupper($choice))
> {
> eval("$action;");
> }
>}
>
>But are there even better ways?
$formchoice = "mars";
go_planet ($formchoice);
Keep the high-levels of the script as simple as possible, push the
complexity down into functions where it's hidden from view.
Maybe go_planet() just calls go_mercury(), go_venus(), etc., or, more
likely, there's enough shared-functionality for only go_planet() to be
necessary.
Either way, you've replaced 11 lines in the main body of your script
with 1 line, and the next person to deal with your code will be
grateful.
[An OO programmer would probably create a planet object...
myPlanet = new Planet()
myPlanet.setType($formchoice)
or something, with the same end (hiding complexity) in mind.]
--- End Message ---
--- Begin Message ---
> >Let's say I need to take one of 20 actions depending on a form
selection.
> I
> >could use a switch statement with 20 cases, but I could also do
something
> >like:
> >
> >// Pretend this comes from a form
> >$formchoice = "mars";
> >
> >
> >$response = array(
> > "mars" => "go_mars()",
> > "mercury" => "go_mercury()",
> > "earth" => "go_earth()");
> >
> >foreach ($response as $choice => $action)
> >{
> > if (strtoupper($formchoice) == strtoupper($choice))
> > {
> > eval("$action;");
> > }
> >}
> >
> >But are there even better ways?
You know you can use a variable as the name of a function??
So, if you had the functions mars(), mercury() and venus(), and you had
$formchoice = 'mars';
You can just call
$formchoice();
and it'll be just like calling mars(). It works the same for the other
functions. You'll still want to validate it so you know it's calling on
of the functions you want called. A simple array with valid planets and
a call to in_array will solve that.
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
--- End Message ---
--- Begin Message ---
"David Otton" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On 22 Feb 2003 03:28:22 -0000, you wrote:
>
> >Let's say I need to take one of 20 actions depending on a form selection.
I
> >could use a switch statement with 20 cases, but I could also do something
> >like:
> >
> >// Pretend this comes from a form
> >$formchoice = "mars";
> >
> >
> >$response = array(
> > "mars" => "go_mars()",
> > "mercury" => "go_mercury()",
> > "earth" => "go_earth()");
> >
> >foreach ($response as $choice => $action)
> >{
> > if (strtoupper($formchoice) == strtoupper($choice))
> > {
> > eval("$action;");
> > }
> >}
> >
> >But are there even better ways?
>
> $formchoice = "mars";
>
> go_planet ($formchoice);
>
> Keep the high-levels of the script as simple as possible, push the
> complexity down into functions where it's hidden from view.
>
> Maybe go_planet() just calls go_mercury(), go_venus(), etc., or, more
> likely, there's enough shared-functionality for only go_planet() to be
> necessary.
>
> Either way, you've replaced 11 lines in the main body of your script
> with 1 line, and the next person to deal with your code will be
> grateful.
:) I think if You use go_planet($choice), the problem will still remain,
bacause that "big switch" should reside in go_planet() func, so we come to
the start of the problem. (of course if we should take different actions
depending on the choice).
I think the one way is like described in upper message, to use variable
names of functions. Ok, that's nice, but I personally wouldnt use this as it
is very language specific (of course we could regard it like pointers to
funcs in C :)), and I think doing many such tricks of this increases the
complexity of your code and so on.
I'd use OO principals for that, making an object for each planet, and each
shoud have a method like go_planet() for THIS particular planet, as they all
this objects would inplement the interface with the same method (of course u
may not do that inheritance in PHP explicitely), So u'd have smth like this:
$response = array(
> > "mars" => object, //mars object
> > "mercury" => object, //mercury object
> > "earth" => " object, //earthobject
and if your choice is "mars", u'd call $response['mars']->go_planet();
Its a known OO principal for avoiding switch'es and if's, and PHP is a nice
OO style language, so doing in OO like this should give valuable practice
for migrating to any other "real" OO language.
Sorry, if wrong,
Mark.
--- End Message ---
--- Begin Message ---
http://www.alaska.edu/hr/jobs/external/tmp19_3.xml
--- End Message ---
--- Begin Message ---
Hello friends,
I wish to run PHP on a Win 2000 server, MS SQL and IIS. Can someone please guide me to
some place where there are some tutorials on how to install and run the above?
Also are there any problems by running PHp on Win 2000, MS SQL and IIS?
Thanks
Denis
--- End Message ---
--- Begin Message ---
> I wish to run PHP on a Win 2000 server, MS SQL and IIS. Can someone
please
> guide me to some place where there are some tutorials on how to
install
> and run the above?
The PHP manual has an installation channel the works.
> Also are there any problems by running PHp on Win 2000, MS SQL and
IIS?
Not that I've noticed. I use all that except for MSSQL, thankfully.
---John Holmes...
--- End Message ---
--- Begin Message ---
For help with getting MSSQL to work with php, check the comments for
the mssql_execute and mssql_bind functions in the online php manual.
You need some extra dlls.
Leo
On February 21, 2003 09:43 pm, John W. Holmes wrote:
> > I wish to run PHP on a Win 2000 server, MS SQL and IIS. Can
> > someone
>
> please
>
> > guide me to some place where there are some tutorials on how to
>
> install
>
> > and run the above?
>
> The PHP manual has an installation channel the works.
>
> > Also are there any problems by running PHp on Win 2000, MS SQL
> > and
>
> IIS?
>
> Not that I've noticed. I use all that except for MSSQL, thankfully.
>
> ---John Holmes...
--- End Message ---
--- Begin Message ---
I am thinking of starting a Utah PHP user group.
If there are any Utah php user out there, please let me know if you
would be interested in starting a user group for PHP.
Thanks,
Ray
--- End Message ---
--- Begin Message ---
Some thoughts on variables and constants:
a) You can't redefine a constant but can redefine
a variable.
b) Constants are autoglobal (like superglobals) so
for example:
<?php
define ('CONSTANT', 'some value');
$variable = 'some value';
function foo() {
global $variable;
print $variable;
print CONSTANT;
}
foo();
?>
Had we not used global $variable, the $variable
would not have been available inside the function.
But, the constant is AUTOglobal so it is. Read:
Variable Scope:
http://www.php.net/variables.scope
c) Constants must be scalar values in PHP4, (so
not arrays, objects, or resources).
d) Constants are cool, variables are cool too.
Regards,
Philip Olson
On Fri, 21 Feb 2003, Chris Corwin wrote:
> Help, please -- I've just started looking at my first line of PHP code.
>
> :)
>
>
> A little background, I am *not really* a programmer: I went to art
> school.
>
> I have taught myself to develop web stuff in another language: Lasso,
> but have no training.
>
> In any case, I am looking through a php script that I've downloaded,
> and most of it makes at least some sense to me, but I have come upon:
>
> <?php
>
> define('BASE', './');
> include(BASE.'Functions/foo.php');
> ?>
>
>
> Now, like any good lister, I checked the source first: php.net
>
> <http://www.php.net/manual/en/language.constants.php> says:
>
> "A constant is a identifier (name) for a simple value. As the name
> suggests, that value cannot change during the execution of the script
> (except the magic constants which aren't actually constants). A
> constant is case-sensitive by default. By convention constant
> identifiers are always uppercase.
>
> [...]
>
> The scope of a constant is global--you can access it anywhere in your
> script without regard to scope."
>
>
>
>
> So it is apparently *similar*, but not *exactly like* a variable, right?
>
> Can anyone explain the difference to me?
>
> A particular question I have is about what this phrase means:
>
> "The scope of a constant is global--you can access it anywhere in your
> script without regard to scope."
>
>
>
> When it says "anywhere in your script" does that mean it's available to
> "all of PHP"?
>
> Or it is global to the rest of the file currently being processed,
> regardless of namespace, unlike a "normal" variable which might be
> unavailable in certain namespaces in the file?
>
> Also, if anyone knows the subtleties of how any such differences effect
> the rest of the script, that'd be wonderful, too.
>
>
> Thanks for any help!
>
> - me
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
See the flash docs. There are ways of making javascript and flash interact.
So make a dynamically generated javascript which will pass variable to
flash!
Or are there special reasonds to use only GET ?
Lord Loh.
--- End Message ---
--- Begin Message ---
One other thing you could do is simply set up SSL with your own certificate
so that it will encrypt the connection and then run code via JAVA or some
other client side applet that will get the MAC address from the client
machine directly. You can then check the MAC against the addresses allowed.
Since the connection is encrypted nobody knows that that is what you are
checking. Of course there is still a potential for someone that you
previously allowed access to find out how you are identifying them and use
it against you later on, but there are also problems with identifying
someone by their computer unless they keep the computer locked in a closet
while they are away. I guess it depends on what you are protecting.
National secrets etc. By the way, open SSL with self signed certs is a free
method but it is not a good idea if you are needing to verify your
credentials to the person coming in.
Larry S. Brown
Dimension Networks, Inc.
(727) 723-8388
-----Original Message-----
From: Leo Spalteholz [mailto:[EMAIL PROTECTED]
Sent: Friday, February 21, 2003 12:59 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] MAC address user recognition?
On February 20, 2003 08:13 pm, Jason Sheets wrote:
> MAC addresses are used for on a LAN and not the Internet. Using a
> MAC address might work for identification on a LAN BUT in most
> operating systems you can easily change the effective MAC address
> on the card.
Good call. I thought there was some fundemental problem I just
couldn't remember enough from my networking class to put my finger on
it.
> It would probably be better to look for some other form of
> identification like SSL certificates or a cookie with the secure
> bit on so it will only be sent over an SSL connection.
Yeah I'm not super concerned about security and such, this is only a
personal page so something simple will do the job. I think I'll just
end up hacking together my own encryption algorithm and then storing
encrypted passwords in a cookie.
Hehe. Security through obscurity, everyones favorite way :)
Thanks,
Leo
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
> >> I'm using sessions for authentication in a content management
system
> and
> >> experiencing rare but occasional problems with the session
apparently
> >> expiring unexpectedly. I've checked the manual and I've reviewed
the
> > session
> >> configuration on the commericial host I'm using. I don't see
anything
> > wrong,
> >> but there are some settings that I don't understand:
> >>
> >> session.gc_maxlifetime 1440 -- Garbage collection after 24 minutes?
> Does
> >> this mean that the session id and session variables will be cleared
> after
> > 24
> >> minutes of inactivity? (Surely not; that doesn't make sense.) And
> cleared
> >> from where, the directory specified in session.save_path?
> >
> > Yes and Yes. After 1440 seconds of not being accessed, they are
deleted
> the
> > next time the garbage collection routine is ran.
>
> So how did my tests of going up to 2 hours without activity succeed?
Like I said, it's a probability thing. Garbage collection has a 1%
chance of being iniated. It may take two hours for that 1% chance to hit
and clean up any data that's over 1440 seconds old. Other times, it may
hit it a couple times in a row quickly, so you lose your data very close
to 1440 seconds.
[snip]
> > Another option would be to use session_save_path() within your
> application
> > to save the session files to a separate directory that's writable by
the
> web
> > server. Since this directory is different from session.save_path
> specified
> > in php.ini, garbage collection will never occur, so the files will
not
> be
> > deleted.
>
> This seems like the answer I was looking for. So the setting
> session.gc_maxlifetime only relates to garbage collection from the
/tmp
> directory? If I use session_save_path() to define a different
directory
> for
> saving session data, then garbage collection will never occur for that
> directory?
Garbage collection is only triggered in the directory identified by
session.save_path, whatever it is. If you change it to something else in
your code, it's not affected by garbage collection.
> > Why not just use a cookie to "remember me" though, instead of
keeping
> the
> > sessions persistant? You're going to end up with a file on your
computer
> for
> > _every_ person that visits the site and the file will not go away.
Seems
> > like it'd be better to just use a cookie and load their data if it's
not
> > already present, like on their first visit.
>
> This is for a content management system, with less than 10 people
> authorized
> to access it, so I don't see the number of session files as a problem.
Have fun!
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
--- End Message ---
--- Begin Message ---
> Hi... I got a big site, which is not very well constructed inside, and
the
> script began to throw (rather often, but NOT always) a fatal error "
Fatal
> error: Allowed memory size of 8388608 bytes exhausted ", every time in
> different places. I wonder how should I debug that, as there is pretty
> much
> code inside, and I hardly got aqcuainted with it in a whole.
>
> SO THE QUESTION: Are there any functions or smth., to check, how much
> memory
> is used at some particular moment of execution of the script??? If I
could
> state, that for example after some class instantiaton memory usage
greatly
> increases, I would be able to localise the problem.
I remember asking about this a while ago. There were no answers. I don't
think there's any way for PHP to monitor it. Some web servers will store
the total amount of memory your script took up. So if you parse those
logs you may get the info you need.
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
--- End Message ---
--- Begin Message ---
Client side issue. Use javascript or DHTML.
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
> -----Original Message-----
> From: Michiel van Heusden [mailto:[EMAIL PROTECTED]
> Sent: Friday, February 21, 2003 4:47 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] selection in form-field
>
> i have quite an easy question:
>
> is there a way in PHP to trace the selection in a certain form-field?
> i need this for building a simple html-edit application,
> which allows a user to select his/her text within a field, and then
click
> 'bold' for instance..the PHP should insert <b> before the selection,
and
> </b> after the selection.
>
> 1) should i use PHP or is this a typical JavaScript-thing? (or a
> combination?)
> 2) if you could help with a function or small script I would me most
> grateful
>
> grace
> michiel
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hello,
I want to set a cookie when I enter a text into the text field, and it
shows the text I submitted immediately, thus I write a sample php code like
this:
<?php
if (isset($HTTP_POST_VARS['Name'])) {
setcookie("name", $HTTP_POST_VARS['Name'], time()+86400*10);
}
echo $name;
?>
(I set the text field is Name and the data will be sent to another page)
In another page, I insert <?php echo $HTTP_COOKIE_VARS['name']; ?> in the
beginning of the code.
Is the code right?
Then I run the test, I enter a name into the text field and submit it. But
it shows "Notice: Undefined index: name in ..", it can't show the name I
submitted.
Why?Anything wrong??
Thanks!!
Terry
_________________________________________________________________
今日星座 http://www.msn.com.hk/fortune/west/ 運程
--- End Message ---
--- Begin Message ---
Cookies are loaded the next time the page is loaded. So you may have to
refresh the page to see the cookie...
or
Submit to a html page which will redirect to the page which shows cookie
value...
Hope this helps...This should work...
Lord Loh
--- End Message ---
--- Begin Message ---
Hi all -
While I know that this is not possible with PHP alone,
Does anyone know how to capture website screen shots
using PHP. I have recieved many spam mails featuring a
screen shot of our company website and I imagine that
it would be quite possible combined with some sort of
web browser.
It would be great for a couple projects I'm working on
to use this in the same style as alexa.com. (featuring
screenshots next to search results.).
thanks for any info!
olinux
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/
--- End Message ---
--- Begin Message ---
on 22/02/03 5:55 PM, olinux ([EMAIL PROTECTED]) wrote:
> Hi all -
> While I know that this is not possible with PHP alone,
> Does anyone know how to capture website screen shots
> using PHP. I have recieved many spam mails featuring a
> screen shot of our company website and I imagine that
> it would be quite possible combined with some sort of
> web browser.
I doubt PHP will have anything to do with it... My guess is there MUST be
some form of automation/macro tool available on Windows or Linux, which
enables you to load a URL in a browser, and take a screen shot. I get the
feeling it could also be done with AppleScript on the Mac.
Afterall, PHP, Perl, etc aren't a browser. But it's possible that PHP can
trigger a command-line program to do the above.
Justin French
--- End Message ---
--- Begin Message ---
Hi,
I'm doing a small project at work with php, ms sql server on w2k IIS5.
All the data access is done through stored procedures. This seems to
be working fine, the record sets are returned and the stored
procedures execute without error however I can't get any return
values from them.
For example I have the following php code:
// setup stored procedure
$sp = mssql_init("spGetReseller", $conObj);
mssql_bind($sp, "@ResellerID", $loginID, SQLINT4, FALSE);
mssql_bind($sp, "@ReturnCode", &$retVal, SQLINT4, TRUE);
$rs = mssql_execute($sp);
So the @ReturnCode variable is defined as OUTPUT in the SP and I am
passing in $retVal by reference. This is my stored procedure.
ALTER PROCEDURE spGetReseller
@ResellerID int
, @ReturnCode int OUTPUT
AS
SELECT Something
FROM SomeTable
WHERE SomeField = 1
-- set return code
IF @@ROWCOUNT > 0
SET @ReturnCode = 0
ELSE
SET @ReturnCode = 1
This should set the returncode to be 1 if there are no rows returned.
However no matter what, it will never get this returncode from the
stored procedure. (ie $retVal will not be changed by the mssql_bind
function) I ran the stored procedure and the @returnCode variable is
set correctly there so that isn't the problem.
Does anyone know what could be the problem there? I guess I could
return @ReturnCode in the recordset but that would be kinda hokey.
Thanks,
Leo
--- End Message ---
--- Begin Message ---
Just replace the name of your <select> element to "select[]" , and you'll
get all the selected values as a php array under the name of
$_GET['select'].
"Mike Walth" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello:
>
> I'm trying to get the value from the following form field.
>
> <select name="select" size="3" multiple>
> <option value="1">Value1</option>
> <option value="2">Value2</option>
> <option value="3">Value3</option>
> </select>
>
> I can get it to return one value, but if I select multiple values I can't
> get all the values form it. Any ideas would be appreciated.
>
> Mike Walth
> CinoFusion
>
>
--- End Message ---
--- Begin Message ---
Hi, all --
How can I tell if a directory is writable? It seems that is_writable
only works on file, and the mode I get out of stat() is [in this case,
anyway] '16895' for a 0777 dir.
TIA & HAND
:-D
--
David T-G * There is too much animal courage in
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED] -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!
pgp00002.pgp
Description: PGP signature
--- End Message ---
--- Begin Message ---
I ran into something interesting & the only thing I can figure out is that
functions won't use any variables other than globals, those past to the
function, or those created inside the function?
here's what I had that didn't print anything other than 3 blank lines for
this section of code -
$byteSize[0] = "bytes";
$byteSize[1] = "kb";
$byteSize[2] = "mb";
function getMaxSize( $maxSize )
{
echo $byteSize[0] . "<br/>\n";
echo $byteSize[1] . "<br/>\n";
echo $byteSize[2] . "<br/>\n";
....
}
but, if I put the array inside the function it would actually work -
function getMaxSize( $maxSize )
{
$byteSize[0] = "bytes";
$byteSize[1] = "kb";
$byteSize[2] = "mb";
echo $byteSize[0] . "<br/>\n";
echo $byteSize[1] . "<br/>\n";
echo $byteSize[2] . "<br/>\n";
....
}
what's up with this? Maybe I'm just up way to late again.
Patrick
--- End Message ---
--- Begin Message ---
At 13:46 22.02.2003, Patrick Teague said:
--------------------[snip]--------------------
>here's what I had that didn't print anything other than 3 blank lines for
>this section of code -
>
>$byteSize[0] = "bytes";
>$byteSize[1] = "kb";
>$byteSize[2] = "mb";
>
>function getMaxSize( $maxSize )
>{
> echo $byteSize[0] . "<br/>\n";
> echo $byteSize[1] . "<br/>\n";
> echo $byteSize[2] . "<br/>\n";
> ....
>}
--------------------[snip]--------------------
if you declare $bytesize global within the function it will work:
function getMaxSize( $maxSize )
{
global $bytesize;
echo $byteSize[0] . "<br/>\n";
}
You'd be still better off passing the array as variable:
function getMaxSize( $bytesize, $maxSize )
{
echo $byteSize[0] . "<br/>\n";
}
And lastly, for performance issues, pass it as a reference:
function getMaxSize( &$bytesize, $maxSize )
{
echo $byteSize[0] . "<br/>\n";
}
Without a reference, the array is copied to the function. By passing a
reference the function is working on the original array, no copy overhead.
Note: When passed as reference, any modification on the array within the
function will effect the original array (same is true if declared global).
Without reference the original array remains unchanged.
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/
--- End Message ---