php-general Digest 15 Oct 2004 10:29:28 -0000 Issue 3054

2004-10-15 Thread php-general-digest-help

php-general Digest 15 Oct 2004 10:29:28 - Issue 3054

Topics (messages 199541 through 199574):

Re: include()ing into a variable
199541 by: Curt Zirzow

Re: Help with sessions problem please
199542 by: John Holmes

For how long session exist
199543 by: Jerry Swanson
199545 by: John Holmes
199547 by: Dan Joseph

Re: Form Validation
199544 by: Jerry Swanson

Ask for help on a mysql problem
199546 by: Teng Wang
199554 by: John Nichel

problem with array
199548 by: Dale Hersowitz
199551 by: Jason Wong
199552 by: Minuk Choi
199564 by: Graham Cossey

replacing characters in a string
199549 by: Mark Hubert
199550 by: Dan Joseph
199560 by: Robby Russell

throw me a bone for a regexp please.
199553 by: Robet Carson
199556 by: Jason Wong

PHP 5.0.2  LDAP SASL Binds (GSSAPI specifically)
199555 by: Quanah Gibson-Mount

Re: dbm choices - advice?
199557 by: Justin French

How to optimize select of random record in DB ?
199558 by: -{ Rene Brehmer }-
199561 by: Matthew Weier O'Phinney
199562 by: Gareth Williams

Problem with MSSQL
199559 by: Yusuf Tikupadang

PHP-CGI: custom 404 error?
199563 by: Jared
199565 by: Christophe Chisogne

PHP App User Permissions Tecnique
199566 by: Brendon
199567 by: Yusuf Tikupadang
199571 by: Ian Firla

PHP websites (www/uk/us2)
199568 by: Graham Cossey
199572 by: Yusuf Tikupadang
199573 by: Lester Caine
199574 by: Ford, Mike

Re: 答复: [PHP] Problem with MSSQL
199569 by: Yusuf Tikupadang
199570 by: Yusuf Tikupadang

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]


--
---BeginMessage---
* Thus wrote Mag:
 Hi Curt,
 Thanks for replying.
 
  $obSaveFile = new SaveToFile();
  $obSaveFile-open('/path/to/file.html');
  ob_start(array($obSaveFile, 'save'), 1024);
  
  /* do your stuff  here */
  
  ob_end_flush();
  $obSaveFile-close();
 
 
 Problem is, I have not really learnt classes as yet, I
 know how to use them but I really have no idea as to
 how to make them. Looking at your above code I see you
 are calling open() and close() of the class but not
 write() is that a mistake or just my lack of
 understanding of classes? (No idea what this:
 $obSaveFile 
 means either)

Oops, yeah the ob_start should have been:
  ob_start(array($obSaveFile, 'write'), 1024);

The $ in $obSaveFile uses a reference instead of a copy of the
object (an old php4 trick, see more on references)

What will happen is anytime PHP's output buffer decides to write
the contents of the buffer, in this case I told it to do it when
ever 1024 bytes where collected, it will call:

  $obSaveFile-write($contents_of_buffer);

Then your write() class method will write the buffer contents to
the file handle you opened in open().

the ob_end_flush() forces the rest of the buffer (1024) to get sent too to
your write() class method, ensuring everything is written.


 Also I have heard that outbuffering can be quite
 complicated, would you mind filling in your example a
 bit more and I can make add to it and work from there?

Here is the class in full (w/o error checking):

class SaveToFile {
  var $file_handle;

  function open($file)  {
$this-file_handle = fopen($file, 'w');
  }
  function write($buf) {
fwrite($this-file_handle, $buf);
  }
  function close() {
fclose($this-file_handle);
  }
}

Curt
-- 
Quoth the Raven, Nevermore.
---End Message---
---BeginMessage---
Chris Shiflett wrote:
--- John Holmes [EMAIL PROTECTED] wrote:
header('Location: http://www.example.org/script2.php?.SID);
He is human after all. :-)
That's just a rumour' I started...
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
---End Message---
---BeginMessage---
For what period of time a session can exist? Or session exist as soon
as browser is open?
TH
---End Message---
---BeginMessage---
Jerry Swanson wrote:
For what period of time a session can exist? Or session exist as soon
as browser is open?
1. For as long as the user is active
2. Depends on what page the browser opens
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
---End Message---
---BeginMessage---
  For what period of time a session can exist? Or session exist as soon
  as browser is open?
 
 1. For as long as the user is active
 2. Depends on what page the browser opens

I'm gonna elaborate a bit...

In your php.ini there is a session idle timeout setting.  The
inactivity John mentioned is set there.  

[PHP] Re: How to optimize select of random record in DB ?

2004-10-15 Thread Matthew Weier O'Phinney
* -{ Rene Brehmer }- [EMAIL PROTECTED]:
 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 countbr'.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 recordbr'.mysql_error());
$personID = mysql_result($personquery,0);

Since you're using mysql, why not use the RAND() function?

$sql = SELECT personID FROM persons ORDER BY RAND() LIMIT 1;
$query = mysql_query($sql) or die(Unable to get random record);
$personID = mysql_result($query, 0);

I've used this quite a bit -- much easier than using PHP to do it.

-- 
Matthew Weier O'Phinney   | mailto:[EMAIL PROTECTED]
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org

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



Re: [PHP] How to optimize select of random record in DB ?

2004-10-15 Thread Gareth Williams
What about in MySQL:
SELECT personID from persons ORDER BY RAND(NOW()) LIMIT 1
If the table is large, then the following might be better:
LOCK TABLES foo READ;
SELECT FLOOR(RAND() * COUNT(*)) AS rand_row FROM foo;
SELECT * FROM foo LIMIT $rand_row, 1;
UNLOCK TABLES;
There's a whole discussion on it in the MySQL documentation web site:
http://dev.mysql.com/doc/mysql/en/SELECT.html
On 15 Oct 2004, at 07:41, -{ Rene Brehmer }- wrote:
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 countbr'.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 
recordbr'.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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] PHP-CGI: custom 404 error?

2004-10-15 Thread Jared
I'm running PHP as CGI instead of as an apache module because my hosting 
1) suggests it and 2) this way I can compile my own PHP with whatever 
options I want, including a custom php.ini.

Works great except when I load a page that doesn't exist, such as 
foo.php, I get No input file specified. Instead of the standard 404 
error. Is there a way to customize this?

I've read about it and the consensus is that you can't. I don't 
understand why not, though. Wouldn't it be easy to add a custom 404 
error page via php.ini or something?

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



RE: [PHP] problem with array

2004-10-15 Thread Graham Cossey
 Hi guys,
 Recently, I had to reformat one of the web servers and now I have
 encountered an unusual problem. I am not sure whether this is an
 issue which
 can be fixed in the .ini file or whether its specific to the
 version of php
 I am using.

 Here is the problem:
$query=SELECT * FROM customizeViewClients WHERE employeeNum =
 $employeeNum;
$results=mssql_query($query, $connection) or die(Couldn't execute
 query);
$numRows=mssql_num_rows($results);

 if($numRows0)
{
  $row=mssql_fetch_array($results);
 }

  $selectedCol=$row[selectedCol];
   echo $selectedCol;
  $selectedColName=$row[$selectCol];   //--- PLEASE NOTE THIS SPECIFIC
ROW
[snip]

Note because you used $selectCol instead of $selectedCol?

I would also move the } to after this line so that you do not attempt to
access non-existent array elements when no rows are returned.

HTH

Graham

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



Re: [PHP] PHP-CGI: custom 404 error?

2004-10-15 Thread Christophe Chisogne
Jared wrote:
foo.php, I get No input file specified. Instead of the standard 404 
error. Is there a way to customize this?
Easy with Apache [1,2], with en ErrorDocument [1] directive.
Ex with this in a .htaccess (the FileInfo Override [3] is required)
containing this line:
ErrorDocument 404 /Lame_excuses/not_found.html
I've read about it and the consensus is that you can't.
Upgrade consensus :)
Wouldn't it be easy to add a custom 404 
error page via php.ini or something?
Easy with Apache (.htaccess or httpd.conf). Ok, not via php.ini.
Christophe
[1] ErrorDocument directive
http://httpd.apache.org/docs/mod/core.html#errordocument
[2] Using XSSI and ErrorDocument to configure customized international server error 
responses
http://httpd.apache.org/docs/misc/custom_errordocs.html
[3] AllowOverride directive
http://httpd.apache.org/docs/mod/core.html#allowoverride
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] PHP App User Permissions Tecnique

2004-10-15 Thread Brendon
I am building a web based community forum type software using PHP. I am 
currently working on how different user privelages are handled. Each 
user is part of a group and each group has varying degrees of privelages.

I need to add in functionality which at the begginning of every script 
check the permission level of the user accessing the page. There are 
about 15 different permissions.

I am debating whether i should store all the permission abilities into 
session variables and they can quickly be checked throughout the script, 
or whether i should query the database to check to see if the user has 
adequate group permissions to perform a certain function.

Could someone give me some advice as to which would be more advisable?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP App User Permissions Tecnique

2004-10-15 Thread Yusuf Tikupadang
I think read from database better than from session, because it's more
easy than usnig session.

On Fri, 15 Oct 2004 00:41:31 -0700, Brendon [EMAIL PROTECTED] wrote:
 I am building a web based community forum type software using PHP. I am
 currently working on how different user privelages are handled. Each
 user is part of a group and each group has varying degrees of privelages.
 
 I need to add in functionality which at the begginning of every script
 check the permission level of the user accessing the page. There are
 about 15 different permissions.
 
 I am debating whether i should store all the permission abilities into
 session variables and they can quickly be checked throughout the script,
 or whether i should query the database to check to see if the user has
 adequate group permissions to perform a certain function.
 
 Could someone give me some advice as to which would be more advisable?


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



[PHP] PHP websites (www/uk/us2)

2004-10-15 Thread Graham Cossey

I was wondering what the difference is between the various PHP sites linked
to in this list, are they mirrors and what determines which site you get
directed to when doing a search from www.php.net?

http://www.php.net
http://uk.php.net
http://us2.php.net

and presumably others...


Thanks

Graham

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



[PHP] Re: : [PHP] Problem with MSSQL

2004-10-15 Thread Yusuf Tikupadang
 I don't know if this can running on mssql.
 select  limit m,n
No, mssql can't do that. the only solution that i have is using
cursor, but I can't use codecharge to do that (and need much more time
to develop).
Thanks for your idea.

Best Regards,
Yusuf Tikupadang

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



[PHP] Re: : [PHP] Problem with MSSQL

2004-10-15 Thread Yusuf Tikupadang
 I don't know if this can running on mssql.
 select  limit m,n
No, mssql can't do that. the only solution that i have is using
cursor, but I can't use codecharge to do that (and need much more time
to develop).
Thanks for your idea.

Best Regards,
Yusuf Tikupadang

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



Re: [PHP] PHP App User Permissions Tecnique

2004-10-15 Thread Ian Firla

Definitely store them in a session. A db lookup will mean a much heavier
and process intensive procedure.

Ian

On Fri, 2004-10-15 at 09:41, Brendon wrote:
 I am building a web based community forum type software using PHP. I am 
 currently working on how different user privelages are handled. Each 
 user is part of a group and each group has varying degrees of privelages.
 
 I need to add in functionality which at the begginning of every script 
 check the permission level of the user accessing the page. There are 
 about 15 different permissions.
 
 I am debating whether i should store all the permission abilities into 
 session variables and they can quickly be checked throughout the script, 
 or whether i should query the database to check to see if the user has 
 adequate group permissions to perform a certain function.
 
 Could someone give me some advice as to which would be more advisable?

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



Re: [PHP] PHP websites (www/uk/us2)

2004-10-15 Thread Yusuf Tikupadang
They're mirrors.


On Fri, 15 Oct 2004 09:20:10 +0100, Graham Cossey
[EMAIL PROTECTED] wrote:
 
 I was wondering what the difference is between the various PHP sites linked
 to in this list, are they mirrors and what determines which site you get
 directed to when doing a search from www.php.net?
 
 http://www.php.net
 http://uk.php.net
 http://us2.php.net
 
 and presumably others...
 
 Thanks
 
 Graham
 
 --
 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



[PHP] Re: PHP websites (www/uk/us2)

2004-10-15 Thread Lester Caine
Graham Cossey wrote:
I was wondering what the difference is between the various PHP sites linked
to in this list, are they mirrors and what determines which site you get
directed to when doing a search from www.php.net?
If you download you will be directed to a mirror, and that will then be 
used as your default location. I tend to use the uk one myself.

The problem comes when you quote links and include your mirror in that - 
just a problem that the Internet has yet to overcome. Perhaps local ip 
addresses could be picked up by an ISP for things like google or php - 
that would help reduce long distance traffic ;)

--
Lester Caine
-
L.S.Caine Electronic Services
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] PHP websites (www/uk/us2)

2004-10-15 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 15 October 2004 10:00, Yusuf Tikupadang wrote:

 They're mirrors.
 
 
 On Fri, 15 Oct 2004 09:20:10 +0100, Graham Cossey
 [EMAIL PROTECTED] wrote:
  
  I was wondering what the difference is between the various PHP
  sites linked to in this list, are they mirrors and what determines
  which site you get directed to when doing a search from www.php.net?
  
  http://www.php.net
  http://uk.php.net
  http://us2.php.net
  
  and presumably others...

Yes -- http://www.php.net/mirrors.php for a full list.

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: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



Re: [PHP] Regular Expression for a UK Mobile

2004-10-15 Thread Gareth Williams
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] SimpleXML: DOM, SAX or Other?

2004-10-15 Thread PHPDiscuss - PHP Newsgroups and mailing lists
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

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



[PHP] Regular Expression for a UK Mobile

2004-10-15 Thread Shaun
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



Re: [PHP] Regular Expression for a UK Mobile

2004-10-15 Thread Robert Cummings
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



Re: [PHP] Regular Expression for a UK Mobile

2004-10-15 Thread Jason Wong
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.
*/

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



Re: [PHP] Regular Expression for a UK Mobile

2004-10-15 Thread John Nichel
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Regular Expression for a UK Mobile

2004-10-15 Thread Ford, Mike
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: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



[PHP] add item to end of (multidimensional) array

2004-10-15 Thread Arnold
Hi,

How can i add new items to an array without using an index.
Normally (single dimension) you can do:  Arr[]=x 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

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



Re: [PHP] add item to end of (multidimensional) array

2004-10-15 Thread Robert Cummings
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[]=x 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' = 'Ahnold',
'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.  |
`'

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



Re: [PHP] add item to end of (multidimensional) array

2004-10-15 Thread Chris Dowell
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[]=x 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
 

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


Re: [PHP] Regular Expression for a UK Mobile

2004-10-15 Thread Chris Dowell
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.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Regular Expression for a UK Mobile

2004-10-15 Thread Gareth Williams
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] SimpleXML: DOM, SAX or Other?

2004-10-15 Thread Christian Stocker
Hi


On 15 Oct 2004 11:51:33 -, PHPDiscuss - PHP Newsgroups and mailing
lists [EMAIL PROTECTED] 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  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

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



[PHP] test

2004-10-15 Thread Cosmin
test
-- 
c3f7bc9d7683857572da3d1fa3d31af17bde4ebbc5c0f0dc2b7f6f


[PHP] RE: [PHP-DB] How to optimize select of random record in DB ?

2004-10-15 Thread Bastien Koert
skip the two step process and use RAND in the sql statement
SELECT * FROM table1, table2 WHERE a=b AND cd
ORDER BY RAND() LIMIT 1000;
bastien
From: -{ Rene Brehmer }- [EMAIL PROTECTED]
To: [EMAIL PROTECTED],[EMAIL PROTECTED]
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 countbr'.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 recordbr'.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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] test

2004-10-15 Thread John Nichel
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
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Advanced maths help (for GD image functionality)

2004-10-15 Thread Mag
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 imagebut 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

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



Re: [PHP] Advanced maths help (for GD image functionality)

2004-10-15 Thread Chris Dowell
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]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Advanced maths help (for GD image functionality)

2004-10-15 Thread Gryffyn, Trevor
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



RE: [PHP] Advanced maths help (for GD image functionality)

2004-10-15 Thread Mag
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



Re: [PHP] add item to end of (multidimensional) array

2004-10-15 Thread Chris Boget
 You mean like this...
 $sub = array
 (
 'name' = 'Ahnold',
 '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



Re: [PHP] Problem with MSSQL

2004-10-15 Thread Greg Donald
On Fri, 15 Oct 2004 12:42:21 +0700, Yusuf Tikupadang
[EMAIL PROTECTED] 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/

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



Re: [PHP] Advanced maths help (for GD image functionality)

2004-10-15 Thread Pankaj Kafley
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 [EMAIL PROTECTED] 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
 


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



Re: [PHP] throw me a bone for a regexp please.

2004-10-15 Thread Robet Carson
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 [EMAIL PROTECTED] 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--

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



Re: [PHP] Advanced maths help (for GD image functionality)

2004-10-15 Thread Jonel Rienton
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] throw me a bone for a regexp please.

2004-10-15 Thread Matt M.
 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

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



RE: [PHP] Advanced maths help (for GD image functionality)

2004-10-15 Thread Gryffyn, Trevor
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:[EMAIL PROTECTED] 
 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
 
 
 

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



[PHP] Help with parsing result code

2004-10-15 Thread Carlos Alberto Bazan-Canabal
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:00: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.

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



Re: [PHP] PHP 5.0.2 LDAP SASL Binds (GSSAPI specifically)

2004-10-15 Thread Curt Zirzow
* 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:
 
 bWarning/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 
 b5/bbr /
 
 
 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 [EMAIL PROTECTED] about this.

Curt
-- 
Quoth the Raven, Nevermore.

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



Re: [PHP] Help with parsing result code

2004-10-15 Thread Matt M.
 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:00: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

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



Re: [PHP] Help with parsing result code

2004-10-15 Thread Matt M.
 http://us2.php.net/manual/en/function.preg-split.php
 
 should do it


also http://us2.php.net/explode

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



Re: [PHP] add item to end of (multidimensional) array

2004-10-15 Thread ApexEleven
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 [EMAIL PROTECTED] wrote:
  You mean like this...
  $sub = array
  (
  'name' = 'Ahnold',
  '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
---

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



[PHP] Advanced maths help (part 2)

2004-10-15 Thread Mag
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.jpgbrThe 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



Re: [PHP] PHP 5.02 and Fedora Core 2 Installation question

2004-10-15 Thread Brad Pauly
On Thu, 14 Oct 2004 16:30:42 -0400, Don [EMAIL PROTECTED] 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

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



Re: [PHP] throw me a bone for a regexp please.

2004-10-15 Thread Robet Carson
Thanks!


On Fri, 15 Oct 2004 10:06:15 -0500, Matt M. [EMAIL PROTECTED] 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--

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



Re: [PHP] Help with parsing result code

2004-10-15 Thread Carlos Alberto Bazan-Canabal
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. [EMAIL PROTECTED] wrote:
  http://us2.php.net/manual/en/function.preg-split.php
 
  should do it
 
 
 also http://us2.php.net/explode


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



[PHP] Getting info off an HTTPS page

2004-10-15 Thread Carlos Alberto Bazan-Canabal
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.

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



RE: [PHP] Advanced maths help (part 2)

2004-10-15 Thread Gryffyn, Trevor
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:[EMAIL PROTECTED] 
 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.jpgbrThe 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



[PHP] Re: Getting info off an HTTPS page

2004-10-15 Thread Manuel Lemos
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Advanced maths help (part 2)

2004-10-15 Thread Mag
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 [EMAIL PROTECTED]
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:[EMAIL PROTECTED] 
  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.jpgbrThe 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

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



RE: [PHP] Advanced maths help (part 2)

2004-10-15 Thread Gryffyn, Trevor
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:[EMAIL PROTECTED] 
 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

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



[PHP] Print window function???

2004-10-15 Thread Tony Kim
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



RE: [PHP] Print window function???

2004-10-15 Thread Steve Murphy
Web standards my friend.

Use CSS, learn from the master: http://www.alistapart.com/articles/goingtoprint/

-Original Message-
From: Tony Kim [mailto:[EMAIL PROTECTED]
Sent: Friday, October 15, 2004 3:10 PM
To: [EMAIL PROTECTED]
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


Re: [PHP] Advanced maths help (part 2)

2004-10-15 Thread Chris Dowell
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.jpgbrThe 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


Re: [PHP] Advanced maths help (part 2)

2004-10-15 Thread Mag
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.jpgbrThe 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

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



[PHP] php_printer functions, how to detect printer is ready to print out

2004-10-15 Thread CK
Hi.

I am currently working on a project that the script should print-out 
documents whenever local users wishe to print-out.

However, my concern is how to detect THE printer is ready to print out NOT 
only its driver is installed.

Thank you in advance.
CK 

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



Re: [PHP] PHP 5.02 and Fedora Core 2 Installation question

2004-10-15 Thread Brad Pauly
On Fri, 15 Oct 2004 10:49:27 -0600, Brad Pauly [EMAIL PROTECTED] wrote:
 
 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

For anyone that is trying to compile 5.0.2 with imap support (dovecot)
on Fedora Core 2, the above link does the trick. At least it did for
me =)

Brad

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



Re: [PHP] Problem with MSSQL

2004-10-15 Thread Yusuf Tikupadang
Thanks, I will try it first


On Fri, 15 Oct 2004 09:26:21 -0500, Greg Donald [EMAIL PROTECTED] wrote:
 http://pear.php.net/package/DB_Pager
 
 --
 Greg Donald
 Zend Certified Engineer
 http://gdconsultants.com/
 http://destiney.com/

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



[PHP] Best way to figure out whether a query returns RESULT or NON-RESULT

2004-10-15 Thread Karam Chand
Hello,

I have an app where one module is similar to
phpMyAdmin (well only .1%) with error_reporting() set
to E_ALL.

Now a user can execute any query. What is the best way
to know whether a query is result or non-result.

e.g.



$result  = mysql_query ( $query, $mysql );

if ( !$result ) {
 HandleError ( mysql_errno(), mysql_error() );
 return;
}

if ( !mysql_num_rows ( $result )  !mysql_num_fields
( $result ) )
{
// handle non_result values
return;
}

// handle result values

 

The problem is that if its an Update stmt. php throws
up an error that $result in mysql_num_rows() is not a
valid handle.

Moreover, from the manual - mysql_affected_rows() does
not work with SELECT statements; only on statements
which modify records. So to use it I have to figure
out if its a non-SELECT statement  

What you PHP gurus suggest the best way to handle such
situations?

Thanks in advance 

Regards,
Karam



___
Do you Yahoo!?
Express yourself with Y! Messenger! Free. Download now. 
http://messenger.yahoo.com

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