php-windows Digest 20 Nov 2004 12:41:01 -0000 Issue 2475
Topics (messages 25000 through 25007):
Re: How to check if a *string* has only numbers...
25000 by: Luis Moreira
GD Image Resizing on the fly.
25001 by: Tony Devlin
25002 by: Mike
25003 by: denis
25006 by: Jed Smith
Re: PHP, Classes, and PEAR
25004 by: Manuel Lemos
25005 by: phpWalter
Limit to the number of sockets socket_select can supervise?
25007 by: Hans-Christian Jehg
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 ---
Better yet, use the right function :-)
This script
<?php
$a = "1234567890";
$b = $a.$a;
$c = $a."A";
echo "$a ";
if (!is_numeric($a))
echo "NOT ";
echo "numeric<br>";
echo "$b ";
if (!is_numeric($b))
echo "NOT ";
echo "numeric<br>";
echo "$c ";
if (!is_numeric($c))
echo "NOT ";
echo "numeric<br>";
?>
should provide this output
1234567890 numeric
12345678901234567890 numeric
1234567890A NOT numeric
Luis
[EMAIL PROTECTED] wrote:
Hi,
Have you tried regular expressions ? try them, they might do the trick
Rui Francisco
Rafael Soares wrote:
Hello people!!!
I would like to check if a string contains only numbers, I really can’t
realize how to do it.
I tried is_int(), but it don’t work because the variable is a string
(I used
gettype() to check it) and is_int() returns NULL…
It is to validate some data in a form. The variable I’m trying to
test is
the result of this script:
$data = $_POST[‘data’]; // something like 123.456.789
$dataParts = explode($data);
//these are the variable I have to check:
$dataP1 = $dataParts[0];
$dataP2 = $dataParts[1];
$dataP3 = $dataParts[3];
gettype($dataP1), gettype($dataP2) and gettype($dataP3) return string
gettype($dataParts) returns array
Thanks in advance.
Rafael Soares - AgênciaM
Fone: +55 11 4616-1394
--- End Message ---
--- Begin Message ---
Hello Everyone,
I am looking for a script or guidance in where to look to figure out how
to create a php script that resizes an image on the fly when it is called
with some variables. To further detail, I have a shopping cart I am
creating for a client -- the client has the ability to upload images,
instead of creating a very complex script when he uploads the file, I
figured on the shopping cart page I could grab the original file and then
resize it to display a thumbnail based on 2 variables being sent W,H (Width,
Height). The products are stored in a database along with the image path.
I need it to display in the middle of a page so a "header( 'Content-type:
image/jpeg' );" won't work for obvious reasons (header already sent). Also
it will have to distinquish between Gif and Jpeg (not a problem, just
preg-match the extension). I know the exact sizes that we want the shopping
cart images to be. Anyone have any ideas? If you need more information
just ask.
Thanks everyone -- this is such a great community!
Tony Devlin
--- End Message ---
--- Begin Message ---
This following bit of code will create a thumbnail of size $thumb_width x
$thumb_height based off of the initial file $file_location. Current GD
libraries don't work on GIFs, so that's not an option. You can use the
relative PNG functions in place of the jpeg functions, however.
// Create New Image
$full_img = imagecreatefromjpeg("$file_location");
$thumb_img = imagecreatetruecolor($thumb_width,$thumb_height);
imagecopyresized($thumb_img,$full_img,0,0,0,0,$thumb_width,$thumb_height,$wi
dth,$height);
imagedestroy($full_img);
imagejpeg($thumb_img,"$path_to_save\\$thumb_name");
imagedestroy($thumb_img);
print "<img src='$path_to_save\\$thumb_name'>";
// Might Need To Change Paths Pending How Script Is Called
The best thing to do, however, is to spend time reading all of the image
functions in the manual http://us2.php.net/manual/en/ref.image.php . There's
a lot in there and you can do some very impressive things with images if you
spend some time reading.
-M
-----Original Message-----
From: Tony Devlin [mailto:[EMAIL PROTECTED]
Sent: Friday, November 19, 2004 9:41 AM
To: Php-Windows
Subject: [PHP-WIN] GD Image Resizing on the fly.
Hello Everyone,
I am looking for a script or guidance in where to look to figure out how
to create a php script that resizes an image on the fly when it is called
with some variables. To further detail, I have a shopping cart I am
creating for a client -- the client has the ability to upload images,
instead of creating a very complex script when he uploads the file, I
figured on the shopping cart page I could grab the original file and then
resize it to display a thumbnail based on 2 variables being sent W,H (Width,
Height). The products are stored in a database along with the image path.
I need it to display in the middle of a page so a "header( 'Content-type:
image/jpeg' );" won't work for obvious reasons (header already sent). Also
it will have to distinquish between Gif and Jpeg (not a problem, just
preg-match the extension). I know the exact sizes that we want the shopping
cart images to be. Anyone have any ideas? If you need more information
just ask.
Thanks everyone -- this is such a great community!
Tony Devlin
--- End Message ---
--- Begin Message ---
hi
this the script i use in www.biere.org
you can see it in action at
http://www.monsieur-biere.com/liste/secondairelmc.php3?type=type&type2=BIERE+DE+NOEL&page=1
i use the same script in rhe shopping cart and in the order form
it test if the file exist and resize it at predefined size or peoduce a
single dot image transparent, it was easy to modify this script to your
needs
<? /* Header ("Content-type: image/png"); */
$imname="imagesb//".$ref.".png";
if (file_exists($imname)):
$im = ImageCreatefrompng($imname);
$rat=60.0*(doubleval(imagesx($im))/doubleval(imagesy($im)));
$im2 = ImageCreate($rat, 60);
imagecopyresized($im2,$im,0,0,0,0,$rat,60,imagesx($im),imagesy($im));
else:
$im2 = ImageCreate(1, 1);
$green = ImageColorAllocate($im2, 0, 255, 0);
imagefilledrectangle($im2,0,0,1,1,$green);
endif;
Imagepng($im2);
?>
denis
--- End Message ---
--- Begin Message ---
Tony Devlin wrote:
Hello Everyone,
I am looking for a script or guidance in where to look to figure out how
to create a php script that resizes an image on the fly when it is called(...)
Image resizing takes a lot of cycles. As opposed to generating a
thumbnail every time a visitor comes to your site, cache it.
/* PHP Psuedocode */
thumbnail_file = thumbnail-cache/product.png
if(file_exists(thumbnail_file))
print <img src=thumbnail_file />
else
generate_thumbnail(source, thumbnail_file);
print <img src=thumbnail_file />
This way, the expensive GD hits only take place once, when the thumbnail
is first created. Otherwise, you may get a visitor who constantly
refreshes and drives up your load average -- and on shared hosting, this
can be problematic.
--
_
(_)___ Jed Smith, Code Ninja
| / __| RFBs: [email for info]
| \__ \ +1 (541) 606-4145
_/ |___/ [EMAIL PROTECTED] (Signed mail preferred: PGP 0x703F9124)
|__/ http://personal.jed.bz/keys/jedsmith.asc
--- End Message ---
--- Begin Message ---
Hello,
On 11/19/2004 01:31 AM, Mikea wrote:
WinXP Pro SP1
PHP 4.3.9
I am still learning PHP so please be gentle with me! LOL
I am trying to send mail from my PC. For some reason it is not working.
The line is
mail($email_to, $email_subject, $email_message);
There is no error or failure but the email is never sent.
I also found a Mail class that extends Mail as a PEAR (extends) class. I
tried that but could not get it to work either. It keep saying that it
could not find the class.
Fatal error: Cannot instantiate non-existent class: mail_mail
I did the PEAR_ENV.reg so it is in the registry. So my questions is how do
I get PHP to find the PEAR classes? And how do I get mail to work?
I think you are a little confused. There is no such thing as a class
that extends the mail() function because classes only extend other
classes, not functions.
Anyway, without more details about your PHP environment (OS, php.ini
mail options) it is hard to tell what is the problem.
You may want to try this class that provides several workarounds to
common problems of using the mail() function and let me know if it still
does not work for you:
http://www.phpclasses.org/mimemessage
--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
--- End Message ---
--- Begin Message ---
> WinXP Pro SP1
> PHP 4.3.9
>
>
> I am still learning PHP so please be gentle with me! LOL
>
>
> I am trying to send mail from my PC. For some reason it is not working.
I have working code. I'll dig it up and sent it to you.
> So my questions is how do I get PHP to find the PEAR classes?
You have to modify your php.ini file.
You need to add the path to the PEAR classes in the php_include line.
If your interested in a "never fails" (Well, OK, I've heard of 1 instance
some didn't work, but that's 1 out of several hundred) installation and
operation, try...
web.torres.ws/walters_way
Oh, BTW, you do have access to an SMTP mail relay, right?
Walter
--- End Message ---
--- Begin Message ---
Hi
Im building a TCP server in PHP 5.0.2 on Windows. It will have to serve a
lot of clients (500+) with low traffic.
During this I have noticed that socket_select seems unable to supervise more
than 64 reading connections at a time (Not good when I need 500+). It stops
with a
message that
"Socket select failed, error code is: 10038, error message is: An operation
was at tempted on something that is not a socket."
These are the outputs of socket_last_error() and
socket_strerror(socket_last_error()).
And now forthe questions:
Does any of you have the same experience?
Is it something to do with Windows? Does this limitation exist on Linux?
Is it just a bug?
Any good suggestions?
Best regards
and thanx in advance
HC
--- End Message ---