php-general Digest 16 Aug 2006 10:59:58 -0000 Issue 4296

Topics (messages 240737 through 240763):

Re: Image Destroy
        240737 by: Richard Lynch
        240744 by: Richard Lynch
        240751 by: Chris

Re: Easier way to get the name of a variable?
        240738 by: David Tulloh
        240750 by: Richard Lynch
        240753 by: Larry Garfield
        240754 by: Robert Cummings

Re: login script
        240739 by: Richard Lynch
        240740 by: Richard Lynch

Re: readdir() question
        240741 by: John Meyer
        240748 by: Richard Lynch
        240755 by: John Meyer
        240756 by: Chris

Re: php and dynamic forms
        240742 by: Richard Lynch

Re: Chicago PHP Conference
        240743 by: Richard Lynch
        240747 by: tedd

Re: Setting flags versus checking for existing/nonexisting values
        240745 by: tedd

Re: proxy server
        240746 by: Richard Lynch

Re: Mail reply-path
        240749 by: tedd
        240752 by: Chris
        240758 by: bob pilly

array problems
        240757 by: Chris G
        240759 by: David Tulloh

Re: Max File Upload
        240760 by: Colin Guthrie

Espanol en esto lista
        240761 by: Rory Browne
        240763 by: Dave Goodchild

simple scrip to stop email injection
        240762 by: Ross

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 ---
On Tue, August 15, 2006 5:45 am, Tom Chubb wrote:
> I know this will be really simple, but I'm struggling to get my head
> round
> the use of imagedestroy()
> I have some code which uploads an image, resizes to create a smaller
> image
> and thumbnail then deletes the source image.
> My question is which images need to be destroyed?

Probably none.

imagedestroy() just frees up the RAM in PHP that the image is taking up.

If your script is about to end, imagedestroy() is gonna be moot, as
ALL the RAM is going to be freed up.

You *CAN* imagedestroy() both the orignal and the thumbnail as you
finish each of your three images, if you are short on RAM, or just
want to be extra squeaky clean.

In no case, however, would it be $targetfile in your code.

imagedestroy($target_pic);
would make sense.

imagedestroy($target_id);
would make sense.

You can only imagedestroy() the thing that comes back from:
$destroyable = imagecreate...();

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Tue, August 15, 2006 6:31 am, chris smith wrote:
> imagedestroy($target_id);
> imagedestroy($source_id);
>
> just before
>
> imagejpeg ($target_id,"$targetfile",$jpegqual);
> return true;
> }

If you destroy it before you write it to disk, you gonna get garbage
for your disk JPEG.

destroy $target_id *AFTER* you imagejpeg() it.

Actually, PHP will complain if you try to destroy it first and then
use it later, so you won't get the $targetfile to work at all, really.

But if it did "work" it would just be junk, cuz that image ain't in
RAM no more.

PS
Using "$targetfile" is just silly.

$targetfile is already a string.

Putting quotes around it just makes PHP build a new string with the
same contents again, which is, well, silly.

PHP might even optimize that away, it's so silly, but I'd recommend
just leaving the excessive quotes off in the first place.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
Richard Lynch wrote:
On Tue, August 15, 2006 6:31 am, chris smith wrote:
imagedestroy($target_id);
imagedestroy($source_id);

just before

imagejpeg ($target_id,"$targetfile",$jpegqual);
return true;
}

If you destroy it before you write it to disk, you gonna get garbage
for your disk JPEG.

destroy $target_id *AFTER* you imagejpeg() it.

which is why i replied straight away with the fix ;)

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
Chris W. Parker wrote:
> Hello,
> 
> After some "intense" searching of Google I found one example at
> http://us2.php.net/language.variables on how to get the name of a
> variable. But it looks pretty expensive.
> 
> <snip>
> 
> Anyone aware of a simple language construct(?) that can do this? I'm on
> PHP 4.3.9.
> 

get_defined_vars() can get you a list of all the currently defined
variables.  If you have the value of the variable, you can use
array_search() to find the (first) key.

I do have some misgivings about what you are trying to do though.  I
can't see a case where this would be the best way to solve a problem.


David

--- End Message ---
--- Begin Message ---
On Tue, August 15, 2006 5:05 pm, Robert Cummings wrote:
> On Tue, 2006-08-15 at 16:50 -0500, Richard Lynch wrote:
>>
>> If the names are not predictable, the array solution is probably
>> best,
>> as there is movement in the PHP Internals list that may (or may not)
>> make it impossible to dynamically add a property to an object.
>
> Yikes!! Do you remember the subject line of the thread? i think that
> would break a lot of sites if they removed the ability to dynamically
> add object properties.

It all started here:
http://marc.theaimsgroup.com/?l=php-dev&m=114596465003800&w=2

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Tuesday 15 August 2006 16:50, Richard Lynch wrote:

> If the names are not predictable, the array solution is probably best,
> as there is movement in the PHP Internals list that may (or may not)
> make it impossible to dynamically add a property to an object.  I've
> lost track of where that thread ended, so apologies if this is a
> non-issue.

Gah!  Please tell me you're joking.  That would kill one of PHP's best 
features, the fact that you can have dynamic data structures.

PHP != Java!!!

-- 
Larry Garfield                  AIM: LOLG42
[EMAIL PROTECTED]               ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

--- End Message ---
--- Begin Message ---
On Tue, 2006-08-15 at 19:01 -0500, Larry Garfield wrote:
> On Tuesday 15 August 2006 16:50, Richard Lynch wrote:
> 
> > If the names are not predictable, the array solution is probably best,
> > as there is movement in the PHP Internals list that may (or may not)
> > make it impossible to dynamically add a property to an object.  I've
> > lost track of where that thread ended, so apologies if this is a
> > non-issue.
> 
> Gah!  Please tell me you're joking.  That would kill one of PHP's best 
> features, the fact that you can have dynamic data structures.
> 
> PHP != Java!!!

I read the list earlier (thanks Richard) and the final consensus was to
enforce the restriction only if the class is defined as strict.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
On Tue, August 15, 2006 5:37 am, Ross wrote:
> I have a couple of questions
>
> first how do I check two tables is it?

You probably should not have 2 tables at all.

Both username and password would normally be stored in a single record
in the same table

CREATE TABLE user (
  user_id int(11) auto_increment unique not null primary key,
  username text,
  password text
);
/* You'd probably have other fields like name, address, email, etc */

> $sql = "SELECT * FROM mytable, mytable2 WHERE username = '$username'
> AND
> userpass = '$userpass'";

So it would just be:
FROM user WHERE username = '$username' AND password = '$userpass'


Second, SELECT * is Evil, for various reasons.  You can Google and
find the debates about it.

> Secondly my table just sends and returns straight values from the db
> but I
> expect some kind of encription is required. What is a simple, secure
> method.
> md5() or another method. Do I store an encypted file on the server and
> just
> decrypt it at the php page.

You never ever ever actually decrypt it.

"But wait", you way, "how can that work?!"

It's quite simple, really.

The whole purpose of a one-way encryption is that you only store the
ENCRYPTED result.

Later, the user then has to put in the correct password, and you
one-way encrypt that, and you compare the ENCRYPTED values.

Either the encrypted values match, or the password is wrong.

You can almost think of the ENCRYPTED value as being like a "lock" to
which there is only one "key" that fits -- the password.

To test if the key fits the lock, you don't make another copy of the
key -- You just encrypt it, and see if it matches the shape of the
lock.

MD5 would be a perfectly reasonable one-way encryption scheme.

So if the password was 'foo', then your MD5-encrypted value would be:
acbd18db4cc2f85cedef654fccc4a4d8

Your database would have 'acbd18db4cc2f85cedef654fccc4a4d8' stored in it.

When they login, you do:

SELECT user_id, username
FROM user
WHERE username = '$username'
  AND password = md5('$userpass')

Either the MD5 of their input ('foo') is the correct value you have
stored: acbd18db4cc2f85cedef654fccc4a4d8 or they have the wrong
password/key, and you should not let them in.

> <?php
> session_start();
> $auth = false; // Assume user is not authenticated
> $username= $_REQUEST['username'];
> $userpass= $_REQUEST['userpass'];
> if (isset($username) && isset($userpass)) {
>  $sql = "SELECT * FROM mytable WHERE
>             username = '$username' AND
>             userpass = '$userpass'";

Yikes!

You REALLY need to read about SQL-injection here:
http://phpsec.org/

and start using this function:
http://php.net/mysql_real_escape_string

Also, your $username and $userpass should be constrained at all times
to very specific validation rules.
Can't be blank.
Must be at least X characters. (you pick a nice X)
Passwords should probably contain at least one non-alpha character.

> // Execute the query and put results in $result
> $result = mysql_query( $sql )
>         or die ( 'Unable to execute query.' );

or die() is a great simple way to demonstrate the basics of code.

It's not something you would really really want to use on a production
server, unless you are 100% sure that you've turned off display-errors
and are logging your errors and you have a process in place to examine
the logs...

Something like http://php.net/set_error_handler and
http://php.net/trigger_error would be more appropriate for "real"
code.

> // Get number of rows in $result.
>  $num_rows = mysql_num_rows($result);
>  if($num_rows == 0) {
>
>  }
> else {
>   $_SESSION['username']= $username;
>   $_SESSION['userpass']= $userpass;
>    header("Location: disclaimer.php");

Instead of a header("Location:") which has some issues involved, you
could just do:
require 'disclaimer.php';
exit;

>
>         $auth = true;

This doesn't do anything, at least not with your current code, nor
with anything I've suggested here...

> }
>     }

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Tue, August 15, 2006 5:51 am, Dave Goodchild wrote:
> I think the php and mysql md5 functions differ but I may be wrong!

You are wrong. :-)

The whole point of MD5 is that MD5 is MD5, no matter where you go.

Even ASP MD5 is the same as PHP MD5.

Except it probably sucks for being too slow or you have to pay for it
or something. :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
Richard Lynch wrote:
> On Tue, August 15, 2006 12:04 pm, John Meyer wrote:
>> I have a script to list the files in a directory:
>>
>> <select name="letters">
>> <?php
>>      $open = opendir(".");
>>      while ($file = readdir($open) != false) {
>> ?>
>>      <option value="<?=$file?>"><?=$file?></option>
>> <?php
>>      }
>> ?>
>> </select>
>> </form>
>>
>> And all I am getting are "1"s.  I think I'm doing it right, what is
>> the
>> disconnect?
> 
> It's not a readdir question.  It's an Order of Operations question.
> :-)
> 
> $file = readdir($open) != false
> 
> You probably believe that PHP is going to magically "know" that you
> want this bit:
>         readdir($open) != false
> to be done "first"
> 


No, and I fixed that.  What I'm wondering about is why this

false !== ($dirhandle = opendir('letters'))

works, but this

($dirhandle = opendir('letters')) != false
does not

--- End Message ---
--- Begin Message ---
On Tue, August 15, 2006 5:56 pm, John Meyer wrote:
> Richard Lynch wrote:
>> On Tue, August 15, 2006 12:04 pm, John Meyer wrote:
>>> I have a script to list the files in a directory:
>>>
>>> <select name="letters">
>>> <?php
>>>     $open = opendir(".");
>>>     while ($file = readdir($open) != false) {
>>> ?>
>>>     <option value="<?=$file?>"><?=$file?></option>
>>> <?php
>>>     }
>>> ?>
>>> </select>
>>> </form>
>>>
>>> And all I am getting are "1"s.  I think I'm doing it right, what is
>>> the
>>> disconnect?
>>
>> It's not a readdir question.  It's an Order of Operations question.
>> :-)
>>
>> $file = readdir($open) != false
>>
>> You probably believe that PHP is going to magically "know" that you
>> want this bit:
>>         readdir($open) != false
>> to be done "first"
>>
>
>
> No, and I fixed that.  What I'm wondering about is why this
>
> false !== ($dirhandle = opendir('letters'))
>
> works, but this
>
> ($dirhandle = opendir('letters')) != false
> does not

Do you really mean opendir() or do you mean readdir() ???

What value are you getting for $dirhandle?

echo it out and see what it is.

You also have != in one, and !== in the other.  Those aren't the same.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
Richard Lynch wrote:

> Do you really mean opendir() or do you mean readdir() ???


readdir().

The point is why do you need to put it as
!==

vs.
!=

--- End Message ---
--- Begin Message ---
John Meyer wrote:
Richard Lynch wrote:

Do you really mean opendir() or do you mean readdir() ???


readdir().

The point is why do you need to put it as
!==

vs.
!=


They mean different things.

!== means "check the values are not the same AND check their types".

!= means "check the values are not the same".

http://www.php.net/manual/en/language.operators.comparison.php

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
On Mon, August 14, 2006 10:01 pm, Bigmark wrote:
> Can anyone tell me if this is possible-
> I currrently have a simple form with a textbox and submit button where
> a
> user chooses a number from 1-22 then on submit it opens another page
> with a
> table of results within another form.
> What i need is for the second form to be shown on the same page and
> just
> below form 1, then when the second form is submitted it then goes back
> to
> just form1.
> What i am trying to do is get rid of multiple pages and have the user
> stay
> on the same page for all admin functions.

You can use include() files to simulate this with old-school PHP only
technology.

You can use CSS and hidden DIVs to do this with new-school PHP + AJAX
technology.

Somewhere in between, there is the whole DHTML debacle, which you
probably want to avoid, but it could also be done that way. :-)

There is also a pure CSS + Javascript non AJAX way, but it would
involve dumping ALL the data out to the browser in the first place,
and 22 tables of data is probably "too much" for that to be a
reasonable user experience in performance.

All that said, the PHP part is pretty much the same, no matter how you
structure it, and you're really asking a CSS/Javascript/AJAX question,
even though you don't realize it.

One rule of thumb:
If it happens all on the browser, in real-time, it CANNOT be a PHP
question, cuz PHP lives on the server.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
I *knew* there was big city there, couldn't remember the name, but I
failed on Google maps to find it...  Sorry.

I've even *been* to Windsor, and still couldn't remember the name.

On Mon, August 14, 2006 8:55 pm, Paul Reinheimer wrote:
> --
> I'm hopeful that by Spring 2007, flying to the US will be a less
> unpleasant experience than it is currently...
> --
> As in the border guards would start stocking lubricant as well
> as rubber gloves?
>
> Windsor, Ontario Canada would probably be a better flight
> destination (you would likely end up hubing through toronto
> anyways, but would save you 3 hours of driving). Though the
> Windsor/Detroit border crossing is the busiest, and the guards
> there take it pretty seriously (ok, so I may have been deported
> once).
>
>
> paul
>
>
>
> On 8/14/06, Richard Lynch <[EMAIL PROTECTED]> wrote:
>>
>> For the US folks, Chicago is centrally-located, and flights to
>> O'Hare
>> and Midway are generally frequent and often go on sale.
>>
>> Global visitors might want to fly to Toronto or some other CA city
>> "close" to Chicago and drive, though :-)
>>
>> I'm hopeful that by Spring 2007, flying to the US will be a less
>> unpleasant experience than it is currently...
>>
>> On Sat, August 12, 2006 5:23 pm, Gerry D wrote:
>> > Richard,
>> >
>> > Within the US that might be ok, but given latest developments, who
>> > wants to fly into the US from elsewhere? I could drive from Canada
>> if
>> > I take 2 weeks vacation...
>> >
>> > I don't want to be a show stopper, but I think you need to explain
>> > what your target audience is re global travel, not just weather in
>> > Chicago.
>> >
>> > Having said that, I like your idea.
>> >
>> > Gerry
>> >
>> > On 8/12/06, Richard Lynch <[EMAIL PROTECTED]> wrote:
>> >> It may have started as a joke on PHP-General, but this just isn't
>> >> funny anymore.
>> >>
>> >> I'm in the pre-planning phase of organizing a PHP Conference in
>> >> Chicago.
>> >>
>> >> Due to Chicago weather patterns, the ideal time would be Spring
>> or
>> >> Autumn.
>> >>
>> >> Given that cheap airfare generally requires significant advance
>> >> notice, I am pre-emptorily eliminating Autumn 2006 as a viable
>> >> option.
>> >>
>> >> If you are interested in attending please reply OFF-LIST with
>> your
>> >> name, email, and some basic input for ideal time-frames in the
>> FALL
>> >> or
>> >> SPRING of 2007.
>> >>
>> >> Suggested Topics would be great, and offers to be a Speaker by
>> >> well-known responders would also be MOST welcome.
>> >
>>
>>
>> --
>> Like Music?
>> http://l-i-e.com/artists.htm
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
> --
> Paul Reinheimer
> Zend Certified Engineer
>


-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
At 6:09 PM -0500 8/15/06, Richard Lynch wrote:
I *knew* there was big city there, couldn't remember the name, but I
failed on Google maps to find it...  Sorry.

I've even *been* to Windsor, and still couldn't remember the name.

I went to Windsor once, but it was closed.

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
On Tue, August 15, 2006 11:53 am, Chris W. Parker wrote:
 Is it a better practice to set flags to determine the action of your
 code or is it perfectly acceptable to have your code determine what it
 should do based on the existence (or lack thereof) of data?

 For example:

-snip- flag example

I seldom use flags, but then again I never use if/elseif's either.

Flags introduce another variable you have to keep track of. When do you turn them on/off becomes another step in your logic that is directly dependant upon data in the first place. So, if logic dictates a branch, then I place the condition on the data.

As I see it, in this case, only three conditions can exist:

1. Data is there, or not there -- use isset() or !isset();
2. Data is relative to a single value -- use "if" with equalities (i.e., <=, ==,...);
3. Data is relative to two, or more, values -- use "switch".

That works for me. But, I'm sure that mileage for others vary.

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
On Mon, August 14, 2006 10:24 pm, John Taylor-Johnston wrote:
> I'm sure. CGI proxy I think is the key word I'm looking for.
> I would even pay $10 per year for an SMTP access account if it fixed
> my
> problems.

Think about it from the angle of a person who would consider offering
this service...

There are a few zillion spammers out there that would pay a heck of a
lot more than $10 per year...

And that still wouldn't make it worth it for the headaches involved...

So I truly believe that getting your IP off the black-lists, and
getting the emails to pass through spam filtering is the better route.

Also consider this:
Whatever you did to get ON the black-lists, you're probably going to
just do again with the new SMTP servers...  So then they get
black-listed, and you're at square one, minus the $10.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
At 11:06 AM -0400 8/15/06, Jon Anderson wrote:
bob pilly wrote:
Im trying to send emails using the mail() function but im having a problem. Because the box that the scripts sit on is a shared web-hosting package the Reply-path part of the header always comes up as [EMAIL PROTECTED] but i have set the from part of the header to [EMAIL PROTECTED] A lot of people are not getting the emails (most are) and im picking that its because the domains on the 2 header parts are different and they have some sort of antispam policy which blocks these. Apart from changing the domains or email addresses to be the same has anyone seen this problem before and if so can you give advice or point me to some relevant docs on it? I have tried to change the Replay-path: part of the header with code but it seems to default to the above.
I think you're looking for the 'Return-Path' header rather than the reply-path. (Or perhaps even Reply-To?)


This works for me (use your own name and domain):  :-)

$to = "[EMAIL PROTECTED]";
$re = "Subject";
$msg = "Message\n";
$headers = "Return-path: <[EMAIL PROTECTED]>\r\n";
$headers .= "From: tedd <[EMAIL PROTECTED]>\r\n";
$param5 = '-ftedd@' . $_SERVER['SERVER_NAME'];
mail ($to, $re, $msg, $headers, $param5);

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
Richard Lynch wrote:
On Tue, August 15, 2006 6:54 am, bob pilly wrote:
Im trying to send emails using the mail() function but im having a
problem. Because the box that the scripts sit on is a shared
web-hosting package the Reply-path part of the header always comes up
as [EMAIL PROTECTED] but i have set the from part of the
header to [EMAIL PROTECTED] A lot of people are not getting the
emails (most are) and im picking that its because the domains on the 2
header parts are different and they have some sort of antispam policy
which blocks these. Apart from changing the domains or email addresses
to be the same has anyone seen this problem before and if so can you
give advice or point me to some relevant docs on it? I have tried to
change the Replay-path: part of the header with code but it seems to
default to the above.

The Reply-path: you want to change is not a normal header, so you can
cross off the idea of fixing it with the 4th arg to mail().

If you are using current PHP, there is yet another bonus argument, the
5th one, for this specific purpose, documented in the manual:
http://php.net/mail

If you are NOT using a version of PHP that has that 5th arg, then you
could maybe use ini_set on the sendmail_path to add the -f there. (see
man mail).

That, however, would require that the user PHP runs as, which is what
Apache runs as, be a trusted user in sendmail.cf, which your webhost
may or may not have decided is a Good Idea, based on how much they
trust their clients.

and also safe_mode being off. Not sure why safe_mode affects this (ask the powers that be) but it does.

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
Hi Richard this is exactly what i was after and works perfectly! 

Cheers

Bob

Richard Lynch <[EMAIL PROTECTED]> wrote: On Tue, August 15, 2006 6:54 am, bob 
pilly wrote:
> Im trying to send emails using the mail() function but im having a
> problem. Because the box that the scripts sit on is a shared
> web-hosting package the Reply-path part of the header always comes up
> as [EMAIL PROTECTED] but i have set the from part of the
> header to [EMAIL PROTECTED] A lot of people are not getting the
> emails (most are) and im picking that its because the domains on the 2
> header parts are different and they have some sort of antispam policy
> which blocks these. Apart from changing the domains or email addresses
> to be the same has anyone seen this problem before and if so can you
> give advice or point me to some relevant docs on it? I have tried to
> change the Replay-path: part of the header with code but it seems to
> default to the above.

The Reply-path: you want to change is not a normal header, so you can
cross off the idea of fixing it with the 4th arg to mail().

If you are using current PHP, there is yet another bonus argument, the
5th one, for this specific purpose, documented in the manual:
http://php.net/mail

If you are NOT using a version of PHP that has that 5th arg, then you
could maybe use ini_set on the sendmail_path to add the -f there. (see
man mail).

That, however, would require that the user PHP runs as, which is what
Apache runs as, be a trusted user in sendmail.cf, which your webhost
may or may not have decided is a Good Idea, based on how much they
trust their clients.

Going farther afield, you could attempt to find an SMTP
host/server/setup that would allow you to set these values to what you
want -- I *think* that's do-able...  I never had to go that far,
personally, so can't be certain.

You may also want to convince the recipients to white-list your
address, so that the From/Reply-path/etc are all irrelevant for spam
filtering.  This has the advantage of being a long-term solution, for
any reasonable implementation of spam-filtering that allows
whitelisting by the recipient, no matter what spam-filtering "rules"
are brought to bear in the future.

-- 
Like Music?
http://l-i-e.com/artists.htm




                
---------------------------------
 All new Yahoo! Mail "The new Interface is stunning in its simplicity and ease 
of use." - PC Magazine

--- End Message ---
--- Begin Message ---
Hi all

Having a prob with a php script...

3 arrays

$datay1=array(140,110,50,60);

$datay2=array(35,90,190,190);

$datay3=array(20,60,70,140);

which have to be passed to a class like this

$gbarplot = new GroupBarPlot(array($bplot1,$bplot2,$bplot3));

if I get data from a database, how can I automatically increment the $datay

arrays..... for instance

currently with my loop that follows, I am only creating one array

($data1y) - but I now need to create various from user input.

$query = "SELECT rep_value_perc FROM report_values WHERE rep_l_per_id =

'$_GET[per_id]'";

$result = mysql_query($query) or die (mysql_error());

while($line = mysql_fetch_array($result)) {

$data1y[] = $line['rep_value_perc'];

}

This gives me just the one array from the above example, $datay1. How would

you dynamically create the all of the above arrays?

At present the $_GET[per_id] is only one value $_GET[per_id] = 2

What happens when it becomes more than one, like $_GET[per_id] = array

(1,2,34,4,561,334)

If I need to assign each one of the $_GET[per_id] a new $data array variable

in the loop above how would you do it?

Am I making sense?

Thanks to anyone that reads this...

Regards

Chris

--- End Message ---
--- Begin Message ---
Chris G wrote:
> Hi all
> 
> Having a prob with a php script...
> 
> 3 arrays
> 
> $datay1=array(140,110,50,60);
> 
> $datay2=array(35,90,190,190);
> 
> $datay3=array(20,60,70,140);
> 
> which have to be passed to a class like this
> 
> $gbarplot = new GroupBarPlot(array($bplot1,$bplot2,$bplot3));
> 
> if I get data from a database, how can I automatically increment the $datay
> 
> arrays..... for instance
> 
> currently with my loop that follows, I am only creating one array
> 
> ($data1y) - but I now need to create various from user input.
> 
> $query = "SELECT rep_value_perc FROM report_values WHERE rep_l_per_id =
> 
> '$_GET[per_id]'";
> 
> $result = mysql_query($query) or die (mysql_error());
> 
> while($line = mysql_fetch_array($result)) {
> 
> $data1y[] = $line['rep_value_perc'];
> 
> }
> 
> This gives me just the one array from the above example, $datay1. How would
> 
> you dynamically create the all of the above arrays?
> 
> At present the $_GET[per_id] is only one value $_GET[per_id] = 2
> 
> What happens when it becomes more than one, like $_GET[per_id] = array
> 
> (1,2,34,4,561,334)
> 
> If I need to assign each one of the $_GET[per_id] a new $data array
> variable
> 
> in the loop above how would you do it?
> 
> Am I making sense?
> 
> Thanks to anyone that reads this...
> 
> Regards
> 
> Chris
> 

I'm going to attempt to summarise what you said, or my interpretation of it.
You want to create a dynamic list of variables based on the users input,
those variables happen to be arrays.

I would suggest creating a data array.  This array will contain a series
of arrays built from the user input.  The following psudo code will
achieve this.

foreach ($user_input_array as $user_input) {
        $data_member = array(); # Create an empty array

        Do SQL query stuff

        foreach ($sql_results as $sql_member) {
                $data_member[] = $sql_member;
        }

        $data[] = $data_member;
}

You can now do your function call as
$gbarplot = new GroupBarPlot($data);


And now a bit of bonus advice.  The SQL query that you provided earlier
has a giant SQL injection attack problem.  I'd recomend reading a little
about SQL injection attacks and getting it patched up.


David

--- End Message ---
--- Begin Message ---
Richard Lynch wrote:
On Tue, August 15, 2006 1:50 pm, Jeremy Privett wrote:
http://us2.php.net/manual/en/ini.core.php#ini.upload-max-filesize

In later versions of PHP, you can't use ini_set to set
upload_max_filesize
... The changeable option is PHP_INI_PERDIR now, meaning you can only
change
it in php.ini, .htaccess or httpd.conf ...

http://us2.php.net/manual/en/ini.php#ini.list

Like it says in the user contributed notes on that page, you have to
use
php_value in .htaccess to adjust the setting.

Example: php_value upload_max_filesize 20M

But, for sure, ini_set ain't gonna work as it's MUCH too late in the
game for a file upload change.

Yup :)

Also, I don't think '20M' will work in httpd.conf, as I don't think
Apache considers '20M' to be a valid numeric value...

You may need to use 20000000 to get aproximately 20 Meg.

But it's not apache that is reading this value. It's in the .htaccess file, but it is going through the php_value directive provided by the PHP Module (there is also it's companions php_flag, php_admin_value and php_admin_flag for use in different situations - e.g. php_admin_* in httpd.conf will prevent it being overridden in .htaccess with php_* calls).

PHP has be be configured as a module for this to work too. Apache wont know what php_value means if PHP is in CGI mode.

So I think the 20M will be OK.

I can't rembmer but does Apache have a max size that is independant of PHP? Perhaps you'll need to set both?

While on the topic, is there a nice way to show users progress when file uploads occur? This could be client side/javascript etc. but to upload a 20Meg file will take a while so some form of feedback is important IMO.

What is the absolute maximum that is sensible to use? Are there any other techniques to use (e.g. Applet etc.).

Col.

--- End Message ---
--- Begin Message ---
No tengo bastante espanol para decir lo que quiero decir aqui correctimente,
pero hay lista php-general-es para los mesajes espanol.
( I don't have enough spanish to say what I want to say here correctly, but
there is a php-general-es list for spanish messages. )

Eso lista es para los mesajes en Ingles, por que muchos personas aqui, no
hablamos bastante espanol para entiendar que quieres decir cuando hablas
espanol.
( This list is for messages in English, because most of the people here
don't speak enough spanish to understand what you mean when  you speak
Spanish)

Yo ( y vivo circa de Espana ) solo hablo bastante para comprar cerveza.
( I (and I live near Spain) only speak enough to buy beer. )


In short, speaking a language other than English on this list( especially
considering that there is a php.general.es -
http://news.php.net/php.general.es ), is similar to whispering in company.
Most of us don't understand what you're saying.

Rory

--- End Message ---
--- Begin Message ---

Hablo espanol, pero lo que Rory dice es verdad, hay otra lista en espanol.
Pero, si quieres, you tratare entender tu palabra.


In short, speaking a language other than English on this list( especially
considering that there is a php.general.es -
http://news.php.net/php.general.es ), is similar to whispering in company.
Most of us don't understand what you're saying.

Rory




--
http://www.web-buddha.co.uk
http://www.projectkarma.co.uk

--- End Message ---
--- Begin Message ---
Been having loads of problems with this and have solved it using the 
phpmailer. The only problem is I cannot get the class working on the remote 
host I am working on. I am back to using mail() but need to drop in script 
that checks my fields $fname, $sname, $email, $subject, $message.


Regards,


Ross 

--- End Message ---

Reply via email to