OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 1 Nov 2004 20:38:13 -0000 Issue 3087

php-general-digest-helplists.php.net
Date: Mon Nov 01 2004 - 14:38:13 CST


php-general Digest 1 Nov 2004 20:38:13 -0000 Issue 3087

Topics (messages 200819 through 200864):

Re: PLEASE HELP ON MAIL FUNCTION
        200819 by: Hodicska Gergely

Re: Need to add a 0 to a float number
        200820 by: Klaus Reimer

Re: Help with preg_match_all()
        200821 by: Klaus Reimer

Help needed on php/mysql
        200822 by: Garth Hapgood - Strickland
        200846 by: Lists

Re: Simple math failing - PHP Bug?
        200823 by: Mark Charette
        200824 by: Aidan Lister
        200826 by: Ford, Mike

Re: PHP_EOL on Darwin?
        200825 by: Pierre Ancelot

imagestring() not working
        200827 by: Ken Tozier

calling javascript
        200828 by: Garth Hapgood - Strickland
        200829 by: Jay Blanchard
        200830 by: John Nichel
        200831 by: Garth Hapgood - Strickland
        200832 by: Garth Hapgood - Strickland
        200833 by: Ben Ramsey
        200834 by: Jay Blanchard
        200835 by: Garth Hapgood - Strickland
        200836 by: Jay Blanchard
        200837 by: Richard Davey
        200838 by: Ben Ramsey
        200849 by: M Saleh EG

Question about function dns_check_record
        200839 by: Bao Vu
        200840 by: Ben Ramsey

Uploading Images
        200841 by: bb9876
        200842 by: Greg Donald
        200843 by: Rens Admiraal
        200844 by: Brian V Bonini
        200848 by: bb9876

Re: Unable to validate XML with Schema if namespace is specified.
        200845 by: Dusty Bin

Re: PHP Working With Excel File ?
        200847 by: Matt M.
        200859 by: Ben Ramsey
        200860 by: Erich Kolb

An easier way? $_POST[] => $_SESSION[]
        200850 by: Erich Kolb
        200851 by: Michael Sims
        200852 by: Klaus Reimer
        200853 by: Jason Wong
        200854 by: Greg Beaver
        200855 by: John Nichel

No luck creating dynamic images
        200856 by: Ken Tozier
        200857 by: Jay Blanchard
        200858 by: Jason Wong
        200861 by: Vail, Warren
        200862 by: Ryan A
        200863 by: Ken Tozier
        200864 by: Vail, Warren

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


> http://www.phpclasses.org/mimemessage
Or you can try is, which is one of the best mailer class:
http://phpmailer.sourceforge.net/

Felho

attached mail follows:


Brent Clements wrote:
> Solved my own problem
> Note to self, RTFM:
> number_format is w hat I needed.

Or:

printf("%.2f", $var);

--
Bye, K <http://www.ailis.de/~k/> (FidoNet: 2:240/2188.18)
[A735 47EC D87B 1F15 C1E9 53D3 AA03 6173 A723 E391]
(Finger kailis.de to get public key)

attached mail follows:


Curt Zirzow wrote:
>>And so on.. It's a kind of a template system... well... I need to
>>create a expression to get all the tags from the HTML with
>>preg_match_all() in order to have them in a array...
> So your looking from something that starts with '{' and continues
> while not a ')' ...
>
> /{([^}]*?)}/

If you are already using the "?" meta character then you can simply do this:

/{(.*?)}/

The "while not"-approch is useful if you don't want to use the "?" meta
character (to be compatible to regex engines which don't support this).
But then it would look like this:

/{([^}]*)}/

But all these expressions are to lazy for the required work. The tags
should be matched more exactly using this:

/{$([\w\.]+)}/

This implies that the variable names always begin with a dollar
character and they can contain upper and lowercase characters, numbers,
underscores and periods. The variable name must contain at least one
character, so {$} is not matched.

--
Bye, K <http://www.ailis.de/~k/> (FidoNet: 2:240/2188.18)
[A735 47EC D87B 1F15 C1E9 53D3 AA03 6173 A723 E391]
(Finger kailis.de to get public key)

attached mail follows:


I have written a registration page in php and have a number of edit boxes
and drop-down lists. The lists are pulling data out of their respective
tables, whereas the edit boxes are just for saving data.

Now my main table where all my data is being saved is called Business. Onto
this I have a table called BusinessCommunication which has the fields
(BusinessCommunicationID, BusinessID, CommunicationTypeID, Destination).

BusinessCommunicationID = Primary Key
BusinessID = Foreign key from Business Table
CommunicationTypeID = Foreign key from CommunicationType table (lists all
communication types)
Destination = field where data is stored (tel number, email address or fax
number etc)

Now the problem is that I want the person registering to be able to select
the Communication Type/s he wants to add and then be able to enter the
relevant information for each selected CommType. There must also be ability
to add 2 of the same CommType.

How can I achieve this as simply and affective as possible on my
registration page.

If you have any solutions are need more information. Please let me know

Many thanx
Garth

attached mail follows:


Seeing the page might help.
On Nov 1, 2004, at 2:52 AM, Garth Hapgood - Strickland wrote:

> I have written a registration page in php and have a number of edit
> boxes
> and drop-down lists. The lists are pulling data out of their respective
> tables, whereas the edit boxes are just for saving data.
>
> Now my main table where all my data is being saved is called Business.
> Onto
> this I have a table called BusinessCommunication which has the fields
> (BusinessCommunicationID, BusinessID, CommunicationTypeID,
> Destination).
>
> BusinessCommunicationID = Primary Key
> BusinessID = Foreign key from Business Table
> CommunicationTypeID = Foreign key from CommunicationType table (lists
> all
> communication types)
> Destination = field where data is stored (tel number, email address or
> fax
> number etc)
>
> Now the problem is that I want the person registering to be able to
> select
> the Communication Type/s he wants to add and then be able to enter the
> relevant information for each selected CommType. There must also be
> ability
> to add 2 of the same CommType.
>
> How can I achieve this as simply and affective as possible on my
> registration page.
>
> If you have any solutions are need more information. Please let me know
>
> Many thanx
> Garth
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
-dg
http://www.rexruff.com

attached mail follows:


From: "Chris Shiflett" <shiflettphp.net>
To: "Jason Wong" <php-generalgremlins.biz>; <php-generallists.php.net>
Sent: Monday, November 01, 2004 12:22 AM
Subject: Re: [PHP] Simple math failing - PHP Bug?

> --- Jason Wong <php-generalgremlins.biz> wrote:
>> Most computer languages handling floating point calculations
>> just as poorly. If accuracy is important use the BCMath
>> functions.
>
> Or use Fortran and double precision. :-)

Wouldn't help. Exact same problem.

The root cause it trying to express the number range of 0.0-1.0 in a finite
set of bits. The more bits you use, the smaller the gaps between the numbers
exactly represented, but there are always an infinite number of "numbers" in
every gap.

It works well enough as an approximation to be useful; the Fortran
programmers use format clauses just like any other programmer to force
rounding to a known precision.

Mark C., who's worked on all the Fortrans up to 95.

attached mail follows:


We have a chapter in the manual about this,
http://www.php.net/manual/en/language.types.float.php

This is also interesting:
http://docs.python.org/tut/node15.html

Kind Regards,
Aidan

"Brian T. Allen" <briangzmarketing.com> wrote in message
news:4185C110.9050106gzmarketing.com...
> Hi,
>
> OK, I'm totally stumped by this. This should be the simplest math
> imaginable (addition and subtraction), but PHP is coming up with the wrong
> answer!
>
> I've checked on 3 different machines (all linux) running both PHP 4 and
> PHP 5.
>
> Here is the code to duplicate the problem:
>
> -----------------------------------
> <?php
>
> $a = 2503.54;
> $b = 303.55;
> $c = 202.13;
>
> $total = 0;
> $total += $a;
> $total += $b;
> $total += $c;
>
> $added_total = $total;
>
> echo "$a + $b + $c = $total<br>";
> echo "Actual: $total<br><br>";
>
> $total -= $a;
> $total -= $b;
> $total -= $c;
>
> echo "$added_total - $a - $b - $c = 0<br>";
> echo "Actual: $total<br><br>";
>
> ?>
> -----------------------------------
>
> This ~should~ output this:
>
> 2503.54 + 303.55 + 202.13 = 3009.22
> Actual: 3009.22
>
> 3009.22 - 2503.54 - 303.55 - 202.13 = 0
> Actual: 0
>
> But instead it outputs this:
>
> 2503.54 + 303.55 + 202.13 = 3009.22
> Actual: 3009.22
>
> 3009.22 - 2503.54 - 303.55 - 202.13 = 0
> Actual: 2.84217094304E-13
>
>
> Now I'm the first to admit that 0.000000000000284217094304 and 0 are
> really very close, but when you are testing a variable to see if it equals
> 0, it is the difference between true and false.
>
> This seems very, very basic to me, but I can't find the flaw in my code.
>
> Is this legitimately bad math on the part of PHP?
>
> Thanks,
> Brian

attached mail follows:


To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm

On 01 November 2004 06:31, Brian T. Allen wrote:

[....]

> When adding dollar amounts using only whole cents (and excluding the
> limitation we've been discussing) you should always have a credit >=
> .01, a balance >= .01, or no balance / credit due, which
> would equal 0
> or 0.00, but NOT 0.0000000000034322.
>
> Yes, there are ways to program around this, but it shouldn't be
> necessary. The example above shouldn't be questionable or
> complicated, in fact it is about as basic as it comes. It's 2nd
> Grade math.

Possibly -- but the explanation of the discrepancy is probably
something nearer high school level (or GCSE Maths, in my
vernacular!).

Very briefly, computers work in binary -- and the binary system can
represent very few decimal fractions exactly. Take, for example,
your 503.54: in binary, this converts to
111110111.100010100011110101110000..., or, slightly more readably, in
hexadecimal it's 1f7.8a3d70a3d70a3d70.... You can see how this has a
repeating fractional part, and so cannot be represented exactly in
any finite number of bits -- so there is no way of storing exactly
503.54 in any computer working in the binary system.

> You just should have to program around that. I would
> MUCH rather
> have PHP
> run a little slower

Unfortunately, it is very unlikely that "fixing" it the way you'd
like would be only a *little* slower -- more likely, it would be
massively slower. Given this, it's more efficient and effective to
have the computer calculate the answer as accurately as it can, and
let the programmer decide the level of accuracy it should be tested
for. (Some early business-oriented computers, and some calculators
(especially financial ones) did use a system called binary-coded
decimal -- BCD -- to calculate "accurately" in the sense you mean,
but the fact that they were never widely used and have died out
almost totally should tell you something about their usefulness.)

Having said all that, here are a couple of golden rules:

  (i) If your numbers can be represented exactly to a given number
of decimals, consider using integers for your calculations and
dividing/multiplying by the appropriate power of 10 on output/input
(this, of course, won't work if the scaled numbers exceed the integer
range).

  (ii) NEVER EVER compare floats for equality -- always build in an
appropriate amount of fuzz (e.g. if you have to use floats for money
amounts, a check for equality to 4 decimal places is probably
sufficient: if (abs($a-100)<0.0001) echo "close enough to $100.00";

  (iii) Always format your numbers to an appropriate number of
decimal places on output (using number_format() or printf(), for
example).

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: m.fordleedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

attached mail follows:


\n will set the appropriate.

On Monday 01 November 2004 04:53, Greg Beaver wrote:
> Hi all,
>
> What's the standard line ending for Darwin? is it still the same as old
> Mac, which I think was just \r? Or does it use \n like unix?
>
> Greg

attached mail follows:


Hi all,

I'm trying to create a little function that generates tabs dynamically
and am having no luck with the imagestring() function. I checked out
the documentation and even cut and pasted the example but it always
chokes the browser when the page containing an imagestring() line is
loaded.

Anyone see what I'm doing wrong?

Thanks

Ken

-----------------------------------------------------

Here's the script so far:

<?php
$font  = 1;
$font_width = ImageFontWidth($font);
$str_len = strlen($in_tab_title);
$width = $font_width * $str_len;
$height = ImageFontHeight($font);
$image = imagecreate($width, $height);
$inactive = ImageColorAllocate($image, 118, 102, 205);
$poly = imagerectangle($image, 0, 0, $width, $height, $inactive);
$over = ImageColorAllocate($image, 138, 122, 243);
$active = ImageColorAllocate($image, 230, 179, 115);
$text_color = ImageColorAllocate($image, 255, 0, 0);

echo "<pre>";
var_dump($image);
var_dump($inactive);
var_dump($poly);
var_dump($over);
var_dump($active);
var_dump($text_color);
echo "</pre>";

// if I comment out the next line, the browser displays the above
var_dumps
// but when it's uncommented, the browser displays a blank screen
imagestring ($image, 1, 0, 0,  "bobo", $text_color);

// header("Content-type: image/png");
// imagepng($im);
?>

And here's the return from gd_settings()

array(11) {
   ["GD Version"]=>
   string(27) "bundled (2.0.15 compatible)"
   ["FreeType Support"]=>
   bool(true)
   ["FreeType Linkage"]=>
   string(13) "with freetype"
   ["T1Lib Support"]=>
   bool(true)
   ["GIF Read Support"]=>
   bool(true)
   ["GIF Create Support"]=>
   bool(false)
   ["JPG Support"]=>
   bool(true)
   ["PNG Support"]=>
   bool(true)
   ["WBMP Support"]=>
   bool(true)
   ["XBM Support"]=>
   bool(true)
   ["JIS-mapped Japanese Font Support"]=>
   bool(false)
}

attached mail follows:


I want to call a javascript function:

function error_popup() { newwin = window.open("error_popup.php","sss","height=470,width=450") }

from within my php code.
How do I go about called this function?

Garth

attached mail follows:


MIME-Version: 1.0
Content-Type: text/plain;
        charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Date: Mon, 1 Nov 2004 08:08:06 -0600
Message-ID: <C8F323573C030A448F3E5A2B6FE2070B03522CD0nemesis>
From: "Jay Blanchard" <jay.blanchardniicommunications.com>
To: "Garth Hapgood - Strickland" <garthredpoint.co.za>,
   <php-generallists.php.net>
Subject: RE: [PHP] calling javascript

[snip]
I want to call a javascript function:

function error_popup() { newwin =
window.open("error_popup.php","sss","height=470,width=450") }

from within my php code.
How do I go about called this function?
[/snip]

You have to echo or print out the javascript using PHP

attached mail follows:


Garth Hapgood - Strickland wrote:
> I want to call a javascript function:
>
> function error_popup() { newwin = window.open("error_popup.php","sss","height=470,width=450") }
>
> from within my php code.
> How do I go about called this function?
>
> Garth

You can't call JavaScript functions from within PHP. You can output the
JavaScript function to the browser.

PHP == Server Side
JavaScript == Client Side

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
johnkegworks.com

attached mail follows:


by saying ?

echo error_popup();
or
print error_popup;

attached mail follows:


> You can't call JavaScript functions from within PHP. You can output the
> JavaScript function to the browser.
>
> PHP == Server Side
> JavaScript == Client Side

Ok so what does this mean I should write..I don't understand what you mean
by Server Side/Client Side.

attached mail follows:


Garth Hapgood - Strickland wrote:
> by saying ?
>
> echo error_popup();
> or
> print error_popup;

As someone mentioned, you cannot call a javascript function from within
PHP. What is meant by client side/server side is this: PHP is processed
on the server before sending any content to the browser; that's
server-side. Then, the server sends the HTML output of the PHP script to
the browser. Any javascript you have in the output is enacted in the
browser (client-side).

So, you want your PHP to output the javascript just like it might output
HTML:

i.e.

echo '<script type="text/javascript">';
echo 'function error_popup() { newwin =
window.open("error_popup.php","sss","height=470,width=450") }';
echo '</script>';
echo '<input type="button" onclick="error_popup()">';

Sounds to me like you need to go back and revisit the introductory pages
of the PHP manual. Take a look at <http://www.php.net/introduction> and
follow the subsequent pages to read more about PHP and what it can do.
It'll also take you through a tutorial that's fairly helpful.

--
Regards,
Ben Ramsey
http://benramsey.com

---------------------------------------------------
Atlanta PHP - http://www.atlphp.org/
The Southeast's premier PHP community.
---------------------------------------------------

attached mail follows:


[snip]
Ok so what does this mean I should write..I don't understand what you
mean
by Server Side/Client Side.
[/snip]

Server side means that the server handles the processing. Client side
means that the interface device (in this case, a browser) handles the
processing. PHP is server side. JavaScript is client side. In order to
get PHP to "precess" JavaScript you have to output the JavaScript with
the PHP.

attached mail follows:


Thanx for your help, I am actually a web designer!

I dont think u understand 100%

I have a form and Im doing a check on submission to check whether there are
any blank field and if there are I want to call function.. error_popup();
does this make anymore sense to you. Now I understand that you cant call
javascript from within php. wot would you recommend as an alternative.

I dont have a button or anything that I want to press, just want to call the
function so it can open a popup window.
Regards
Garth

"Ben Ramsey" <listsbenramsey.com> wrote in message
news:41864986.60101benramsey.com...
> Garth Hapgood - Strickland wrote:
> > by saying ?
> >
> > echo error_popup();
> > or
> > print error_popup;
>
> As someone mentioned, you cannot call a javascript function from within
> PHP. What is meant by client side/server side is this: PHP is processed
> on the server before sending any content to the browser; that's
> server-side. Then, the server sends the HTML output of the PHP script to
> the browser. Any javascript you have in the output is enacted in the
> browser (client-side).
>
> So, you want your PHP to output the javascript just like it might output
> HTML:
>
> i.e.
>
> echo '<script type="text/javascript">';
> echo 'function error_popup() { newwin =
> window.open("error_popup.php","sss","height=470,width=450") }';
> echo '</script>';
> echo '<input type="button" onclick="error_popup()">';
>
> Sounds to me like you need to go back and revisit the introductory pages
> of the PHP manual. Take a look at <http://www.php.net/introduction> and
> follow the subsequent pages to read more about PHP and what it can do.
> It'll also take you through a tutorial that's fairly helpful.
>
> --
> Regards,
> Ben Ramsey
> http://benramsey.com
>
> ---------------------------------------------------
> Atlanta PHP - http://www.atlphp.org/
> The Southeast's premier PHP community.
> ---------------------------------------------------

attached mail follows:


[snip]
I have a form and Im doing a check on submission to check whether there
are
any blank field and if there are I want to call function..
error_popup();
does this make anymore sense to you. Now I understand that you cant call
javascript from within php. wot would you recommend as an alternative.

I dont have a button or anything that I want to press, just want to call
the
function so it can open a popup window.
[/snip]

You would then be using pure JavaScript ... I think onBlur is what you
are looking for IIRC. You might want to send this to a JavaScript list.

attached mail follows:


Hello Garth,

Monday, November 1, 2004, 2:52:48 PM, you wrote:

GHS> I have a form and Im doing a check on submission to check whether
GHS> there are any blank field and if there are I want to call
GHS> function.. error_popup(); does this make anymore sense to you.

Then keep it all within the JavaScript and write a JavaScript function
to handle the error_popup and do whatever it needs to do before
submitting to the server. Sorry but this isn't a PHP question.

Best regards,

Richard Davey
--
 http://www.launchcode.co.uk - PHP Development Services
 "I am not young enough to know everything." - Oscar Wilde

attached mail follows:


Jay Blanchard wrote:
> [snip]
> I have a form and Im doing a check on submission to check whether there
> are
> any blank field and if there are I want to call function..
> error_popup();
> does this make anymore sense to you. Now I understand that you cant call
> javascript from within php. wot would you recommend as an alternative.
>
> I dont have a button or anything that I want to press, just want to call
> the
> function so it can open a popup window.
> [/snip]
>
> You would then be using pure JavaScript ... I think onBlur is what you
> are looking for IIRC. You might want to send this to a JavaScript list.

Nah. I was just using the button as an example to get you started.
You'll probably want to call it from the onsubmit attribute of the form tag.

I didn't want to get into too much of an HTML/Javascript discussion,
since that's off-topic for this list.

Google for form handling and javascript, etc. There're plenty of
resources on it.

--
Regards,
Ben Ramsey
http://benramsey.com

---------------------------------------------------
Atlanta PHP - http://www.atlphp.org/
The Southeast's premier PHP community.
---------------------------------------------------

attached mail follows:


The idea is very simple. It just needs you to know the concepts.

On the form processing page whenever u find an error just print or echo this :
<script type="text/javascript">
err_popup();
</script>

e.g. <? if( empty($_POST['firstName']) )
           {
             echo "<script type=\"text/javascript\">";
             echo "err_popup();";
             echo "</script>";
           }
       ?>

Given that the definistion of the JS err_popup() function has been
done in the header part of the markup

attached mail follows:


Hello,

I have a problem regard to function
   - dns_check_record
   - dns_get_mx
Can you tell me why the PHP said the "Call to undefined function"?
 
and also

class Dog
{
   function __construct()
   {
   }
}

the construct or descontruction are not working?

Thanks,
Bao

attached mail follows:


To: php-generallists.php.net, Bao Vu <baovuearthlink.net>
Message-ID: <41865761.9070405benramsey.com>
Date: Mon, 01 Nov 2004 10:33:53 -0500
From: Ben Ramsey <listsbenramsey.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; formatowed
Content-Transfer-Encoding: 7bit
Subject: Re: Question about function dns_check_record

First of all, don't ask two questions in one message. Send two separate
messages. You're more likely to get better answers to both questions.

Bao Vu wrote:
> I have a problem regard to function
> - dns_check_record
> - dns_get_mx
> Can you tell me why the PHP said the "Call to undefined function"?

Did you read the manual?
<http://us2.php.net/manual/en/function.checkdnsrr.php>

dns_check_record() is an alias for checkdnsrr(), which isn't implemented
on Windows. Same thing for dns_get_mx()/getmxrr().

Check your platform. If you're on Windows, that could be the problem.

> and also
>
> class Dog
> {
> function __construct()
> {
> }
> }
>
> the construct or descontruction are not working?

Are you using PHP 5? If you're still on PHP 4, then that's the problem.

--
Regards,
Ben Ramsey
http://benramsey.com

---------------------------------------------------
Atlanta PHP - http://www.atlphp.org/
The Southeast's premier PHP community.
---------------------------------------------------

attached mail follows:


I want to allow people to upload images but I want to be able to put
limitations on it, such as allow only jpg and gif extensions and make sure
the image is no larger than 60x60. Is there any way to do this?

Thanks

attached mail follows:


On Mon, 1 Nov 2004 07:44:13 -0800, bb9876 <bradbrevetropeofsilicon.com> wrote:
> I want to allow people to upload images but I want to be able to put
> limitations on it, such as allow only jpg and gif extensions

$_FILES['userfile']['type'] contains the mime type.

> and make sure
> the image is no larger than 60x60. Is there any way to do this?

getimagesize( $_FILES['userfile']['tmp_name'] ) contains the size info.

--
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

attached mail follows:


yes, using the Glib for example...

you can set a MAX FILE SIZE for the images you upload, and check it
afterwards for size and format. After that you move the temporary files
to their destination folder...

check http://www.php.net/manual/en/features.file-upload.php and
http://www.php.net/manual/en/ref.image.php

bb9876 wrote:

>I want to allow people to upload images but I want to be able to put
>limitations on it, such as allow only jpg and gif extensions and make sure
>the image is no larger than 60x60. Is there any way to do this?
>
>Thanks
>
>
>

attached mail follows:


From: Brian V Bonini <b-boninicox.net>
To: bb9876 <bradbrevetropeofsilicon.com>
Cc: PHP Lists <php-generallists.php.net>
Content-Type: text/plain
Message-Id: <1099324979.16315.24.camelhome.gfx-design.com>
Mime-Version: 1.0
Date: Mon, 01 Nov 2004 11:03:00 -0500
Content-Transfer-Encoding: 7bit
Subject: Re: [PHP] Uploading Images

On Mon, 2004-11-01 at 10:44, bb9876 wrote:
> I want to allow people to upload images but I want to be able to put
> limitations on it, such as allow only jpg and gif extensions and make sure
> the image is no larger than 60x60. Is there any way to do this?
>

http://us2.php.net/manual/en/ini.sect.file-uploads.php

attached mail follows:


Thanks guys, these three things should solve the question. :)

"Brian V Bonini" <b-boninicox.net> wrote in message
news:1099324979.16315.24.camelhome.gfx-design.com...
> On Mon, 2004-11-01 at 10:44, bb9876 wrote:
> > I want to allow people to upload images but I want to be able to put
> > limitations on it, such as allow only jpg and gif extensions and make
sure
> > the image is no larger than 60x60. Is there any way to do this?
> >
>
> http://us2.php.net/manual/en/ini.sect.file-uploads.php
>

attached mail follows:


Thanks Christian(or chregu),
and thanks for the pointer to trang. I've not met that tool before.
Best regards. . . Dusty
Christian Stocker wrote:
<snip>
</snip>
> Aren't you missing any namespace declaration in your Schema File?
Yes I was - duh!!
<snip>
</snip>

attached mail follows:


> Can PHP work with Excel files as database ?
> If not, how can I conver it to MySQL format and
> reconvert it to Excel 'coz I need it to report it
> in Excel format,

if you are on windows you could use a com object.

if you have access to perl, you could use
http://search.cpan.org/~kwitknr/Spreadsheet-ParseExcel-0.2603/ParseExcel.pm

attached mail follows:


Matt M. wrote:
>>Can PHP work with Excel files as database ?
>>If not, how can I conver it to MySQL format and
>>reconvert it to Excel 'coz I need it to report it
>>in Excel format,
>
> if you are on windows you could use a com object.
>
> if you have access to perl, you could use
> http://search.cpan.org/~kwitknr/Spreadsheet-ParseExcel-0.2603/ParseExcel.pm

You could also just use the MySQL database and have a PHP script that
outputs the contents of your report to a CSV (comma-separated value)
file with an extension of .csv. Excel will automatically open these
files without problem.

--
Ben Ramsey
Zend Certified Engineer
http://benramsey.com

---------------------------------------------------
Atlanta PHP - http://www.atlphp.org/
The Southeast's premier PHP community.
---------------------------------------------------

attached mail follows:


I think the easiest way is to store your data in MySQL and then create a DSN
via MyODBC and connect to your spreadsheet.

"Matt M." <h.dudenessgmail.com> wrote in message
news:7d4580200411010818435d1c5amail.gmail.com...
>> Can PHP work with Excel files as database ?
>> If not, how can I conver it to MySQL format and
>> reconvert it to Excel 'coz I need it to report it
>> in Excel format,
>
>
> if you are on windows you could use a com object.
>
> if you have access to perl, you could use
> http://search.cpan.org/~kwitknr/Spreadsheet-ParseExcel-0.2603/ParseExcel.pm

attached mail follows:


Is there an easier way to assign all post data from a form to session data?

Eg.,

$_SESSION['first_name'] = $_POST['first_name'];
$_SESSION['last_name'] = $_POST['last_name'];

$_SESSION['email'] = $_POST['email'];

attached mail follows:


Erich Kolb wrote:
> Is there an easier way to assign all post data from a form to session
> data?
>
> Eg.,
>
> $_SESSION['first_name'] = $_POST['first_name'];
> $_SESSION['last_name'] = $_POST['last_name'];
>
> $_SESSION['email'] = $_POST['email'];

You could do this:

$_SESSION = array_merge($_SESSION, $_POST);

Although it might be better to ensure that only known valid keys from $_POST are
making their way into $_SESSION, doing something like this:

$keys = array('first_name', 'last_name', 'email');
foreach ($keys as $key) {
  if (isset($_POST[$key])) { $_SESSION[$key] = $_POST[$key]; }
}

attached mail follows:


Erich Kolb wrote:
> Is there an easier way to assign all post data from a form to session data?
> $_SESSION['first_name'] = $_POST['first_name'];
> $_SESSION['last_name'] = $_POST['last_name'];
> $_SESSION['email'] = $_POST['email'];

If a two-dimensional array is ok for you then the easiest way is this:

$_SESSION['user'] = $_POST;

Then you have:

   $_SESSION['user']['first_name'];
   $_SESSION['user']['last_name'];
   $_SESSION['user']['email'];

But you also have something like

   $_SESSION['user']['submit'];

because the submit button in also copied from _POST to the session.

--
Bye, K <http://www.ailis.de/~k/> (FidoNet: 2:240/2188.18)
[A735 47EC D87B 1F15 C1E9 53D3 AA03 6173 A723 E391]
(Finger kailis.de to get public key)

attached mail follows:


On Monday 01 November 2004 17:43, Erich Kolb wrote:
> Is there an easier way to assign all post data from a form to session data?
>
> Eg.,
>
> $_SESSION['first_name'] = $_POST['first_name'];
> $_SESSION['last_name'] = $_POST['last_name'];
>
> $_SESSION['email'] = $_POST['email'];

Name your form elements like so:

  form[first_name]
  form[last_name]

Then:

  $_SESSION['form'] = $_POST['form'];

--
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
------------------------------------------
/*
The shortest distance between any two puns is a straight line.
*/

attached mail follows:


Erich Kolb wrote:
> Is there an easier way to assign all post data from a form to session data?
>
> Eg.,
>
> $_SESSION['first_name'] = $_POST['first_name'];
> $_SESSION['last_name'] = $_POST['last_name'];
>
> $_SESSION['email'] = $_POST['email'];

Never pass in data from any external source without explicitly
validating it. You could run into some serious crap if malicious users
attempt to pass in very large chunks of BS into random $_POST variables,
and you simply save it in $_SESSION. For instance, if you have any
quota, you might exceed it in a single bound, and your whole site would
stop working.

so, the way you're doing it is a lot better than any other options, but
I would add in checks to the values before you save them in $_SESSION.

Greg

attached mail follows:


Erich Kolb wrote:
> Is there an easier way to assign all post data from a form to session data?
>
> Eg.,
>
> $_SESSION['first_name'] = $_POST['first_name'];
> $_SESSION['last_name'] = $_POST['last_name'];
>
> $_SESSION['email'] = $_POST['email'];
>

If you're not worried about checking the integrity of your data...

foreach ( $_POST as $key => $value ) {
        $_SESSION[$key] = $value;
}

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
johnkegworks.com

attached mail follows:


I've been trying for most of the day to generate a simple dynamic image
in my php script without any success. It seems obvious that something
isn't right with my php environment as even the simplest images (like a
rectangle) only yield the broken link icon. Does anyone know of any in
depth resource for php trouble shooting? I've already scoured the
php.net site and it wasn't of much help.

Thanks for any help

Ken

attached mail follows:


[snip]
I've been trying for most of the day to generate a simple dynamic image
in my php script without any success. It seems obvious that something
isn't right with my php environment as even the simplest images (like a
rectangle) only yield the broken link icon. Does anyone know of any in
depth resource for php trouble shooting? I've already scoured the
php.net site and it wasn't of much help.
[/snip]

Put a page on your site that contains only the following code and see if
it works...

<?php

phpinfo();

?>

attached mail follows:


On Monday 01 November 2004 18:24, Ken Tozier wrote:
> I've been trying for most of the day to generate a simple dynamic image
> in my php script without any success. It seems obvious that something
> isn't right with my php environment as even the simplest images (like a
> rectangle) only yield the broken link icon. Does anyone know of any in
> depth resource for php trouble shooting? I've already scoured the
> php.net site and it wasn't of much help.

Enable FULL error reporting.

--
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
------------------------------------------
/*
 "Hey, sexy mama. Wanna kill all the humans?" -Bender
*/

attached mail follows:


One trick I use is invoke the dynamic image module directly (code the URL in
the address field of the browser), along with making sure that the
outputting of headers doesn't take place until just before the image output
command. This allows the browser to display any syntax errors and such.

Warren Vail

-----Original Message-----
From: Jason Wong [mailto:php-generalgremlins.biz]
Sent: Monday, November 01, 2004 6:40 PM
To: php-generallists.php.net
Subject: Re: [PHP] No luck creating dynamic images

On Monday 01 November 2004 18:24, Ken Tozier wrote:
> I've been trying for most of the day to generate a simple dynamic
> image in my php script without any success. It seems obvious that
> something isn't right with my php environment as even the simplest
> images (like a
> rectangle) only yield the broken link icon. Does anyone know of any in
> depth resource for php trouble shooting? I've already scoured the
> php.net site and it wasn't of much help.

Enable FULL error reporting.

--
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
------------------------------------------
/*
 "Hey, sexy mama. Wanna kill all the humans?" -Bender
*/

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

attached mail follows:


Check if you have the GD (or if you are using ImageMagick) installed in the
first place....not all servers do and its not always "enabled"

After that, your might consider posting some code as there are many helpful
people on this list who will give you a hand if needed or point you to the
correct places where you can read up and learn for/by yourself.

Cheers,
-Ryan

> > I've
> been trying for most of the day to generate a simple dynamic
>
> > image in my php script without any success. It seems obvious that
>
> > something
> isn't right with my php environment as even the simplest
> > images (like a
> > rectangle) only yield the broken link icon. Does anyone know of any in
> > depth resource for php trouble shooting? I've
> already scoured the
>
> > php.net site and it wasn't of much help.
>

attached mail follows:


<snip>

> Enable FULL error reporting.

I tried this with error_reporting(E_ALL); and ran the script in
multiple browsers no errors reported.

Also ran phpinfo(); (as suggested by Jay Blanchard) which worked
without problem. The settings under GD were all enabled for the common
image types.

Anybody see any glaring errors in the following?

Here's the html:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
        <body bgcolor="#ffffff">
                <img src="dynamic_tabs.php">
        </body>
</html>

And here's the php:

<?php
        header("Content-type: image/png");
        $im = imagecreate(100, 50)
            or die("Cannot Initialize new GD image stream");
        $back_color = imagecolorallocate($im, 255, 255, 255);
        $text_color = imagecolorallocate($im, 233, 14, 91);
        imagestring($im, 1, 5, 5,  "A Simple Text String", $text_color);
        imagepng($im);
        imagedestroy($im);
?>

attached mail follows:


<?php
        $im = imagecreate(100, 50)
            or die("Cannot Initialize new GD image stream");
        $back_color = imagecolorallocate($im, 255, 255, 255);
        $text_color = imagecolorallocate($im, 233, 14, 91);
        imagestring($im, 1, 5, 5,  "A Simple Text String", $text_color);
        header("Content-type: image/png"); //<-----------------
move header to here
        imagepng($im);
        imagedestroy($im);
?>

And invoke the module directly from your browser,

At http://localhost/dynamic_tabs.php

And now php should be able to help you find your problem.

Good luck,

Warren Vail

-----Original Message-----
From: Ken Tozier [mailto:kentoziercomcast.net]
Sent: Monday, November 01, 2004 11:52 AM
To: php-generallists.php.net
Subject: Re: [PHP] No luck creating dynamic images

<snip>

> Enable FULL error reporting.

I tried this with error_reporting(E_ALL); and ran the script in
multiple browsers no errors reported.

Also ran phpinfo(); (as suggested by Jay Blanchard) which worked
without problem. The settings under GD were all enabled for the common
image types.

Anybody see any glaring errors in the following?

Here's the html:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>
        <body bgcolor="#ffffff">
                <img src="dynamic_tabs.php">
        </body>
</html>

And here's the php:

<?php
        header("Content-type: image/png");
        $im = imagecreate(100, 50)
            or die("Cannot Initialize new GD image stream");
        $back_color = imagecolorallocate($im, 255, 255, 255);
        $text_color = imagecolorallocate($im, 233, 14, 91);
        imagestring($im, 1, 5, 5,  "A Simple Text String", $text_color);
        imagepng($im);
        imagedestroy($im);
?>

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