|
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 15 Oct 2004 23:40:49 -0000 Issue 3055
php-general-digest-help
lists.php.net
Date: Fri Oct 15 2004 - 18:40:49 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 15 Oct 2004 23:40:49 -0000 Issue 3055
Topics (messages 199575 through 199621):
Regular Expression for a UK Mobile
199575 by: Shaun
199576 by: Gareth Williams
199578 by: Robert Cummings
199579 by: Jason Wong
199580 by: John Nichel
199581 by: Ford, Mike
199585 by: Chris Dowell
199586 by: Gareth Williams
SimpleXML: DOM, SAX or Other?
199577 by: PHPDiscuss - PHP Newsgroups and mailing lists
199587 by: Christian Stocker
add item to end of (multidimensional) array
199582 by: Arnold
199583 by: Robert Cummings
199584 by: Chris Dowell
199596 by: Chris Boget
199608 by: ApexEleven
test
199588 by: Cosmin
199590 by: John Nichel
Re: [PHP-DB] How to optimize select of random record in DB ?
199589 by: Bastien Koert
installer file creater help needed
199591 by: bigmark
Advanced maths help (for GD image functionality)
199592 by: Mag
199593 by: Chris Dowell
199594 by: Gryffyn, Trevor
199595 by: Mag
199598 by: Pankaj Kafley
199600 by: Jonel Rienton
199602 by: Gryffyn, Trevor
Re: Problem with MSSQL
199597 by: Greg Donald
Re: throw me a bone for a regexp please.
199599 by: Robet Carson
199601 by: Matt M.
199611 by: Robet Carson
Help with parsing result code
199603 by: Carlos Alberto Bazan-Canabal
199605 by: Matt M.
199606 by: Matt M.
199607 by: Matt M.
199612 by: Carlos Alberto Bazan-Canabal
Re: PHP 5.0.2 & LDAP SASL Binds (GSSAPI specifically)
199604 by: Curt Zirzow
Advanced maths help (part 2)
199609 by: Mag
199614 by: Gryffyn, Trevor
199616 by: Mag
199617 by: Gryffyn, Trevor
199620 by: Chris Dowell
199621 by: Mag
Re: PHP 5.02 and Fedora Core 2 Installation question
199610 by: Brad Pauly
Getting info off an HTTPS page
199613 by: Carlos Alberto Bazan-Canabal
199615 by: Manuel Lemos
Print window function???
199618 by: Tony Kim
199619 by: Steve Murphy
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
Hi,
Could anyone help me with a reugular expression for a UK mobile phone
number?
So far I have tried this but with no success
<snip>
$regexp = "/^447[0-9]{9}$/";
if(!preg_match( $regexp, $_POST[mobile_number] )){
$error = "Invalid Mobile Number";
</snip>
The number nust be 11 numbers long, be all numbers, have no spaces and begin
with 447.
Any help would be greatly appreciated...
attached mail follows:
Do you even need a regex?
What about
if (strlen($_POST['mobile_number']) != 11 &&
substr($_POST['mobile_number'],0,3) != 447)
{
$error="Invalid Number";
}
On 15 Oct 2004, at 13:38, Shaun wrote:
> Hi,
>
> Could anyone help me with a reugular expression for a UK mobile phone
> number?
>
> So far I have tried this but with no success
>
> <snip>
> $regexp = "/^447[0-9]{9}$/";
> if(!preg_match( $regexp, $_POST[mobile_number] )){
> $error = "Invalid Mobile Number";
> </snip>
>
> The number nust be 11 numbers long, be all numbers, have no spaces and
> begin
> with 447.
>
> Any help would be greatly appreciated...
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
attached mail follows:
On Fri, 2004-10-15 at 07:45, Gareth Williams wrote:
> Do you even need a regex?
>
> What about
>
> if (strlen($_POST['mobile_number']) != 11 &&
> substr($_POST['mobile_number'],0,3) != 447)
> {
> $error="Invalid Number";
> }
This doesn't verify that the portion following 447 is also a number.
eg. 4474567X901
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. |
`------------------------------------------------------------'
attached mail follows:
On Friday 15 October 2004 19:38, Shaun wrote:
> Could anyone help me with a reugular expression for a UK mobile phone
> number?
>
> So far I have tried this but with no success
>
> <snip>
> $regexp = "/^447[0-9]{9}$/";
> if(!preg_match( $regexp, $_POST[mobile_number] )){
> $error = "Invalid Mobile Number";
> </snip>
>
> The number nust be 11 numbers long, be all numbers, have no spaces and
> begin with 447.
11 minus 3 = 8?
--
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
------------------------------------------
/*
When nothing can possibly go wrong, it will.
*/
attached mail follows:
Shaun wrote:
> Hi,
>
> Could anyone help me with a reugular expression for a UK mobile phone
> number?
>
> So far I have tried this but with no success
>
> <snip>
> $regexp = "/^447[0-9]{9}$/";
> if(!preg_match( $regexp, $_POST[mobile_number] )){
> $error = "Invalid Mobile Number";
> </snip>
>
> The number nust be 11 numbers long, be all numbers, have no spaces and begin
> with 447.
You're matching 447, then 9 numbers after that...bringing the total
numbers to 12, not 11.
$regexp = "/^447\d{8}$/";
--
By-Tor.com
It's all about the Rush
http://www.by-tor.com
attached mail follows:
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm
On 15 October 2004 12:39, Shaun wrote:
> Hi,
>
> Could anyone help me with a reugular expression for a UK mobile phone
> number?
>
> So far I have tried this but with no success
>
> <snip>
> $regexp = "/^447[0-9]{9}$/";
That expression looks perfectly valid for the conditions you have stated
(given that you meant 12 digits, not 11, which would be correct for UK
mobiles). There must be some other kind of error.
As a first step, I suggest you do a var_dump($_POST['mobile_number']) to
make sure it's exactly what you think it should be. (And, yes, you should
be quoting the index to the $_POST[] array.)
> if(!preg_match( $regexp, $_POST[mobile_number] )){
> $error = "Invalid Mobile Number";
> </snip>
>
> The number nust be 11 numbers long, be all numbers, have no
> spaces and begin
> with 447.
However, if you mean genuine mobiles, and not pagers or other follow-me type
numbers in the UK 07 range (or even completely unallocated parts of it!),
then you need to refine that pattern a bit; this should do:
$regexp = "/^447[7-9][0-9]{8}$/";
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.ford
leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
attached mail follows:
Try is_int($_POST['mobile_number']) or ctype_digit($_POST['mobile_number'])
HTH
Cheers
Chris
Robert Cummings wrote:
>On Fri, 2004-10-15 at 07:45, Gareth Williams wrote:
>
>>Do you even need a regex?
>>
>>What about
>>
>>if (strlen($_POST['mobile_number']) != 11 &&
>>substr($_POST['mobile_number'],0,3) != 447)
>>{
>> $error="Invalid Number";
>>}
>>
>
>This doesn't verify that the portion following 447 is also a number.
>
> eg. 4474567X901
>
>Cheers,
>Rob.
>
attached mail follows:
You could add is_integer() into the if statement.
On 15 Oct 2004, at 14:07, Robert Cummings wrote:
> On Fri, 2004-10-15 at 07:45, Gareth Williams wrote:
>> Do you even need a regex?
>>
>> What about
>>
>> if (strlen($_POST['mobile_number']) != 11 &&
>> substr($_POST['mobile_number'],0,3) != 447)
>> {
>> $error="Invalid Number";
>> }
>
> This doesn't verify that the portion following 447 is also a number.
>
> eg. 4474567X901
>
> 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. |
> `------------------------------------------------------------'
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
attached mail follows:
Hi,
Does anybody have any depthful knowledge of the SimpleXML extension in
PHP5?..
More accurately, do you know if the simpleXml->xpath() method uses DOM,
SAX or some other method of parsing a loaded XML document?
I ask because I am trying to parse arbitrary XML documents as efficiently
as possible (avoiding DOM).
Kieran
attached mail follows:
Hi
On 15 Oct 2004 11:51:33 -0000, PHPDiscuss - PHP Newsgroups and mailing
lists <naroth_k
wmgmail.wmg.warwick.ac.uk> wrote:
> Hi,
>
> Does anybody have any depthful knowledge of the SimpleXML extension in
> PHP5?..
>
> More accurately, do you know if the simpleXml->xpath() method uses DOM,
> SAX or some other method of parsing a loaded XML document?
>
> I ask because I am trying to parse arbitrary XML documents as efficiently
> as possible (avoiding DOM).
Hi
SimpleXML uses the same stuff as DOM in the backend. So you won't gain
any efficency using SimpleXML
chregu
>
> Kieran
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60 | fax +41 1 240 56 71
http://www.bitflux.ch | chregu
bitflux.ch | gnupg-keyid 0x5CE1DECB
attached mail follows:
Hi,
How can i add new items to an array without using an index.
Normally (single dimension) you can do: Arr[]="xxxxx" and this item is
added to the array, but what if i have subitems like:
Arr[]['name']="arnold"; Arr[]['address']="street".
This last example doesnt work and i think there will be an easy solution but
who can tell me this?
Arnold
attached mail follows:
On Fri, 2004-10-15 at 08:34, Arnold wrote:
> Hi,
>
> How can i add new items to an array without using an index.
> Normally (single dimension) you can do: Arr[]="xxxxx" and this item is
> added to the array, but what if i have subitems like:
> Arr[]['name']="arnold"; Arr[]['address']="street".
> This last example doesnt work and i think there will be an easy solution but
> who can tell me this?
You mean like this...
$sub = array
(
'name' => 'Ahhhhhnold',
'address' => '123 Someplace Nice',
);
$bigArray[] = $sub;
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. |
`------------------------------------------------------------'
attached mail follows:
try $Arr[] = array('name' => 'arnold', 'address' => 'street');
Arnold wrote:
>Hi,
>
>How can i add new items to an array without using an index.
>Normally (single dimension) you can do: Arr[]="xxxxx" and this item is
>added to the array, but what if i have subitems like:
>Arr[]['name']="arnold"; Arr[]['address']="street".
>This last example doesnt work and i think there will be an easy solution but
>who can tell me this?
>
>Arnold
>
>
>
attached mail follows:
> You mean like this...
> $sub = array
> (
> 'name' => 'Ahhhhhnold',
> 'address' => '123 Someplace Nice',
> );
>
> $bigArray[] = $sub;
Something else that will work is the following:
$arrPt =& $Arr[];
$arrPt['name'] = 'bob';
$arrPt['address'] = 'wherever';
thnx,
Chris
attached mail follows:
How come you guys always go for the simplest answer? why not do something like,
$num = count($arrPt);
$arrPt[$num]['name'] = "Figntin' Bob";
$arrPt[$num]['address'] = "Under the Broad Street Bridge";
Live a little...
-Jasper
On Fri, 15 Oct 2004 09:07:43 -0500, Chris Boget <chris.boget
wild.net> wrote:
> > You mean like this...
> > $sub = array
> > (
> > 'name' => 'Ahhhhhnold',
> > 'address' => '123 Someplace Nice',
> > );
> >
> > $bigArray[] = $sub;
>
> Something else that will work is the following:
>
> $arrPt =& $Arr[];
> $arrPt['name'] = 'bob';
> $arrPt['address'] = 'wherever';
>
> thnx,
> Chris
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
<<--------------------------------------------------------
Jasper Howard - Database Administration
ApexEleven.com
530 559 0107
------------------------------------------------------->>
attached mail follows:
test
--
c3f7bc9d7683857572da3d1fa3d31af17bde4ebbc5c0f0dc2b7f6f
attached mail follows:
Cosmin wrote:
> test
Had this been a real email, we would have been given instructions on how
to reply. This has been a test of the emergency php email broadcast system.
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
john
kegworks.com
attached mail follows:
skip the two step process and use RAND in the sql statement
SELECT * FROM table1, table2 WHERE a=b AND c<d
ORDER BY RAND() LIMIT 1000;
bastien
>From: -{ Rene Brehmer }- <metalbunny
metalbunny.net>
>To: php-db
lists.php.net,php-general
lists.php.net
>Subject: [PHP-DB] How to optimize select of random record in DB ?
>Date: Fri, 15 Oct 2004 07:41:44 +0200
>
>I made this code to pick a random record from a changeable number of
>records in a given table.
>I'm just curious if any of the more awake coders out there can see a way to
>optimize this for better performance, since there's several other DB
>queries on the same page.
>
> $records = mysql_query("SELECT COUNT(*) AS count FROM persons") or
>die('Unable to get record count<br>'.mysql_error());
> $totalcount = mysql_result($records,0) - 1;
> $rndrecord = rand(0,$totalcount);
> $personquery = mysql_query("SELECT personID FROM persons LIMIT
>$rndrecord,1") or die('Unable to get random record<br>'.mysql_error());
> $personID = mysql_result($personquery,0);
>--
>Rene Brehmer
>aka Metalbunny
>
>If your life was a dream, would you wake up from a nightmare, dripping of
>sweat, hoping it was over? Or would you wake up happy and pleased, ready to
>take on the day with a smile?
>
>http://metalbunny.net/
>References, tools, and other useful stuff...
>Check out the new Metalbunny forums at http://forums.metalbunny.net/
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
attached mail follows:
Does anyone know how i can get this following code (#1) in the
adminconfig.php script (#2).
At the moment script #2 creates a file---config.php which has the php
open/close tags plus the variables for hostname etc but i need the code #1
to be embedded below all of this but before the closing php tag, but as is
with all the indents etc.
I tried to get it to work but failed miserabley ! (is that a word)
I hope you all understand what i mean!
////////////////////////////////////////////////////////////////////////////
(#1)
///////////////////////////////////////////////////////////////////////////
$link = mysql_connect($host, $username, $password);
if(!
$link)
die("<br><br>Could not connect to MySQL");
$database = "mytipinstaller";
mysql_select_db($database)
or die ("<br><br>Could not open " . $database .mysql_error() );
////////////////////////////////////////////////////////////////////////////
/
(#2)
////////////////////////////////////////////////////////////////////////////
//
$filename="config/config.php" ;
$itemsarray = array("hostname", "user", "password") ;
if ($btnsubmit) {
foreach ($itemsarray as $value) {
${$value} = stripslashes(${$value}) ;
writeconfig($value, ${$value}) ;
}
} else {
foreach($itemsarray as $value) {
${$value} = readconfig($value) ;
}
}
function readconfig($item) {
global $filename ;
$fcontents=
file($filename) ;
if (!empty($fcontents)) {
while (list($linenum, $line) = each($fcontents)) {
if (leftside($line) == $item) {
return rightside($line) ;
break ;
}
}
}
return "" ;
}
function writeconfig($item, $value) {
global $filename ;
if (!file_exists($filename)) {
$fp = fopen($filename, "w") ;
fputs($fp, "<?php\n");
fclose($fp) ;
}
$fcontents=file($filename) ;
$fp = fopen($filename, "w") ;
$found = false ;
while (list($linenum, $line) = each($fcontents)) {
if ($line != "?>\n") {
if (leftside($line) == $item) {
fputs($fp, "\$".$item."=\"".$value."\";\n") ;
$found = true ;
} else {
fputs($fp, $line) ;
}
}
}
if (!$found) {
fputs($fp, "\$".$item."=\"".$value."\";\n") ;
}
fputs($fp, "?>\n") ;
fclose($fp) ;
}
function leftside($line) {
$pos = strpos($line, "=") ;
if ($pos === false) {
return "" ;
} else {
return substr($line, 1, $pos-1) ;
}
}
function rightside($line) {
$pos = strpos($line, "=") ;
if ($pos === false) {
return "" ;
} else {
return substr($line, ($pos+2), strlen($line)-5-strlen(leftside($line))) ;
}
}
echo "<html><body><form method=post action=\"".$PHP_SELF."\">" ;
foreach ($itemsarray as $value) {
echo "$".$value." <input type=text name=".$value." size=20
value=\"".${$value}."\"><br>" ;
}
?>
<input type=submit name=btnsubmit value=Save>
</form>
</body>
</html>
////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////
attached mail follows:
Hi!
I need someone who is very good with maths to help me
with this, unfortunatly I suck at maths so that
someone can not be me. Ironically before I started my
first computer course years back I asked the
instructer if "learning computers needed a lot of
maths...she said 'no, just basics'"..that aint really
true is it? :-D
Anyway, I have 2 scripts, one that resizes an image
according to the height and width i specify and
another that cuts a w=90 h=120 thumb from *within* an
image according to the x and y parameters I send it.
This functionality is distributed in 2 scripts.
Heres my maths problems in 2 parts:
Problem 1)
I need to scale down an image (eg: example.jpg) to
height of 120 pixels while maintaining the images
proportions.
eg:
if i have an image of (height and width) 800x600 what
would the dimensions be if the height was 120?
usually for resizeing I just do something like this:
if($image_height > 400)
{$image_height=$image_height / 2;
$image_width=$image_width / 2;}
which gets me a pretty decent image....but now I need
an image no more than 120px in height with a
proportionate width.
Problem 2)
After getting the above image now I need the x and y
parameters to cut a h120 x w90 thumb *from the center
of the image*
eg: if from problem 1 the result is an image of 120 x
160 then x=35 and y=125 (I think, i told you i suck at
maths.. :-D )
Anyone up to the challenge? or just want to help a
poor person with some maths?
Thanks in advance,
Mag
=====
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
__________________________________
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
http://promotions.yahoo.com/new_mail
attached mail follows:
Problem 1)
$h_1 = 600;
$w_1 = 800;
$h_2 = 120;
$w_2 = $w_1 * ($h_2 / $h_1);
Problem 2 a)
Assuming you're wanting the central portion of the original image (which
I think you are from what you've written)
$h_1 = 600;
$w_1 = 800;
$h_2 = 120;
$w_2 = 90;
$x = ($h_1 - $h_2) / 2;
$y = ($w_1 - $w_2) / 2;
Problem 2 b)
If you're in fact trying to get the central portion of the new thumbnail
$h_1 = 600;
$w_1 = 800;
$h_2 = 120;
$w_2 = $w_1 * ($h_2 / $h_1); // need to have the correct thumbnail
width to start from
$x = ($w_2 - 90) / 2;
$y = 0; // because the image is only 120px high
Hope this helps
Cheers
Chris
Mag wrote:<><>
> [snip]
> Heres my maths problems in 2 parts:
>
> Problem 1)
> I need to scale down an image (eg: example.jpg) to
> height of 120 pixels while maintaining the images
> proportions.
> [/snip]
> ...
> [snip]
> Problem 2)
> After getting the above image now I need the x and y
> parameters to cut a h120 x w90 thumb *from the center
> of the image*
> [/snip]
attached mail follows:
Good questions.. Here's some stuff to play with:
> Heres my maths problems in 2 parts:
>
> Problem 1)
> I need to scale down an image (eg: example.jpg) to
> height of 120 pixels while maintaining the images
> proportions.
>
> eg:
> if i have an image of (height and width) 800x600 what
> would the dimensions be if the height was 120?
Proportions can be figured out by doing cross multiplication. Say
you're trying to figure out percentages, do something like this:
x 75
----- x -------
100 185
Multiple cross ways and you get:
185x = 7500
Divide both sides by 185 to get just an "x = " and you get 40.54. 75
is 40.54% of 185.
You can use this to get your proportions for images too. It doesn't
have to be 100 at the bottom of that one side. Say you have an image
that's 1275 x 852 and you want to create a 120 x ???? Thumbnail.
1275 w 120 w
------ x -------
852 h x h
1275x = 102240 (1275 times x = 120 times 852)
Divide both sides by 1275 and you get:
X = 80.19.... Which you might round to 80.
So a 1275 x 852 image scale down to 120 x 80.
Easy, right? :)
> Problem 2)
> After getting the above image now I need the x and y
> parameters to cut a h120 x w90 thumb *from the center
> of the image*
>
> eg: if from problem 1 the result is an image of 120 x
> 160 then x=35 and y=125 (I think, i told you i suck at
> maths.. :-D )
This one's even easier. Using the same 1275 x 852 image:
1275 w - 120 w = 1155 (difference in widths)
1155 / 2 = 577.5 (578 rounded let's say). That's how much space you'll
have on either wide width-wise. That'll give you a 120w "center cut"
Do the same with the height:
852 - 90 = 762
762 / 2 = 381
So your top-left pixel to start cutting would be at 578 x 381.
Try it out and let us know how it worked.
-TG
attached mail follows:
DAMN!
2 minutes after posting to the list I get some pretty
good mails from two people with answers on how to
solve this,while i had a restless night trying to
figure this out in my head! I LOVE THIS LIST!
Thanks guys, will tell you how this goes and if i have
any problems.
Cheers,
Mag
=====
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com
attached mail follows:
Very helpful indeed. Until today I had used softwares like Photoshop
to get the exact proportion rate. This really works, thank you guys.
Cheers !!!
On Fri, 15 Oct 2004 07:05:34 -0700 (PDT), Mag <genphp
yahoo.com> wrote:
> DAMN!
> 2 minutes after posting to the list I get some pretty
> good mails from two people with answers on how to
> solve this,while i had a restless night trying to
> figure this out in my head! I LOVE THIS LIST!
>
> Thanks guys, will tell you how this goes and if i have
> any problems.
>
> Cheers,
> Mag
>
> =====
> ------
> - The faulty interface lies between the chair and the keyboard.
> - Creativity is great, but plagiarism is faster!
> - Smile, everyone loves a moron. :-)
>
> _______________________________
> Do you Yahoo!?
> Declare Yourself - Register online to vote today!
> http://vote.yahoo.com
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
it's algebra at work :)
nicely done.
On Oct 15, 2004, at 8:57 AM, Gryffyn, Trevor wrote:
> Good questions.. Here's some stuff to play with:
>
>> Heres my maths problems in 2 parts:
>>
>> Problem 1)
>> I need to scale down an image (eg: example.jpg) to
>> height of 120 pixels while maintaining the images
>> proportions.
>>
>> eg:
>> if i have an image of (height and width) 800x600 what
>> would the dimensions be if the height was 120?
>
> Proportions can be figured out by doing cross multiplication. Say
> you're trying to figure out percentages, do something like this:
>
> x 75
> ----- x -------
> 100 185
>
>
> Multiple cross ways and you get:
>
> 185x = 7500
>
> Divide both sides by 185 to get just an "x = " and you get 40.54. 75
> is 40.54% of 185.
>
>
> You can use this to get your proportions for images too. It doesn't
> have to be 100 at the bottom of that one side. Say you have an image
> that's 1275 x 852 and you want to create a 120 x ???? Thumbnail.
>
>
> 1275 w 120 w
> ------ x -------
> 852 h x h
>
>
>
> 1275x = 102240 (1275 times x = 120 times 852)
>
> Divide both sides by 1275 and you get:
>
> X = 80.19.... Which you might round to 80.
>
>
> So a 1275 x 852 image scale down to 120 x 80.
>
> Easy, right? :)
>
>
>> Problem 2)
>> After getting the above image now I need the x and y
>> parameters to cut a h120 x w90 thumb *from the center
>> of the image*
>>
>> eg: if from problem 1 the result is an image of 120 x
>> 160 then x=35 and y=125 (I think, i told you i suck at
>> maths.. :-D )
>
>
> This one's even easier. Using the same 1275 x 852 image:
>
>
> 1275 w - 120 w = 1155 (difference in widths)
>
> 1155 / 2 = 577.5 (578 rounded let's say). That's how much space you'll
> have on either wide width-wise. That'll give you a 120w "center cut"
>
> Do the same with the height:
>
> 852 - 90 = 762
>
> 762 / 2 = 381
>
>
> So your top-left pixel to start cutting would be at 578 x 381.
>
>
> Try it out and let us know how it worked.
>
> -TG
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
attached mail follows:
Algebra! I aced that in 7th grade! (don't ask me about all the other
years of math. Haha.. I think I just got bored and slept a lot or
something)
-TG
> -----Original Message-----
> From: Jonel Rienton [mailto:jonel
road14.com]
> Sent: Friday, October 15, 2004 11:02 AM
> To: Gryffyn, Trevor
> Cc: php php; Mag
> Subject: Re: [PHP] Advanced maths help (for GD image functionality)
>
>
> it's algebra at work :)
>
> nicely done.
>
>
> On Oct 15, 2004, at 8:57 AM, Gryffyn, Trevor wrote:
>
> > Good questions.. Here's some stuff to play with:
> >
> >> Heres my maths problems in 2 parts:
> >>
> >> Problem 1)
> >> I need to scale down an image (eg: example.jpg) to
> >> height of 120 pixels while maintaining the images
> >> proportions.
> >>
> >> eg:
> >> if i have an image of (height and width) 800x600 what
> >> would the dimensions be if the height was 120?
> >
> > Proportions can be figured out by doing cross multiplication. Say
> > you're trying to figure out percentages, do something like this:
> >
> > x 75
> > ----- x -------
> > 100 185
> >
> >
> > Multiple cross ways and you get:
> >
> > 185x = 7500
> >
> > Divide both sides by 185 to get just an "x = " and you get
> 40.54. 75
> > is 40.54% of 185.
> >
> >
> > You can use this to get your proportions for images too. It doesn't
> > have to be 100 at the bottom of that one side. Say you
> have an image
> > that's 1275 x 852 and you want to create a 120 x ???? Thumbnail.
> >
> >
> > 1275 w 120 w
> > ------ x -------
> > 852 h x h
> >
> >
> >
> > 1275x = 102240 (1275 times x = 120 times 852)
> >
> > Divide both sides by 1275 and you get:
> >
> > X = 80.19.... Which you might round to 80.
> >
> >
> > So a 1275 x 852 image scale down to 120 x 80.
> >
> > Easy, right? :)
> >
> >
> >> Problem 2)
> >> After getting the above image now I need the x and y
> >> parameters to cut a h120 x w90 thumb *from the center
> >> of the image*
> >>
> >> eg: if from problem 1 the result is an image of 120 x
> >> 160 then x=35 and y=125 (I think, i told you i suck at
> >> maths.. :-D )
> >
> >
> > This one's even easier. Using the same 1275 x 852 image:
> >
> >
> > 1275 w - 120 w = 1155 (difference in widths)
> >
> > 1155 / 2 = 577.5 (578 rounded let's say). That's how much
> space you'll
> > have on either wide width-wise. That'll give you a 120w
> "center cut"
> >
> > Do the same with the height:
> >
> > 852 - 90 = 762
> >
> > 762 / 2 = 381
> >
> >
> > So your top-left pixel to start cutting would be at 578 x 381.
> >
> >
> > Try it out and let us know how it worked.
> >
> > -TG
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
attached mail follows:
On Fri, 15 Oct 2004 12:42:21 +0700, Yusuf Tikupadang
<yusuf.tikupadang
gmail.com> wrote:
> I'm a new member in this mailing list.
> I have a problem with large data in mssql (more than 100.000 record in
> one table). If I want to browse it from record 10 until 19 (like when
> I press next button), php have to read all data (select * from table).
> Is it posible to read only the record that I need (from record x1
> untuk x2), without stored procedure?
> Thanks before.
http://pear.php.net/package/DB_Pager
--
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/
attached mail follows:
Thank you for the tips and the help. I really appriciate it. You
have given me something that I can use to learn regular expressions.
Thanks,
Robert
On Fri, 15 Oct 2004 11:04:57 +0800, Jason Wong <php-general
gremlins.biz> wrote:
> On Friday 15 October 2004 10:35, Robet Carson wrote:
>
>
> > need a regexp to get the contents of this marker or one very simular:
> >
> > {!STATISTICS:starbucks!}
> >
> > what I am looking for is to get the "STATISTICS" and "starbucks" into
> > an array() if possible. I believe with the correct regexp this can be
> > accomplished using preg_split() or by getting the contents of the
> > marker and explode()'ing them. also i am looking to grab several
> > strings for a marker like this, for instance.
> >
> > {!STASTISTICS:starbucks:blended:chocolate!}
> >
> > Also if someone could direct me to a site that explains how to use and
> > create regexp in a small minded manor since I have been unable to
> > grasp the concepts.
>
> A few tips for starting out with regex:
>
> 1) use PCRE, they are faster and ultimately more useful than the POSIX variety
> 2) Build up your regex step-by-step and test it at each step to see what is
> being matched and what isn't (and why it isn't)
> 3) Use parentheses () to enclose the bits you want to 'capture' (extract).
> 4) Practice
> 5) More practice
>
> So for your first example, as a first draft you can just capture everything
> between the begin marker and the end marker:
>
> $doo = '{!STATISTICS:starbucks!}';
> preg_match('/\{!(.*)!\}/', $doo, $match)
>
> $match[1] now contains: STATISTICS:starbucks
>
> You can explode() it to get the constituent parts.
>
> Or you can refine your regex:
>
> preg_match('/\{!(.*):(.*)!\}/', $doo, $match)
>
> So basically your first draft would match a large chunk of stuff, your
> successive drafts would fine-tune it until eventually you're matching exactly
> what you need.
>
> --
> 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
> ------------------------------------------
> /*
> Today you'll start getting heavy metal radio on your dentures.
> */
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
R. Carson
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GIT d s+:+ a- C++++$ ULL+++>++++$ P+>++++ L+++>+++++$ !E- W N+ !o K-?
!w--- !O !M !V PS+ PE+ Y+ PGP+ !t !5 !X R+ !tv b++ !DI !D G++ e+ h----
r+++ y++++
------END GEEK CODE BLOCK------
attached mail follows:
> Also if someone could direct me to a site that explains how to use and
> create regexp in a small minded manor since I have been unable to
> grasp the concepts.
the regex coach has been a big help to me
http://www.weitz.de/regex-coach/
you might find it useful
attached mail follows:
Thanks!
On Fri, 15 Oct 2004 10:06:15 -0500, Matt M. <h.dudeness
gmail.com> wrote:
> > Also if someone could direct me to a site that explains how to use and
> > create regexp in a small minded manor since I have been unable to
> > grasp the concepts.
>
>
> the regex coach has been a big help to me
>
> http://www.weitz.de/regex-coach/
>
> you might find it useful
>
--
R. Carson
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GIT d s+:+ a- C++++$ ULL+++>++++$ P+>++++ L+++>+++++$ !E- W N+ !o K-?
!w--- !O !M !V PS+ PE+ Y+ PGP+ !t !5 !X R+ !tv b++ !DI !D G++ e+ h----
r+++ y++++
------END GEEK CODE BLOCK------
attached mail follows:
Hi.
I'm setting up a credit card payment app. When I send the information
through the form I get a result similar to this:
NOT CAPTURED:000000:428930479495:NA:1015:9755676331042890:1:1::::
This is the only data in the result page.
I have never done parsing, and I have no idea of how to get this
information inerted into variables.
The result data is a series of data separated by ':'
Could anyone please give me a hint as of where to look for information
on how to do the parsing, or a short sample script?
And if also someone knows of a good reference manual on scraping and
parsing with PHP, I'd appreciate it.
Thx
Carlos.
attached mail follows:
> I'm setting up a credit card payment app. When I send the information
> through the form I get a result similar to this:
>
> NOT CAPTURED:000000:428930479495:NA:1015:9755676331042890:1:1::::
>
> This is the only data in the result page.
>
> I have never done parsing, and I have no idea of how to get this
> information inerted into variables.
>
> The result data is a series of data separated by ':'
>
> Could anyone please give me a hint as of where to look for information
> on how to do the parsing, or a short sample script?
http://us2.php.net/manual/en/function.preg-split.php
should do it
attached mail follows:
> http://us2.php.net/manual/en/function.preg-split.php
>
> should do it
also http://us2.php.net/explode
attached mail follows:
> http://us2.php.net/manual/en/function.preg-split.php
>
> should do it
also http://us2.php.net/explode
attached mail follows:
Thank you Matt and Ed.
I have solved the issue and started looking into parsing and regular
expressions.
Thx
Carlos.
On Fri, 15 Oct 2004 10:57:02 -0500, Matt M. <h.dudeness
gmail.com> wrote:
> > http://us2.php.net/manual/en/function.preg-split.php
> >
> > should do it
>
>
> also http://us2.php.net/explode
>
attached mail follows:
* Thus wrote Quanah Gibson-Mount:
> I see that php 5.0.2 has added the "ldap_sasl_bind" function. I compiled
> php-5.0.2 against our OpenLDAP w/ SASL support libraries, and went ahead to
> give it a whirl:
> ...
> However, what I get back is:
>
> <b>Warning</b>: ldap_sasl_bind() [<a
> href='function.ldap-sasl-bind'>function.ldap-sasl-bind</a>]: Unable to bind
> to server: Not Supported in
> <b>/afs/ir.stanford.edu/users/q/u/quanah/cgi-bin/test.cgi</b> on line
> <b>5</b><br />
>
>
> In looking at the php 5.0.2 code I see:
>
> if ((rc = ldap_sasl_interactive_bind_s(ld->link, NULL, NULL, NULL,
> NULL, LDAP_SASL_QUIET, _php_sasl_interact, NULL)) != LDAP_SUCCESS) {
You might want to contact internal
lists.php.net about this.
Curt
--
Quoth the Raven, "Nevermore."
attached mail follows:
Hi again guys, :-)
Thanks to the educated (and excellient) help of Chris
and trevor I am now getting proportionate thumbs
(which was "problem 1", remember? )
Heres the code that i am using, if it may help anyone
else:
** code start **
$src_img = imagecreatefromjpeg("tgp1.jpg");
$img_dim = getimagesize("tgp1.jpg");
$h_1 = $img_dim[1];
$w_1 = $img_dim[0];
$dst_h = 120;
$dst_w = $w_1 * ($dst_h / $h_1);
$dst_img = imagecreatetruecolor($dst_w,$dst_h);
$src_w = imagesx($src_img);
$src_h = imagesy($src_img);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$dst_w,$dst_h,$src_w,$src_h);
// problem 1 solved till here
** code end **
Then i am trying to work with problem 2, instead of
starting all over again from the beginning of getting
the images dimensions etc I am continueing and trying
to get it straight from the above like so:
** code start problem 2**
$dst_w = ($dst_w - 90) / 2;
$dst_h = 0; // because the image is only 120px high
imagecopyresampled($dst_img,$src_img,0,0,0,0,$dst_w,$dst_h,$src_w,$src_h);
ImageJPEG($dst_img,'test.jpg');
echo "<img src=test.jpg><br>The bitch works!";
** code end problem 2 **
When i check the output I am only getting the first
parts output... is what i am doing even possible? or
do I have to do everything from the start for problem
2 (eg: read from disk, calculate dimensions etc)
Thanks,
Mag
=====
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail
attached mail follows:
My interpretation of Problem 2 before was that you wanted to get a 120w
x 90h (?) section of the original image, not of the thumbnail you
generated by resizing the original.
You seem to be working off of the adjusted height.
Sorry, I didn't noodle all the way through this one, what I am missing?
-TG
> -----Original Message-----
> From: Mag [mailto:genphp
yahoo.com]
> Sent: Friday, October 15, 2004 12:45 PM
> To: php php
> Subject: [PHP] Advanced maths help (part 2)
>
>
> Hi again guys, :-)
> Thanks to the educated (and excellient) help of Chris
> and trevor I am now getting proportionate thumbs
> (which was "problem 1", remember? )
>
> Heres the code that i am using, if it may help anyone
> else:
>
> ** code start **
> $src_img = imagecreatefromjpeg("tgp1.jpg");
> $img_dim = getimagesize("tgp1.jpg");
>
> $h_1 = $img_dim[1];
> $w_1 = $img_dim[0];
>
> $dst_h = 120;
> $dst_w = $w_1 * ($dst_h / $h_1);
>
> $dst_img = imagecreatetruecolor($dst_w,$dst_h);
> $src_w = imagesx($src_img);
> $src_h = imagesy($src_img);
> imagecopyresampled($dst_img,$src_img,0,0,0,0,$dst_w,$dst_h,$sr
> c_w,$src_h);
> // problem 1 solved till here
> ** code end **
>
>
> Then i am trying to work with problem 2, instead of
> starting all over again from the beginning of getting
> the images dimensions etc I am continueing and trying
> to get it straight from the above like so:
>
> ** code start problem 2**
> $dst_w = ($dst_w - 90) / 2;
> $dst_h = 0; // because the image is only 120px high
>
> imagecopyresampled($dst_img,$src_img,0,0,0,0,$dst_w,$dst_h,$sr
> c_w,$src_h);
>
> ImageJPEG($dst_img,'test.jpg');
> echo "<img src=test.jpg><br>The bitch works!";
> ** code end problem 2 **
>
> When i check the output I am only getting the first
> parts output... is what i am doing even possible? or
> do I have to do everything from the start for problem
> 2 (eg: read from disk, calculate dimensions etc)
>
> Thanks,
> Mag
>
>
>
> =====
> ------
> - The faulty interface lies between the chair and the keyboard.
> - Creativity is great, but plagiarism is faster!
> - Smile, everyone loves a moron. :-)
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail Address AutoComplete - You start. We finish.
> http://promotions.yahoo.com/new_mail
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
Hi Trevor,
Sorry, am just a bit confused myself mostly because I
am using a third party script to clip the 120x90 part
out of the image...understanding the way the script is
written is a little frustrating as it was written for
something else and I am trying to adopt it.
if you want to try your hand at it tell me and i'll
zip up the script and send it to you.
Thanks,
Mag
--- "Gryffyn, Trevor" <TGryffyn
air-cargo-inc.com>
wrote:
> My interpretation of Problem 2 before was that you
> wanted to get a 120w
> x 90h (?) section of the original image, not of the
> thumbnail you
> generated by resizing the original.
>
> You seem to be working off of the adjusted height.
>
> Sorry, I didn't noodle all the way through this one,
> what I am missing?
>
> -TG
>
> > -----Original Message-----
> > From: Mag [mailto:genphp
yahoo.com]
> > Sent: Friday, October 15, 2004 12:45 PM
> > To: php php
> > Subject: [PHP] Advanced maths help (part 2)
> >
> >
> > Hi again guys, :-)
> > Thanks to the educated (and excellient) help of
> Chris
> > and trevor I am now getting proportionate thumbs
> > (which was "problem 1", remember? )
> >
> > Heres the code that i am using, if it may help
> anyone
> > else:
> >
> > ** code start **
> > $src_img = imagecreatefromjpeg("tgp1.jpg");
> > $img_dim = getimagesize("tgp1.jpg");
> >
> > $h_1 = $img_dim[1];
> > $w_1 = $img_dim[0];
> >
> > $dst_h = 120;
> > $dst_w = $w_1 * ($dst_h / $h_1);
> >
> > $dst_img = imagecreatetruecolor($dst_w,$dst_h);
> > $src_w = imagesx($src_img);
> > $src_h = imagesy($src_img);
> >
>
imagecopyresampled($dst_img,$src_img,0,0,0,0,$dst_w,$dst_h,$sr
> > c_w,$src_h);
> > // problem 1 solved till here
> > ** code end **
> >
> >
> > Then i am trying to work with problem 2, instead
> of
> > starting all over again from the beginning of
> getting
> > the images dimensions etc I am continueing and
> trying
> > to get it straight from the above like so:
> >
> > ** code start problem 2**
> > $dst_w = ($dst_w - 90) / 2;
> > $dst_h = 0; // because the image is only 120px
> high
> >
> >
>
imagecopyresampled($dst_img,$src_img,0,0,0,0,$dst_w,$dst_h,$sr
> > c_w,$src_h);
> >
> > ImageJPEG($dst_img,'test.jpg');
> > echo "<img src=test.jpg><br>The bitch works!";
> > ** code end problem 2 **
> >
> > When i check the output I am only getting the
> first
> > parts output... is what i am doing even possible?
> or
> > do I have to do everything from the start for
> problem
> > 2 (eg: read from disk, calculate dimensions etc)
> >
> > Thanks,
> > Mag
> >
> >
> >
> > =====
> > ------
> > - The faulty interface lies between the chair and
> the keyboard.
> > - Creativity is great, but plagiarism is faster!
> > - Smile, everyone loves a moron. :-)
> >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Mail Address AutoComplete - You start. We
> finish.
> > http://promotions.yahoo.com/new_mail
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit:
> http://www.php.net/unsub.php
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
=====
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com
attached mail follows:
No worries. But here's my thought:
1. You start with an image, getting it's current (original) proportions
2. You figure out the width and height proportions to resize it down to
something small
3. Resize image (creating a new image.. At least to send to the browser
if not in a file separate from the original..whichever works for you)
4. Take the original image (not the resized one) and clip a little
section out of the middle of it to use as a thumbnail as well (or
whatever).
I think this is what you are aiming for because there are two theories
regarding thumbnails:
A. Take the original and scale it down.. But this can create an image
that doesn't look like anything (if the original had a lot of detail
and/or was huge)
B. Take a portion of the original (like someone's face out of a scene
that really shows their whole body). This can sometimes be fun because
it shows a small portion of an image that can make people curious.. Like
"What the heck is that I'm seeing? I have to see more!"
I'm not sure if that's what you were planning to do or not. Why don't
you detail your intentions and then maybe we can figure out how to best
do that.
-TG
> -----Original Message-----
> From: Mag [mailto:genphp
yahoo.com]
> Sent: Friday, October 15, 2004 2:00 PM
> To: Gryffyn, Trevor
> Cc: php php
> Subject: RE: [PHP] Advanced maths help (part 2)
>
>
> Hi Trevor,
>
> Sorry, am just a bit confused myself mostly because I
> am using a third party script to clip the 120x90 part
> out of the image...understanding the way the script is
> written is a little frustrating as it was written for
> something else and I am trying to adopt it.
>
> if you want to try your hand at it tell me and i'll
> zip up the script and send it to you.
>
> Thanks,
> Mag
attached mail follows:
I think you've a couple of problems with your second problem (problem
problem problem).
First of all, you're setting $dst_h to 0, which gives you a height of 0
- IIRC that's not what you wanted :)
You should be setting that $dst_h = 120 as you always want it to be 120px
I reckon that your code should look more like this:
<?php
// assuming that we're creating two thumbnails, one has h=120, w=?, the
second has h=120, w=90
// we'll also assume that the original has h=600, w=800
$src_img = imagecreatefromjpeg("tgp1.jpg");
$src_h = imagesy($src_img); // 600
$src_w = imagesx($src_img); // 800
$dst_h = 120;
$dst_w = $src_w * ($dst_h / $src_h);
$dst_img = imagecreatetruecolor($dst_w,$dst_h);
imagecopyresampled ($dst_img, $srcImage, 0, 0, 0, 0, $dst_w, $dst_h, $src_w, $src_h);
// so far so good, now, lets save the file
imagejpeg($dst_img, 'test.jpg');
unset($dst_img);
// time for problem 2
// first we need a h=120, w=90 image
// image size for h=120, w=90 thumbnail
$dst_h = 120;
$dst_w = 90;
$dst_img = imagecreatetruecolor($dst_w, $dst_h);
// we will be copying to the top left corner of the new thumbnail
$dst_x = 0;
$dst_y = 0;
// now, let's find the top-left offset from the larger original image
$src_x = ($src_h - $dst_h) / 2;
$src_y = ($src_w - $dst_w) / 2;
// no need for imagecopyresampled as we'll be doing 1-1 pixel copying here
imagecopy ($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $src_w,
$src_h);
// so far so good, now, lets save the file
imagejpeg($dst_img, 'test2.jpg');
unset($dst_img);
?>
<img src="test.jpg" /><img src="test2.jpg" />
------------
Hope this helps (although I haven't tested it)
Cheers
Chris
Mag wrote:
>Hi again guys, :-)
>Thanks to the educated (and excellient) help of Chris
>and trevor I am now getting proportionate thumbs
>(which was "problem 1", remember? )
>
>Heres the code that i am using, if it may help anyone
>else:
>
>** code start **
>$src_img = imagecreatefromjpeg("tgp1.jpg");
>$img_dim = getimagesize("tgp1.jpg");
>
>$h_1 = $img_dim[1];
>$w_1 = $img_dim[0];
>
>$dst_h = 120;
>$dst_w = $w_1 * ($dst_h / $h_1);
>
>$dst_img = imagecreatetruecolor($dst_w,$dst_h);
>$src_w = imagesx($src_img);
>$src_h = imagesy($src_img);
>imagecopyresampled($dst_img,$src_img,0,0,0,0,$dst_w,$dst_h,$src_w,$src_h);
>// problem 1 solved till here
>** code end **
>
>
>Then i am trying to work with problem 2, instead of
>starting all over again from the beginning of getting
>the images dimensions etc I am continueing and trying
>to get it straight from the above like so:
>
>** code start problem 2**
>$dst_w = ($dst_w - 90) / 2;
>$dst_h = 0; // because the image is only 120px high
>
>imagecopyresampled($dst_img,$src_img,0,0,0,0,$dst_w,$dst_h,$src_w,$src_h);
>
>ImageJPEG($dst_img,'test.jpg');
>echo "<img src=test.jpg><br>The bitch works!";
>** code end problem 2 **
>
>When i check the output I am only getting the first
>parts output... is what i am doing even possible? or
>do I have to do everything from the start for problem
>2 (eg: read from disk, calculate dimensions etc)
>
>Thanks,
>Mag
>
>
>
>=====
>------
>- The faulty interface lies between the chair and the keyboard.
>- Creativity is great, but plagiarism is faster!
>- Smile, everyone loves a moron. :-)
>
>
>
>__________________________________
>Do you Yahoo!?
>Yahoo! Mail Address AutoComplete - You start. We finish.
>http://promotions.yahoo.com/new_mail
>
>
attached mail follows:
Hey Chris,
Thanks for replying.
Dont worry about it, I got so p*ssed that I just
striped the whole thing down to pretty much just the
imagecopyresized() function, fiddled around with it to
see how it works and got the sh*t working. The good
thing now is I understand a bit better how the
function works and thanks to you and Trever I learnt
how the first problem works too, not a bad day at all
if I say so myself.
Working on other parts of the scripts now so have not
uploaded the working parts but if you would like to
see it working, just reply.
Cheers,
Mag
> I think you've a couple of problems with your second
> problem (problem
> problem problem).
>
> First of all, you're setting $dst_h to 0, which
> gives you a height of 0
> - IIRC that's not what you wanted :)
>
> You should be setting that $dst_h = 120 as you
> always want it to be 120px
>
> I reckon that your code should look more like this:
>
> <?php
>
> // assuming that we're creating two thumbnails, one
> has h=120, w=?, the
> second has h=120, w=90
> // we'll also assume that the original has h=600,
> w=800
>
> $src_img = imagecreatefromjpeg("tgp1.jpg");
>
> $src_h = imagesy($src_img); // 600
> $src_w = imagesx($src_img); // 800
>
> $dst_h = 120;
> $dst_w = $src_w * ($dst_h / $src_h);
>
> $dst_img = imagecreatetruecolor($dst_w,$dst_h);
>
> imagecopyresampled ($dst_img, $srcImage, 0, 0, 0, 0,
> $dst_w, $dst_h, $src_w, $src_h);
>
> // so far so good, now, lets save the file
> imagejpeg($dst_img, 'test.jpg');
>
> unset($dst_img);
>
> // time for problem 2
>
> // first we need a h=120, w=90 image
>
> // image size for h=120, w=90 thumbnail
> $dst_h = 120;
> $dst_w = 90;
>
> $dst_img = imagecreatetruecolor($dst_w, $dst_h);
>
> // we will be copying to the top left corner of the
> new thumbnail
> $dst_x = 0;
> $dst_y = 0;
>
> // now, let's find the top-left offset from the
> larger original image
> $src_x = ($src_h - $dst_h) / 2;
> $src_y = ($src_w - $dst_w) / 2;
>
> // no need for imagecopyresampled as we'll be doing
> 1-1 pixel copying here
>
> imagecopy ($dst_img, $src_img, $dst_x, $dst_y,
> $src_x, $src_y, $src_w,
> $src_h);
>
> // so far so good, now, lets save the file
> imagejpeg($dst_img, 'test2.jpg');
>
> unset($dst_img);
>
> ?>
> <img src="test.jpg" /><img src="test2.jpg" />
>
> ------------
>
> Hope this helps (although I haven't tested it)
>
> Cheers
>
> Chris
>
>
>
> Mag wrote:
>
> >Hi again guys, :-)
> >Thanks to the educated (and excellient) help of
> Chris
> >and trevor I am now getting proportionate thumbs
> >(which was "problem 1", remember? )
> >
> >Heres the code that i am using, if it may help
> anyone
> >else:
> >
> >** code start **
> >$src_img = imagecreatefromjpeg("tgp1.jpg");
> >$img_dim = getimagesize("tgp1.jpg");
> >
> >$h_1 = $img_dim[1];
> >$w_1 = $img_dim[0];
> >
> >$dst_h = 120;
> >$dst_w = $w_1 * ($dst_h / $h_1);
> >
> >$dst_img = imagecreatetruecolor($dst_w,$dst_h);
> >$src_w = imagesx($src_img);
> >$src_h = imagesy($src_img);
>
>imagecopyresampled($dst_img,$src_img,0,0,0,0,$dst_w,$dst_h,$src_w,$src_h);
> >// problem 1 solved till here
> >** code end **
> >
> >
> >Then i am trying to work with problem 2, instead of
> >starting all over again from the beginning of
> getting
> >the images dimensions etc I am continueing and
> trying
> >to get it straight from the above like so:
> >
> >** code start problem 2**
> >$dst_w = ($dst_w - 90) / 2;
> >$dst_h = 0; // because the image is only 120px
> high
> >
>
>imagecopyresampled($dst_img,$src_img,0,0,0,0,$dst_w,$dst_h,$src_w,$src_h);
> >
> >ImageJPEG($dst_img,'test.jpg');
> >echo "<img src=test.jpg><br>The bitch works!";
> >** code end problem 2 **
> >
> >When i check the output I am only getting the first
> >parts output... is what i am doing even possible?
> or
> >do I have to do everything from the start for
> problem
> >2 (eg: read from disk, calculate dimensions etc)
> >
> >Thanks,
> >Mag
> >
> >
> >
> >=====
> >------
> >- The faulty interface lies between the chair and
> the keyboard.
> >- Creativity is great, but plagiarism is faster!
> >- Smile, everyone loves a moron. :-)
> >
> >
> >
> >__________________________________
> >Do you Yahoo!?
> >Yahoo! Mail Address AutoComplete - You start. We
> finish.
> >http://promotions.yahoo.com/new_mail
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
=====
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com
attached mail follows:
On Thu, 14 Oct 2004 16:30:42 -0400, Don <donpro
lclnav.com> wrote:
> Has anyone had any luck installing with the --with-imap configuration
> option. IMAP doesn't seem to be installed (nor imap-devel) and the c
> library specified in the docs at php.net does not compile.
I am also trying to do this. Dovecot is the default IMAP server on
FC2. I haven't had time to try it yet, but here is a link I found
about compiling PHP with dovecot:
http://www.dovecot.org/list/dovecot/2004-July/004282.html
I should have a chance to try later today and will let you know if I
have any luck.
Brad
attached mail follows:
Hi,
I am working on setting up a VPOS system, and I need to read the
results of sending the CC information to the bank.
When sending the form I am doing it with HTTPS port 443 with POST
method in my form and application/www-form-urlencoded
When I get the results of my submission I get another https URL .
Since I send the form using POST, I get no params in the URL. BTW, GET
is not supported.
What I need to do is be able to read the results of that page so I can
parse them and have the machine understand what was the result of the
credit card charge.
Any idea of how I can get to save the results of that page into a variable?
Thanks!
Carlos.
attached mail follows:
Hello,
On 10/15/2004 02:24 PM, Carlos Alberto Bazan-Canabal wrote:
> I am working on setting up a VPOS system, and I need to read the
> results of sending the CC information to the bank.
>
> When sending the form I am doing it with HTTPS port 443 with POST
> method in my form and application/www-form-urlencoded
>
> When I get the results of my submission I get another https URL .
> Since I send the form using POST, I get no params in the URL. BTW, GET
> is not supported.
>
> What I need to do is be able to read the results of that page so I can
> parse them and have the machine understand what was the result of the
> credit card charge.
>
> Any idea of how I can get to save the results of that page into a variable?
You can either use Curl functions or fsockopen with OpenSSL support,
depending on what is available on your system.
You may want to try this HTTP client class that supports submitting POST
requests via SSL as you need in a very simple way and it figures which
PHP extension to use to send your requests and collecting the responses
if possible with your PHP setup.
http://www.phpclasses.org/httpclient
--
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
attached mail follows:
Is there a function for print window in php? I tried javascript
window.print() but this doesn't work in ie 5.2 on mac. Thanks.
attached mail follows:
Web standards my friend.
Use CSS, learn from the master: http://www.alistapart.com/articles/goingtoprint/
-----Original Message-----
From: Tony Kim [mailto:kim
acca.com]
Sent: Friday, October 15, 2004 3:10 PM
To: php-general
lists.php.net
Subject: [PHP] Print window function???
Is there a function for print window in php? I tried javascript
window.print() but this doesn't work in ie 5.2 on mac. Thanks.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]