php-general Digest 30 Nov 2005 14:19:38 -0000 Issue 3824

2005-11-30 Thread php-general-digest-help

php-general Digest 30 Nov 2005 14:19:38 - Issue 3824

Topics (messages 226612 through 226638):

checkboxes
226612 by: blackwater dev
226618 by: Matt Monaco
226624 by: Curt Zirzow

url vs dirname(__FILE__)
226613 by: Chris
226616 by: Chris Shiflett

help avoid multiple login
226614 by: mail.pmpa
226615 by: mail.pmpa
226627 by: Mark Rees
226628 by: Jochem Maas

Re: PhpMailer vs Pear:Mail
226617 by: Manuel Lemos
226620 by: Curt Zirzow

How do i display a neat table of returned mysql data?
226619 by: Dave Carrera
226634 by: Ciprian Constantinescu

Re: Two version of PHP in single server
226621 by: Curt Zirzow

Re: when to enter submitted in mysql?
226622 by: Curt Zirzow

Re: migrating from http to https...
226623 by: Curt Zirzow

GD2 Question
226625 by: Karuna
226626 by: Jochem Maas
226635 by: Ciprian Constantinescu
226636 by: Jochem Maas

MVC platform choice.
226629 by: Gregory Machin
226631 by: Fabiano Ricci

imap_mail_move
226630 by: Georgi Ivanov

Re: Howto search in SQL for a specific character?
226632 by: Jesús Fernández
226633 by: Ciprian Constantinescu
226637 by: Albert

Re: Merging two images (GD  PNG)
226638 by: Albert

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:
php-general@lists.php.net


--
---BeginMessage---
I have a form where I am dynamically building a bunch of checkbox
inputs.  Then when submitted, I need to update the db.  Problem is, of
course, if the checkbox is unchecked then the $_POST doesn't have the
value in the array.  How can I get the value from $_POST even though
it's unchecked?

For example, here would be the generated form:

input type=checkbox name=cars[2] value=1Car 1
input type=checkbox name=cars[3] value=1Car 2
input type=checkbox name=cars[4] value=1Car 3
input type=checkbox name=cars[5] value=1Car 4

Then in the update I loop through:

foreach($_POST[cars] as $id=$value){
//update vehicles set value to yes or no

}

But, if the unchecked values aren't in $_POST, how do I know to update them???

Thanks!
---End Message---
---BeginMessage---
Well if your keys are a straight sequence of numbers instead of a foreach 
you can do a for loop and for those whose value is not one, set to zero.

Matt


blackwater dev [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
I have a form where I am dynamically building a bunch of checkbox
inputs.  Then when submitted, I need to update the db.  Problem is, of
course, if the checkbox is unchecked then the $_POST doesn't have the
value in the array.  How can I get the value from $_POST even though
it's unchecked?

For example, here would be the generated form:

input type=checkbox name=cars[2] value=1Car 1
input type=checkbox name=cars[3] value=1Car 2
input type=checkbox name=cars[4] value=1Car 3
input type=checkbox name=cars[5] value=1Car 4

Then in the update I loop through:

foreach($_POST[cars] as $id=$value){
//update vehicles set value to yes or no

}

But, if the unchecked values aren't in $_POST, how do I know to update 
them???

Thanks! 
---End Message---
---BeginMessage---
On Tue, Nov 29, 2005 at 10:15:36PM -0500, blackwater dev wrote:
 I have a form where I am dynamically building a bunch of checkbox
 inputs.  Then when submitted, I need to update the db.  Problem is, of
 course, if the checkbox is unchecked then the $_POST doesn't have the
 value in the array.  How can I get the value from $_POST even though
 it's unchecked?
 
 For example, here would be the generated form:
 
 input type=checkbox name=cars[2] value=1Car 1
 input type=checkbox name=cars[3] value=1Car 2
 input type=checkbox name=cars[4] value=1Car 3
 input type=checkbox name=cars[5] value=1Car 4
 
 Then in the update I loop through:
 
 foreach($_POST[cars] as $id=$value){
 //update vehicles set value to yes or no
 
 }

This is a good example on how *not* to trust data via form data
posted.  I'm assuming you have some sort of one to many relation
going on:

  table lot {
id int,
lot varchar(255)  -- Lot 1 
  }

  table vehicles {
id int,
name varchar(255) -- Car 1, Car 2, etc... 
  }

  table lotvehicle {
lot_id int,
vehicle_id int,
  }

The form value of cars[X] where X being the id of vehicle and the
value of 1 being it is selected (although with  the form definition
you just want to know if if cars[X] is defined.).

So we have a form that will eventually need to knnow  what values
should be selected. Potentially data alreadly exists that may have
the same records. There are two options (or perhaps more) to
approach this:

Decide as we go approach and clean up:

  1) Grap the 'vehicles' currently assoicated with 

[PHP] GD2 Question

2005-11-30 Thread Karuna
Hi. Is possible to calculate the filesize of image that will result from
using imagejpeg without actually writing to disk?

Thanks :)

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



Re: [PHP] GD2 Question

2005-11-30 Thread Jochem Maas

Karuna wrote:

Hi. Is possible to calculate the filesize of image that will result from
using imagejpeg without actually writing to disk?

Thanks :)



something like (although its not very efficient, I think):

ob_start();
image_jpeg($im); // $im is an GD resource
$data = ob_get_contents();
ob_end_clean;

$byteCount = strlen($data);

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



[PHP] Re: help avoid multiple login

2005-11-30 Thread Mark Rees
 the normal way of doing session 'closing' is by way of 'garbage
collection'
 - every now and then a script/process/function is run that 'closes' any
 sessions which are (according to your criteria) inactive. php has stuff
 built it that will do this for you to a degree.
 -

 Is there a way I can access sessions from other users on a script?
 If yes I could store the session id on a table and later check if isset.

You could write the session id into a table when the session is started,
along with the start time.
Something like

sessionid CHAR|starttime DATETIME|lastvisittime DATETIME

You could then update this table each time the user visits a page, and
delete it if the interval between starttime and lastvisittime is longer than
you want. A cron job/scheduled task could be used to clean this table up
periodically

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



Re: [PHP] Re: help avoid multiple login

2005-11-30 Thread Jochem Maas

Mark Rees wrote:

the normal way of doing session 'closing' is by way of 'garbage


collection'


- every now and then a script/process/function is run that 'closes' any
sessions which are (according to your criteria) inactive. php has stuff
built it that will do this for you to a degree.
-

Is there a way I can access sessions from other users on a script?


what exactly do you mean by that last sentence? I don't quite follow it.


If yes I could store the session id on a table and later check if isset.



You could write the session id into a table when the session is started,
along with the start time.
Something like

sessionid CHAR|starttime DATETIME|lastvisittime DATETIME

You could then update this table each time the user visits a page, and
delete it if the interval between starttime and lastvisittime is longer than
you want. A cron job/scheduled task could be used to clean this table up
periodically


a nice description of 'session garbage collection' :-) 
which is pretty much all you can do in terms of 'logoff'.





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



[PHP] imap_mail_move

2005-11-30 Thread Georgi Ivanov
Hi ,
I'm trying to move some mail from one dir to another:
$mbox=imap_open(...);
imap_mail_move($mbox,2,INBOX,Sent) or die (imap_last_error());

I get this error : 
error in imap command received by server .

I'm not sure what this error means. Any suggestions?
Thanks in advance.

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



Re: [PHP] MVC platform choice.

2005-11-30 Thread Fabiano Ricci
Have a look at http://znf.zeronotice.com/

this framework is young but very good and easy to use. It's written in PHP5 
and supports also PDO. 


On Wednesday 30 November 2005 12:04, Gregory Machin wrote:
 Hi..
 Any body recomend a good MVC platform that is easy to work with, and build
 on...
 I'm looking at cakephp, solar, php on trax..

 Anything better out there.
 --
 Gregory Machin
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 www.linuxpro.co.za
 www.exponent.co.za
 Web Hosting Solutions
 Scalable Linux Solutions
 www.iberry.info (support and admin)

 +27 72 524 8096

-- 
Fabiano Ricci

  HomePage   --:. http://www.stalsy.it
  Blog   --:. http://blog.stalsy.com
  Public Key --:. http://www.stalsy.it/key.php
  E-Mail --:. [EMAIL PROTECTED] || [EMAIL PROTECTED]
  ICQ--:. 302346155
  MSN--:. [EMAIL PROTECTED]


pgpouWYeLHaf3.pgp
Description: PGP signature


Re: [PHP] Howto search in SQL for a specific character?

2005-11-30 Thread Jesús Fernández
$sql = SELECT nameOfPedigree FROM tbpedigrees WHERE  nameOfPedigree like
'\'%' ;

Maybe this could work...

--
El único error real es aquel en el que no hemos aprendido nada.


Re: [PHP] Howto search in SQL for a specific character?

2005-11-30 Thread Ciprian Constantinescu
The ' character has to be escaped. Try using \'
Gustav Wiberg [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi

 I'm sorry but this didn't work either? If I replaced the ' with for
example
 an a it worked

 /G

 - Original Message - 
 From: Stephen Johnson [EMAIL PROTECTED]
 To: Gustav Wiberg [EMAIL PROTECTED]; PHP General
 php-general@lists.php.net
 Sent: Tuesday, November 29, 2005 10:00 PM
 Subject: Re: [PHP] Howto search in SQL for a specific character?


  Try this :
 
  $sql = SELECT nameOfPedigree FROM tbpedigrees WHERE  nameOfPedigree
like
  '%;
 
  The % is a wildcard and will give you the results you want.
 
 
  ?php
  /*
 
  Stephen Johnson c | eh
  The Lone Coder
 
  http://www.ouradoptionblog.com
  Join our journey of adoption
 
  http://www.thelonecoder.com
  [EMAIL PROTECTED]
 
  continuing the struggle against bad code
 
  */
  ?
 
 
  From: Gustav Wiberg [EMAIL PROTECTED]
  Organization: Gustav Wiberg
  Reply-To: Gustav Wiberg [EMAIL PROTECTED]
  Date: Tue, 29 Nov 2005 21:55:27 +0100
  To: PHP General php-general@lists.php.net
  Subject: [PHP] Howto search in SQL for a specific character?
 
  Hi there!
 
  in PHP i Write..
 
 
  $v1 = chr(39); //39 is apostrofe
 
 
  $sql = SELECT nameOfPedigree FROM tbpedigrees WHERE
  SUBSTR(nameOfPedigree,0,1) = $v1;
 
  Why doesn't this work?
 
  I want the sql to select all nameOfPedigree - fields where the first
  character is apostrofe (')
 
  /G
  http://www.varupiraten.se/
 
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 


smime.p7s
Description: S/MIME cryptographic signature


[PHP] Re: How do i display a neat table of returned mysql data?

2005-11-30 Thread Ciprian Constantinescu
First of all this is not automatic. You can do this with a foreach loop. If
you want nice presentations, you might as well try http://smarty.php.net


Dave Carrera [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi List,

 I have some mysql table data that i would like to display back to the
 web user in a neat and tidy way using php.

 Data:

 col1   col2   col3
 test   1.99   F
 test   1.99   F
 test   1.99   F
 test   0.99   F
 test   1.99   F
 bang 2.99   F
 bang 3.99   F
 bang 4.49   F
 bang 2.99   F
 bang 2.99   F

 Table display i am hoping to display:
 First the unique name of col1 as a header

 tabletrtdtest/tdtdbang/td/tr/table

 Second a row each for each col2 and col3 where header above = col1 so
 the finished table looks like this

 test   bang
 1.99   F2.99   F
 1.99   F3.99   F
 1.99   F4.49   F
 0.99   F2.99   F
 1.99   F2.99   F

 I will really appreiciate and help you may give with this question.

 Thank you in advance

 Dave C


smime.p7s
Description: S/MIME cryptographic signature


Re: [PHP] GD2 Question

2005-11-30 Thread Ciprian Constantinescu
Not efficient, because the actual size on the disk depends on the
filesystem. I don't think you can find out before writing it to the disk

Jochem Maas [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Karuna wrote:
  Hi. Is possible to calculate the filesize of image that will result from
  using imagejpeg without actually writing to disk?
 
  Thanks :)
 

 something like (although its not very efficient, I think):

 ob_start();
 image_jpeg($im); // $im is an GD resource
 $data = ob_get_contents();
 ob_end_clean;

 $byteCount = strlen($data);


smime.p7s
Description: S/MIME cryptographic signature


Re: [PHP] GD2 Question

2005-11-30 Thread Jochem Maas

Ciprian Constantinescu wrote:

Not efficient, because the actual size on the disk depends on the
filesystem. I don't think you can find out before writing it to the disk


excuse me but:

1. the OP asked for the size of the file, not the number of bytes it takes
up on disk (which are eaten up in fixed increments aka clusters) - then again
chances are the OP didn't consider that there may be a difference, so he'll have
to figure out which of the 2 number is actually important to him.

2. you don't seem to know what 'efficient' means, generating a wrong (in your
opinion) size consitutes wrongness not inefficiency. I called it inefficient
because it requires that the whole file is read into php's memoryspace.




Jochem Maas [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]


Karuna wrote:


Hi. Is possible to calculate the filesize of image that will result from
using imagejpeg without actually writing to disk?

Thanks :)



something like (although its not very efficient, I think):

ob_start();
image_jpeg($im); // $im is an GD resource
$data = ob_get_contents();
ob_end_clean;

$byteCount = strlen($data);


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



RE: [PHP] Howto search in SQL for a specific character?

2005-11-30 Thread Albert
Gustav Wiberg wrote:
  $v1 = chr(39); //39 is apostrofe
 
 
  $sql = SELECT nameOfPedigree FROM tbpedigrees WHERE
  SUBSTR(nameOfPedigree,0,1) = $v1;
 
  Why doesn't this work?
 
  I want the sql to select all nameOfPedigree - fields where the first
  character is apostrofe (')

Here is what I have done using MySQL:

** Create a table:
mysql CREATE TABLE `tablename` (
- `id` tinyint(3) unsigned NOT NULL auto_increment,
- `name` char(20) default '0',
- PRIMARY KEY  (`id`)
- );
Query OK, 0 rows affected (0.06 sec)

** Then insert some data into the table:
mysql INSERT INTO tablename (id, name) VALUES (NULL, '\'Albert');
Query OK, 1 row affected (0.00 sec)

mysql INSERT INTO tablename (id, name) VALUES (NULL, '\'Piet');
Query OK, 1 row affected (0.00 sec)

mysql INSERT INTO tablename (id, name) VALUES (NULL, '\'Koos');
Query OK, 1 row affected (0.00 sec)

mysql INSERT INTO tablename (id, name) VALUES (NULL, 'Jan');
Query OK, 1 row affected (0.00 sec)

mysql INSERT INTO tablename (id, name) VALUES (NULL, 'Gert');
Query OK, 1 row affected (0.00 sec)

** Then retrieve all the record starting with an apostrophe ('):
mysql SELECT * FROM tablename WHERE name LIKE '\'%';
++-+
| id | name|
++-+
|  1 | 'Albert |
|  2 | 'Piet   |
|  3 | 'Koos   |
++-+
3 rows in set (0.00 sec)

Hope it helps

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.10/188 - Release Date: 2005/11/29
 

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



[PHP] FW: Merging two images (GD PNG)

2005-11-30 Thread Albert
I have two images which I want to overlay on each other.

Image1 is a satellite image.
Image2 is contains the statistical data we collected. It has a transparent
background and should be overlaid on top of the satellite image.

Both are in PNG format.

My current code:

?
$dataImage = imagecreate(1000, 1000);
$dIBack = imagecolorallocate($dataImage, 199, 199, 199);
imagecolortransparent($dataImage, $dIBack);
  $darkGreen= imagecolorallocate($tileImage, 2,   123, 48 );
  $grey = imagecolorallocate($tileImage, 118, 131, 120);
  $fuchsia  = imagecolorallocate($tileImage, 255, 0,   255);
  $aqua = imagecolorallocate($tileImage, 113, 168, 194);
  $brown= imagecolorallocate($tileImage, 177, 170, 107);
  $offwhite = imagecolorallocate($tileImage, 187, 210, 193);
  $black= imagecolorallocate($tileImage, 0,   0,   0  );
  $blue = imagecolorallocate($tileImage, 0,   0,   255);
  $red  = imagecolorallocate($tileImage, 255, 0,   0  );
  $yellow   = imagecolorallocate($tileImage, 255, 255, 0  );

/* Code to draw data on image comes here */

$satImage = imagecreatefrompng(‘sat_image.png’);

$mergedImage = imagecreate(1000, 1000);
  imagealphablending($mergedImage, true);
imagecopy($mergedImage, $satImage, 0, 0, 0, 0, 1000, 1000);
imagecopy($mergedImage, $dataImage, 0, 0, 0, 0, 1000, 1000);

imagepng($mergedImage, ‘merged_image.png’);

imagedestroy($mergedImage);
imagedestroy($satImage);
imagedestroy($dataImage);
?
 
Notes:
1. When using imagecreatetruecolor the images turn black
2. When using imagealphablending = true or imagealphablending = false 
   with imagecopy the result is the same. The top image is shown but it is 
   almost transparent. Some images are also discoloured.
3. When using imagecopymerge to copy with a pct value of 99, and commenting 
   out the imagealphablending line the top image does not appear at all
4. When using imagecopymerge to copy with a pct value of 99, and 
   imagealphablending=true, it has the same result as 2. above.
5. When using imagecopymerge to copy with a pct value of 50, and 
   Imagealphablending=true, it has the same result as 2. above.

What is the effect of the pct value of imagecopymerge?

Should I be using different values for the pct value of imagecopymerge or is
there an alternative method which will do what I want to be done?

It seems to me that the palette used in the top image is not merged with the
palette used in the satellite image.

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.10/188 - Release Date: 2005/11/29
 

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



Re: [PHP] FW: Merging two images (GD PNG)

2005-11-30 Thread Jochem Maas

imagecreatetruecolor() is probably what your after:

http://php.net/imagecreatetruecolor

Albert wrote:

I have two images which I want to overlay on each other.

Image1 is a satellite image.
Image2 is contains the statistical data we collected. It has a transparent
background and should be overlaid on top of the satellite image.

Both are in PNG format.

My current code:

?
$dataImage = imagecreate(1000, 1000);
$dIBack = imagecolorallocate($dataImage, 199, 199, 199);
imagecolortransparent($dataImage, $dIBack);
  $darkGreen= imagecolorallocate($tileImage, 2,   123, 48 );
  $grey = imagecolorallocate($tileImage, 118, 131, 120);
  $fuchsia  = imagecolorallocate($tileImage, 255, 0,   255);
  $aqua = imagecolorallocate($tileImage, 113, 168, 194);
  $brown= imagecolorallocate($tileImage, 177, 170, 107);
  $offwhite = imagecolorallocate($tileImage, 187, 210, 193);
  $black= imagecolorallocate($tileImage, 0,   0,   0  );
  $blue = imagecolorallocate($tileImage, 0,   0,   255);
  $red  = imagecolorallocate($tileImage, 255, 0,   0  );
  $yellow   = imagecolorallocate($tileImage, 255, 255, 0  );

/* Code to draw data on image comes here */

$satImage = imagecreatefrompng(‘sat_image.png’);

$mergedImage = imagecreate(1000, 1000);
  imagealphablending($mergedImage, true);
imagecopy($mergedImage, $satImage, 0, 0, 0, 0, 1000, 1000);
imagecopy($mergedImage, $dataImage, 0, 0, 0, 0, 1000, 1000);

imagepng($mergedImage, ‘merged_image.png’);

imagedestroy($mergedImage);
imagedestroy($satImage);
imagedestroy($dataImage);
?
 
Notes:

1. When using imagecreatetruecolor the images turn black
2. When using imagealphablending = true or imagealphablending = false 
   with imagecopy the result is the same. The top image is shown but it is 
   almost transparent. Some images are also discoloured.
3. When using imagecopymerge to copy with a pct value of 99, and commenting 
   out the imagealphablending line the top image does not appear at all
4. When using imagecopymerge to copy with a pct value of 99, and 
   imagealphablending=true, it has the same result as 2. above.
5. When using imagecopymerge to copy with a pct value of 50, and 
   Imagealphablending=true, it has the same result as 2. above.


What is the effect of the pct value of imagecopymerge?

Should I be using different values for the pct value of imagecopymerge or is
there an alternative method which will do what I want to be done?

It seems to me that the palette used in the top image is not merged with the
palette used in the satellite image.

Albert



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



Re: [PHP] MVC platform choice.

2005-11-30 Thread Greg Donald

On Wed, 30 Nov 2005, Gregory Machin wrote:


Hi..
Any body recomend a good MVC platform that is easy to work with,
and build on...
I'm looking at cakephp, solar, php on trax..

Anything better out there.


Rubyonrails:

http://www.rubyonrails.com/

It's certainly better than any PHP MVC framework I've ever used.


--
Greg Donald
Zend Certified Engineer
MySQL Core Certification
http://destiney.com/

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



Re: [PHP] checkboxes

2005-11-30 Thread Brent Baisley
Excellent response. You should always be expecting certain data. So  
if no checkboxes are checked, your code should realize that since it  
was expecting the data and none was submitted.
The lazy way is much easier to code, but it is actually fairly  
efficient. You are only hitting the database twice, once of the  
delete and once for the bulk insert. On a fixed record length table,  
the lazy way may actually be quicker.


On Nov 30, 2005, at 2:23 AM, Curt Zirzow wrote:


So we have a form that will eventually need to knnow  what values
should be selected. Potentially data alreadly exists that may have
the same records. There are two options (or perhaps more) to
approach this:

Decide as we go approach and clean up:

  1) Grap the 'vehicles' currently assoicated with the 'lot'
  2) if 'vehicle' is currently selected do nothing
  3) if 'vehicle' is a new item we should add 'vehicle' as long as it
 is a valid 'vehicle;
  4) repeat 2 and 3 until we looked at all the data
  5) figure out which ones should be deleted and delete them.


Forget everything, we'll add what is valid (the lazy way):

  1) delete every associated record to the 'lot'
  2) for each 'vehicle' add 'vehicle' as long as it is a valid
 'vehicle'



--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search  Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577

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



[PHP] PHP on Mobile Devices(Pocket PC specifically)

2005-11-30 Thread Kilbride, James
Does anybody know of a way to run PHP files on a windows mobile
device(Pocket PC 2003)? Optimally I'd like to run it under a web server
running on the mobile device itself but barring that I'll take some form
of command line I guess. Realize that the mobile device will NOT be
running any active network connectivity. For all intents and purposes
the individual is sitting in a wireless empty room with no land
connectivity talking to the mobile device. I haven't been able to find
any web servers that run on the Pocket PC that can be viewed by the
mobile IE(or mobile Opera either I guess) when it doesn't have active
connectivity, at which point I might as well just be using a server for
all of the mobile devices rather than hiding it on the mobile device.

James Kilbride


RE: [PHP] FW: Merging two images (GD PNG)

2005-11-30 Thread Albert
Jochem Maas wrote:
 imagecreatetruecolor() is probably what your after:
 
 http://php.net/imagecreatetruecolor

 Albert wrote:
  Notes:
  1. When using imagecreatetruecolor the images turn black

I did try imagecreatetruecolor() but then the images turn black.

Albert

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



[PHP] XSS via curl

2005-11-30 Thread Sandy Keathley
My company uses a home-grown formmail script for clients 
groan, and someone is using curl to inject HTTP headers and 
spam email addresses, and turn it into an open relay. Yes, I know 
the right answer is to not use a formmail, but I don't make the rules 
here.

Is there a way to detect that a script is being accessed by curl, and 
not by a browser?  ENV ($_SERVER) variables won't work, as 
those can be forged.

Thanks.

Sandy Keathley

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



Re: [PHP] PHP on Mobile Devices(Pocket PC specifically)

2005-11-30 Thread Jason Wong
On Wednesday 30 November 2005 22:48, Kilbride, James wrote:
 Does anybody know of a way to run PHP files on a windows mobile
 device(Pocket PC 2003)? Optimally I'd like to run it under a web server
 running on the mobile device itself but barring that I'll take some
 form of command line I guess. Realize that the mobile device will NOT
 be running any active network connectivity. For all intents and
 purposes the individual is sitting in a wireless empty room with no
 land connectivity talking to the mobile device. I haven't been able to
 find any web servers that run on the Pocket PC that can be viewed by
 the mobile IE(or mobile Opera either I guess) when it doesn't have
 active connectivity, at which point I might as well just be using a
 server for all of the mobile devices rather than hiding it on the
 mobile device.

If you're willing to ditch the windows mobile requirement (Wince/WM is 
crap anyway) then you could have a look at the Sharp Zaurus series. Run 
www.pocketworkstation.org on one of the Zaurus and you'll have access to 
most of Debian in the palm of your hand. I've successfully run FUDforum 
using Apache2/PHP4/MySQL on my Zaurus. Ruby on Rails works as well albeit 
a tad slow -- I need to figure out how to get fastcgi working. And unlike 
WM devices, you can run *real* browsers, Firefox and Mozilla are 
available.

-- 
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
--
New Year Resolution: Ignore top posted posts

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



Re: [PHP] XSS via curl

2005-11-30 Thread Jochem Maas

Sandy Keathley wrote:
My company uses a home-grown formmail script for clients 
groan, and someone is using curl to inject HTTP headers and 
spam email addresses, and turn it into an open relay. Yes, I know 


1. cut out the ability for the poster (form submitter) to determine who is 
addressed.
2. strip out anything thst looks like its trying to be a mail 'field' in 
submitted
content.
3. use a CAPTCHA.
4. ask the 'Zend Certified Engineer' in your office???

the right answer is to not use a formmail, but I don't make the rules 
here.


Is there a way to detect that a script is being accessed by curl, and 
not by a browser?  ENV ($_SERVER) variables won't work, as 
those can be forged.


no. the webserver only sees the incoming request - given that what
is sent (the _complete_ request) is totaly up to the client how could you
possibly tell who/what sent the request (other than trusting the client that
its telling the truth)?

granted there may be ways (hackish or not) to make some kind of determination
as to the legitimacy of the client - but that is probably in the realm of
if you have to ask  



Thanks.

Sandy Keathley



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



Re: [PHP] XSS via curl

2005-11-30 Thread Chris Shiflett

Sandy Keathley wrote:

My company uses a home-grown formmail script for clients
groan, and someone is using curl to inject HTTP headers
and spam email addresses, and turn it into an open relay.
Yes, I know the right answer is to not use a formmail,
but I don't make the rules here.

Is there a way to detect that a script is being accessed
by curl, and not by a browser?


It sounds like you have a PHP script with a security vulnerability, and 
you think that restricting what the client uses to request the script is 
going to fix it. This is not a good approach. Just fix the problem. :-)


For example, filter the data you receive from the client before passing 
it as arguments to the mail() function.


Hope that helps.

Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

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



[PHP] Lowest PHP version to work with MySQL 4.1.x

2005-11-30 Thread AmirBehzad Eslami
Hi List,

I have noted that some versions of PHP are unable to work with MySQL 4.1.x.

1) Should I upgrade to PHP 5?
2) What is the lowest PHP version which works fine with MySQL 4.1.x?

Regards,
Behzad

P.S.
I don't use Improved MySQL extension in PHP.
I just need MySQL 4.1.x for multi-byte character support.


RE: [PHP] PHP on Mobile Devices(Pocket PC specifically)

2005-11-30 Thread Kilbride, James
The problem with this suggestion, unless people know of a good solution,
is that I need a ruggedized mobile system with built in 2d bar code
scanner that will treat the bar code data as keyboard entry so the user,
in the web browser, basically has the curser in the right form field,
scans the bar code, and the number gets dumped in directly. I haven't
found any ruggedized, builtin mobile scanners that run linux at this
time. Anybody have any suggestions on that?(Symbol makes really nice
ruggedized pocket pc based ones with built in scanners and an
application piece that treats it as keyboard entry)

James Kilbride 

 -Original Message-
 From: Jason Wong [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, November 30, 2005 10:31 AM
 To: php-general@lists.php.net
 Subject: Re: [PHP] PHP on Mobile Devices(Pocket PC specifically)
 
 On Wednesday 30 November 2005 22:48, Kilbride, James wrote:
  Does anybody know of a way to run PHP files on a windows mobile 
  device(Pocket PC 2003)? Optimally I'd like to run it under a web 
  server running on the mobile device itself but barring that 
 I'll take 
  some form of command line I guess. Realize that the mobile 
 device will 
  NOT be running any active network connectivity. For all intents and 
  purposes the individual is sitting in a wireless empty room with no 
  land connectivity talking to the mobile device. I haven't 
 been able to 
  find any web servers that run on the Pocket PC that can be 
 viewed by 
  the mobile IE(or mobile Opera either I guess) when it doesn't have 
  active connectivity, at which point I might as well just be using a 
  server for all of the mobile devices rather than hiding it on the 
  mobile device.
 
 If you're willing to ditch the windows mobile requirement 
 (Wince/WM is crap anyway) then you could have a look at the 
 Sharp Zaurus series. Run www.pocketworkstation.org on one of 
 the Zaurus and you'll have access to most of Debian in the 
 palm of your hand. I've successfully run FUDforum using 
 Apache2/PHP4/MySQL on my Zaurus. Ruby on Rails works as well 
 albeit a tad slow -- I need to figure out how to get fastcgi 
 working. And unlike WM devices, you can run *real* browsers, 
 Firefox and Mozilla are available.
 
 --
 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
 --
 New Year Resolution: Ignore top posted posts
 
 --
 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] FW: Merging two images (GD PNG)

2005-11-30 Thread Jochem Maas

Albert wrote:

Jochem Maas wrote:


imagecreatetruecolor() is probably what your after:

http://php.net/imagecreatetruecolor

Albert wrote:


Notes:
1. When using imagecreatetruecolor the images turn black



I did try imagecreatetruecolor() but then the images turn black.


shit missed that sorry. question is where did you use then?



Albert



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



Re: [PHP] FW: Merging two images (GD PNG)

2005-11-30 Thread Jochem Maas

Albert wrote:

Jochem Maas wrote:


imagecreatetruecolor() is probably what your after:

http://php.net/imagecreatetruecolor

Albert wrote:


Notes:
1. When using imagecreatetruecolor the images turn black



I did try imagecreatetruecolor() but then the images turn black.


the output image resource you create should be created with $xxx = 
imagecreatetruecolor(1000,1000),
you should call imagealphablending($xxx, true) on the output image resource 
after you create and
before copying [which you are as far as I can tell], and you should use 
imagecopyresampled()
to actually copy the image data into the final image (instead of imagecopy()).

try this site:
http://php.amnuts.com/

I use a very hacked up version of his image masking class to do similar things 
to
what you want to do.



Albert



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



Re: [PHP] XSS via curl

2005-11-30 Thread Silvio Porcellana [tradeOver]
Sandy Keathley wrote:
 
 Is there a way to detect that a script is being accessed by curl, and 
 not by a browser?  ENV ($_SERVER) variables won't work, as 
 those can be forged.
 

Use a CAPTCHA test:
http://en.wikipedia.org/wiki/Captcha

HTH, cheers!
Silvio

-- 
tradeOver | http://www.tradeover.net
ready to become the King of the World?

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



Re: [PHP] Schroedinger's Bug - may require exorcism...

2005-11-30 Thread tg-php
What to do next?  I'd check to see if your page is being inadvertantly called 
twice (I've seen this happen when people used frames.. or like someone else 
mentioned, doing a double include() or sometimes redirecting back to itself via 
header())... anything that could possibly re-initiate the page, check into.

Failing that, do it old school...  just inserted die() statements to break 
execution at various points and see where the probably first starts occuring 
and focus in that area.  Crude but it works.  At least helps narrow down where 
the problem could be.

It doesn't do something silly like include() itself inside a conditional 
somewhere does it?

You might also echo/var_dump/print_r/whatever some of your key variables 
(especially input variables like $_GET/$_POST/etc and variables used in 
conditionals) and try to isolate what combination causes your problem.  Since 
it doesn't do it all the time, I'd guess you could have something like:

$x = 4;

if ($x  1) {
  include('someinclude.inc');
}

if ($x  5) {
  include('someinclude.inc');
}

Where 'someinclude.inc' contains your double declarations.


Next point... check your logic around your include()/require()s and such.  
Maybe you have a condition where something is falling into multiple categories.


The logic puzzle is as much about writing good logic as untangling possibly 
flawed logic.

If all else fails, trace through your code by hand... interpret it in your head 
like the computer would.. like by line.. maybe you'll see where something is 
ambiguous and under certain conditions creates a fail.

Let us know what you find.. kind of curious myself.

-TG

= = = Original message = = =

So... I have this script (being called in a perfectly typical way by  
PHP 4.4.1 through mod_php in Apache 2.0.55) which sometimes runs  
perfectly, and sometimes chooses, totally haphazardly, to seemingly  
run itself twice, which of course causes it to die with a fatal error  
after it tries to redefine some functions.

As mysterious as that is, it turns out it must be something  
altogether more sinister. I tried putting die() at the end of the  
script, on the assumption that it was for some reason executing  
twice, yet behold: the problem is still present, and the PHP error  
log still complains about constants and functions being redefined!  
The problem, I therefore thought, cannot be that the script is being  
run twice. (In retrospect, this was the most likely possibility,  
because the page doesn't actually output anything if it dies with  
this error.) So for debugging, I added a bit that logs one message to  
a file immediately before the die() at the end of the file, and a  
different message after the die(). The die() seems to be working  
normally, in that it only logs the first message...

But wait a second! WTF? If the PHP error log is to be believed, then  
the script should be dying with a fatal error before it even *gets*  
to that point in the script, isn't it?

And the greater WTF is the fact that, as I mentioned above, every  
time the page is requested, it unpredictably either does this or  
works flawlessly. Oh my. How do I even *begin* to debug something  
like this?

Thanks for any help.
-- Adam Atlas


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP] php related segmentation fault with Apache 2.0.55

2005-11-30 Thread kristina clair
Hi again,

I tried compiling and installing php 4.4.1 with Apache 2.0.54, out of
curiosity (because php 4.3.10 and Apache 2.0.54 didn't give me any
problems).

With this combination, I still get a segmentation fault with at least
one php script.  The gdb backtrace is:
#0  0xb7e207c1 in php_handler (r=0xda16ca8)
at /home/sys/src/php-4.4.1/sapi/apache2handler/sapi_apache2.c:538
538 if (parent_req  strcmp(parent_req-handler,
PHP_MAGIC_TYPE)  strcmp(parent_req-handler, PHP_SOURCE_MAGIC_TYPE)
 strcmp(parent_req-handler, PHP_SCRIPT)) {
(gdb) bt full
#0  0xb7e207c1 in php_handler (r=0xda16ca8)
at /home/sys/src/php-4.4.1/sapi/apache2handler/sapi_apache2.c:538
orig_bailout = {{__jmpbuf = {0, 0, 0, 0, 0, 0},
__mask_was_saved = 0, __saved_mask = {__val = {
0 repeats 32 times
ctx = (php_struct *) 0xda08818
conf = Variable conf is not available.

I think it is worth reiterating that this is only happening with one
script, to our knowledge.  The actual file being served is a .shtml
file which includes a php script.  I looked at the php script, and it
looks like a pretty straightforward database access script, using
mysql.  Is there anything I should look for in that script?

Thanks,
Kristina


On 11/17/05, kristina clair [EMAIL PROTECTED] wrote:
 I actually did that before emailing about php 4.3.10.  With php 4.4.1,
 the traceback is different:

 Reading symbols from /home/sys/Zend/lib/ZendExtensionManager.so...done.
 Loaded symbols for /home/sys/Zend/lib/ZendExtensionManager.so
 Error while reading shared library symbols:
 .//home/sys/Zend/etc/pfpro.so: No such file or directory.
 Reading symbols from /home/sys/verisign/lib/libpfpro.so...done.
 Loaded symbols for /usr/local/verisign//lib/libpfpro.so
 #0  0xb7ca0c15 in php_handler (r=0xda05f90)
 at /home/sys/src/php-4.4.1/sapi/apache2handler/sapi_apache2.c:538538
  if (parent_req  strcmp(parent_req-handler,
 PHP_MAGIC_TYPE)  strcmp(parent_req-handler, PHP_SOURCE_MAGIC_TYPE)
  strcmp(parent_req-handler, PHP_SCRIPT)) {
 warning: not using untrusted file .gdbinit

 (gdb) bt full
 #0  0xb7ca0c15 in php_handler (r=0xda05f90)
 at /home/sys/src/php-4.4.1/sapi/apache2handler/sapi_apache2.c:538
 orig_bailout = {{__jmpbuf = {0, 0, 0, 0, 0, 0}, __mask_was_saved = 0,
  __saved_mask = {__val = {0 repeats 32 times
 ctx = (php_struct *) 0xd9e9a80
 conf = Variable conf is not available.
 (gdb)

 On 11/17/05, Max Belushkin [EMAIL PROTECTED] wrote:
I have had various problems with upgrading one or the other, until I took 
  it
  as a rule to recompile both upon an upgrade. On the machine I do things
  completely manually on [which has it's drawbacks], I generally also upgrade
  to the current version of PHP together with any Apache update, and
  vice-versa. The current 4.x version is 4.4.1 [although on a FreeBSD install 
  I
  had some issues and downgraded to 4.4.0, but this behaviour hasn't been
  confirmed outside of FreeBSD until now] - perhaps try recompiling PHP to the
  current 4.x version (or if you feel up to it, upgrade to the 5.x versions?),
  and see if it helps? Resolved a lot of my problems in the past...
 
  On Thursday 17 November 2005 22:31, kristina clair wrote:
   2.0.54 to Apache 2.0.55.  The scripts that are failing with the new
   Apache work with no problems with the old Apache.
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


 --
 In most cases, people, even wicked people, are far more naive and
 simple-hearted than one generally assumes.  And so are we.
 /* last line, 1st ch., The Brothers Karamazov */



--
In most cases, people, even wicked people, are far more naive and
simple-hearted than one generally assumes.  And so are we.
/* last line, 1st ch., The Brothers Karamazov */

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



Re: [PHP] Schroedinger's Bug - may require exorcism...

2005-11-30 Thread Robert Cummings
On Wed, 2005-11-30 at 11:48, [EMAIL PROTECTED] wrote:
 What to do next?  I'd check to see if your page is being inadvertantly called 
 twice (I've seen this happen when people used frames.. or like someone else 
 mentioned, doing a double include() or sometimes redirecting back to itself 
 via header())... anything that could possibly re-initiate the page, check 
 into.
 
 Failing that, do it old school...  just inserted die() statements to break 
 execution at various points and see where the probably first starts occuring 
 and focus in that area.  Crude but it works.  At least helps narrow down 
 where the problem could be.
 
 It doesn't do something silly like include() itself inside a conditional 
 somewhere does it?
 
 You might also echo/var_dump/print_r/whatever some of your key variables 
 (especially input variables like $_GET/$_POST/etc and variables used in 
 conditionals) and try to isolate what combination causes your problem.  Since 
 it doesn't do it all the time, I'd guess you could have something like:
 
 $x = 4;
 
 if ($x  1) {
   include('someinclude.inc');
 }
 
 if ($x  5) {
   include('someinclude.inc');
 }

Which reminds me... make sure your using include() where appropriate,
and include_once() where appropriate. Obviously include_once() should
ALWAYS be used when the source contains function or class definitions.

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] include_once behaves differently in mod_php4 vs php5-cgi

2005-11-30 Thread Toomas Aas

Hello!

There's a website with a following structure

index.php in the site's DocumentRoot directory (for this thread, let's 
call it /www)


functions.php, init.php and db_connect.php in /www/library

index.php includes line:

include_once('library/functions.php');

functions.php includes lines:

include_once('db_connect.php');
include_once('init.php');

The website was running fine under PHP 4.4.0 installed as Apache module.

Then we tried it with PHP 5.0.5 installed as CGI. We got the following 
errors:


PHP Warning:  main() : open_basedir restriction in effect. 
File(/db_connect.php) is not within the allowed path(s): 
(/www:/usr/local/www/phpMyAdmin:/var/tmp/php) in 
/www/library/functions.php on line 2
PHP Warning:  main(db_connect.php) : failed to open stream: Operation 
not permitted in /www/library/functions.php on line 2
PHP Warning:  main() : Failed opening 'db_connect.php' for inclusion 
(include_path='.:') in /www/library/functions.php on line 2


...and similar 3 messages about init.php.

Note that first warning is about '/db_connect.php', not 'db_connect.php' 
or './db_connect.php'. /www/library should be inside the open_basedir, 
since it is under /www, which is listed in open_basedir in php.ini. It 
looks like something is changed in PHP's behaviour between versions 4 
and 5 or is differently handled in CGI vs Apache SAPI, but I find it 
unlikely since I can find no documentation regarding this. It's more 
likely that I am overlooking something trivial, but I can't figure out 
what it is.


I tried to change the include lines to

include_once('./db_connect.php');
include_once('./init.php');

but this made no difference.

However, when I specify the full path:

include_once('/www/library/db_connect.php');
include_once('/www/library/init.php');

then the errors disappear and 'everything' seems to work.

Also, I never get any errors about the

include_once('library/funcions.php');

line in index.php

I'm puzzled...


--
... ASCII stupid question, get a stupid ANSI!

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



[PHP] RE: help avoid multiple login

2005-11-30 Thread mail.pmpa
-Mensagem original-
De: Jochem Maas [mailto:[EMAIL PROTECTED] 

the normal way of doing session 'closing' is by way of 'garbage
 
 collection'
 
- every now and then a script/process/function is run that 'closes' any
sessions which are (according to your criteria) inactive. php has stuff
built it that will do this for you to a degree.
-

Is there a way I can access sessions from other users on a script?

what exactly do you mean by that last sentence? I don't quite follow it.
--

I mean if I knew all active session id's I could compare them to the
members_online table.

An example in pseudo code:

// Member logs in, store session id, login datetime, last visit datetime:
INSERT INTO members_online

// Get active session ids from table:
php code

// Compare active session ids with table sessions:
for ($i=0; $i  table rows; $i++){
  if ( !isset( session id from member $i )) {
DELETE member from table
  }
}

If yes I could store the session id on a table and later check if isset.
 You could write the session id into a table when the session is started,
 along with the start time.
 Something like
 sessionid CHAR|starttime DATETIME|lastvisittime DATETIME
 You could then update this table each time the user visits a page, and
 delete it if the interval between starttime and lastvisittime is longer
than
 you want. A cron job/scheduled task could be used to clean this table up
 periodically

a nice description of 'session garbage collection' :-) 
which is pretty much all you can do in terms of 'logoff'.


I already use a class to perform this task. The problem is if a member
closes the browser windows and then tries to login again before the
specified timeout.

Does Apache have a function like asp Session_OnStart, Session_OnEnd ?

I am using IIS and PHP 5.0.4

Thanks in advance.
Pedro.

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



[PHP] page duration tracking

2005-11-30 Thread MikeL
Is there a way to incorporate some type of time in a page to track the
duration of time each individual visitor spent on a specific page with ..PHP?
 
I know I can keep a counter with JavaScript, but I would like it to keep
track in my stats file.
 
I can track  log the arrival time, but would like to either track the page
exit time, too.  It would be great to convert it to minutes:seconds for time
spent viewing the page.
 
I only want to track how much time someone spends on my index.php page
before they leave the page.  I can track when they click to the next page in
my site.
 
 
Thanks for any help and suggestions!
 
 
 
Mike Lewitz
Phoenix, AZ
Supra - the only way to FLY!
==
 
Manage your destiny, or someone else will.
~Jack Welch, Former CEO, General Electric
 
 
 


[PHP] Re: page duration tracking

2005-11-30 Thread Ben

MikeL said the following on 11/30/2005 11:39 AM:

Is there a way to incorporate some type of time in a page to track the
duration of time each individual visitor spent on a specific page with ..PHP?
 
I know I can keep a counter with JavaScript, but I would like it to keep

track in my stats file.
 
I can track  log the arrival time, but would like to either track the page

exit time, too.  It would be great to convert it to minutes:seconds for time
spent viewing the page.
 
I only want to track how much time someone spends on my index.php page

before they leave the page.  I can track when they click to the next page in
my site.


You can only track the amount of time between page/file loads within 
your own site.  Record the time when a page loads and then when the 
person loads another page on your site you can compare the times to 
figure out how long they were on the previous page.


There is no reliable way to record if they leave your stie for another 
site or close their browser.


- Ben

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



Re: [PHP] script won't work on other server

2005-11-30 Thread Peppy
Short tags are on on both servers.

- Original Message - 
From: [EMAIL PROTECTED]
To: Peppy [EMAIL PROTECTED]
Sent: Wednesday, November 30, 2005 2:23 PM
Subject: Re: [PHP] script won't work on other server


 you're using the short-tag form:
 
   ?
 
 rather than:
 
   ?php
 
 this may not be supported on both machines.
 
 haven't looked at other aspects of the script.
 
 
  Original Message 
  Date: Wednesday, November 30, 2005 02:15:47 PM -0600
  From: Peppy [EMAIL PROTECTED]
  To: php-general@lists.php.net
  Subject: [PHP] script won't work on other server
  
  I have a small script that I am testing out on two different
  servers.  It uses the $_SERVER['HTTP_USER_AGENT'] to detect the
  browser and serve up a style sheet dependent on the results.
  (Please don't comment on its usefulness, it's just an example.)
  
  On one server, I can get this script to run correctly in all
  browsers that I test.  On another server, it will not run correctly
  in Netscape (testing for the word Gecko, but have used Netscape
  also).   Any help would be appreciated.
  
  Link to script:
  
  http://www.asrm.org/class/php/angelia.php
  
  In case it's needed, link to file with phpinfo():
  
  http://www.asrm.org/test/test.php
  
  
 
 -- End Original Message --
 
 

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



[PHP] Re: Lowest PHP version to work with MySQL 4.1.x

2005-11-30 Thread Oliver Grätz
AmirBehzad Eslami schrieb:
 I have noted that some versions of PHP are unable to work with MySQL 4.1.x.

Would be new to me but...

 1) Should I upgrade to PHP 5?
Disregarding your question about databases: Yes you should. PHP5 is
there since well over a year. The dev team WILL stop support for PHP4,
be it sooner or later. With the 5.1 release there are no speed arguments
for PHP4 anymore. If you switch now, you are avoiding bigger adjustment
problems in the future.

 2) What is the lowest PHP version which works fine with MySQL 4.1.x?

Tip: Look at the relase notes of the different XAMPP versions. They
always bundle a PHP4 version with a MySQL version and they have changed
to MySQL 4.1 very early. Any download they offer means that the
contained versions work well together.

OLLi

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



[PHP] custom CAD directory/file browser

2005-11-30 Thread Marlin Unruh
I have hundreds of CAD drawing files in binary format. Using the 
strpos() function I can query embedded ASCII info from the CAD files. I 
display the queried info along with an anchor element to the CAD file in 
the web browser using a php script. Thus I can give the drawings 
arbitrary file names but find the file I am looking for from the 
description in the drawings title block.  I can handle that aspect of 
the project all right, the question is how to handle the directories. If 
I create an anchor to the directories it drops out of the script and use 
the browsers file viewing functionality. I think what I need is for the 
php script to call itself and pass the name of the new directory so the 
new directory can be queried and displayed.


Can I use an anchor element to pass info back to the self same php 
script? If so how? I can't seem to find my way though this aspect of the 
project.


Point me to a tutorial, give me a clue, or let me struggle on.

Thanks
--

Regards,
 Marlin Unruh
 Sunco Systems Inc.
 (308) 326-4400

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



Re: [PHP] Lowest PHP version to work with MySQL 4.1.x

2005-11-30 Thread Brent Baisley
PHP4 works just fine with MySQL 4.1. You may be encountering a  
problem with the new password scheme in MySQL 4.1 that PHP 4 does  
not support. In this case, PHP4 is considered and old client. Read  
this part of the manual to get it working:

http://dev.mysql.com/doc/refman/5.0/en/old-client.html

Should you upgrade to PHP5 is a completely different story. There are  
some great things in 5.



On Nov 30, 2005, at 11:13 AM, AmirBehzad Eslami wrote:


Hi List,

I have noted that some versions of PHP are unable to work with  
MySQL 4.1.x.


1) Should I upgrade to PHP 5?
2) What is the lowest PHP version which works fine with MySQL 4.1.x?

Regards,
Behzad

P.S.
I don't use Improved MySQL extension in PHP.
I just need MySQL 4.1.x for multi-byte character support.


--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search  Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577

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



Re: [PHP] page duration tracking

2005-11-30 Thread Michael Crute
On 11/30/05, MikeL [EMAIL PROTECTED] wrote:
 Is there a way to incorporate some type of time in a page to track the
 duration of time each individual visitor spent on a specific page with ..PHP?

 I know I can keep a counter with JavaScript, but I would like it to keep
 track in my stats file.

 I can track  log the arrival time, but would like to either track the page
 exit time, too.  It would be great to convert it to minutes:seconds for time
 spent viewing the page.

 I only want to track how much time someone spends on my index.php page
 before they leave the page.  I can track when they click to the next page in
 my site.


 Thanks for any help and suggestions!

Theoretically you should be able to use a javascript function in the
page unload to submit back to your server when somebody navigates away
from your page. Not sure if it would work 100% of the time but its
worth a try.

-Mike

--

Michael E. Crute
Software Developer
SoftGroup Development Corporation

Linux takes junk and turns it into something useful.
Windows takes something useful and turns it into junk.

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



Re: [PHP] custom CAD directory/file browser

2005-11-30 Thread Leonard Burton
Greetings,

I think what I need is for the
 php script to call itself and pass the name of the new directory so the
 new directory can be queried and displayed.

Let me see if I got this right.

You have Dir x, y, z, w.  In each dir you have files 1 through n.

What you want to do is loop through each dir and then loop through
each drawing and look for some pattern in the title block and then
append the query info there.

If this is the case: you should use chdir() to change dirs.  Then you
can readdir() and loop through the files.

Does this help?

--
Leonard Burton, N9URK
[EMAIL PROTECTED]

You must understand, if you are on a plane you must behave yourself.

The prolonged evacuation would have dramatically affected the
survivability of the occupants.

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



RE: [PHP] custom CAD directory/file browser

2005-11-30 Thread Jay Blanchard
[snip]
Can I use an anchor element to pass info back to the self same php 
script? If so how? I can't seem to find my way though this aspect of the 
project.
[/snip]

You can include information in the query string of the URL

a href=foo.php?directory=/path/to/may/files/Click Here/a

The information would be available in the $_GET array as $_GET['directory']

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



Re: [PHP] page duration tracking

2005-11-30 Thread Jesús Fernández
I think you could use cookies for this.
When the user loads the page you can write a cookie with the timestamp
and the page loaded writen on it. Then when the user request another
page, load if the cookie exists and then you can calculate the time
spent on a certain page...


--
http://esu.proyectoanonimo.com
http://www.proyectoanonimo.com

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



[PHP] shortest possible check: field is set, integer or 0

2005-11-30 Thread Chris Lott
What is the shortest possible check to ensure that a field coming from
a form as a text type input is either a positive integer or 0, but
that also accepts/converts 1.0 or 5.00 as input?

c

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



Re: [PHP] shortest possible check: field is set, integer or 0

2005-11-30 Thread Richard Lynch
On Wed, November 30, 2005 5:10 pm, Chris Lott wrote:
 What is the shortest possible check to ensure that a field coming from
 a form as a text type input is either a positive integer or 0, but
 that also accepts/converts 1.0 or 5.00 as input?

This might be good enough:

if (isset($_POST['x'])){
  if (!preg_match('/([0-9]*)(\\.0*)?/', $_POST['x']){
//invalid
  }
  else{
$_CLEAN['x'] = (int) $_POST['x'];
  }
}

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

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



Re: [PHP] shortest possible check: field is set, integer or 0

2005-11-30 Thread Ray Hauge

Richard Lynch wrote:


On Wed, November 30, 2005 5:10 pm, Chris Lott wrote:
 


What is the shortest possible check to ensure that a field coming from
a form as a text type input is either a positive integer or 0, but
that also accepts/converts 1.0 or 5.00 as input?
   



This might be good enough:

if (isset($_POST['x'])){
 if (!preg_match('/([0-9]*)(\\.0*)?/', $_POST['x']){
   //invalid
 }
 else{
   $_CLEAN['x'] = (int) $_POST['x'];
 }
}

 


You could also replace:

if (!preg_match('/([0-9]*)(\\.0*)?/', $_POST['x'])

with:


if(!is_numeric($_POST['x']) || $_POST['x']  0)

This would ensure that your value only contains numbers, and that it is 
greater than zero.  Then when you put it into the $_CLEAN array, you can 
type-cast it as an int (as in the other script) and that would convert 
any doubles to an integer value.  If you wanted you could also round, 
ceil, or floor the value.


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



Re: [PHP] custom CAD directory/file browser

2005-11-30 Thread Marlin Unruh

Jay Blanchard wrote:

[snip]
Can I use an anchor element to pass info back to the self same php 
script? If so how? I can't seem to find my way though this aspect of the 
project.

[/snip]

You can include information in the query string of the URL

a href=foo.php?directory=/path/to/may/files/Click Here/a

The information would be available in the $_GET array as $_GET['directory']

  
This did the trick but, how do I clear out the $_GET array? As I move 
around the directories the 'directory' string gets longer and longer. 
I'm not sure if it is an Apache variable or what that I need to clear to 
empty the ?directory= string. Below is what builds up in the browser 
address window as I go in and out of directories. How do I dump it?


http://localhost/cad.php?directory=c:/suncosys/cyl/../sbr/../act/2d/obsolete/..


--

Regards,
 Marlin Unruh
 Sunco Systems Inc.
 (308) 326-4400

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



[PHP] hi everyone

2005-11-30 Thread EasyHorpak.com
Why this list very quiet?.
No one in this list.


Please feel free to reply to this email if you have additional questions or 
concerns

ชวน จุดาบุตร 
01-7499093
ติดต่อลงโฆษณา อพาร์ทเมนท์, แมนชั่น, หอพัก โทร. 01-749-9093, 02-938-8301

http://www.EasyHorpak.com - แหล่งค้นหาหอพัก, คอนโด, ที่พัก, อพาร์ทเมนท์ 
http://www.EasyHorpak.com/webdesign - บริการดูแลและออกแบบเว็บไซต์
http://www.EasyHorpak.com/internet - 
แหล่งรวมผู้ให้บริการติดตั้งอินเตอร์เน็ตในอพาร์ทเมนท์ 
http://www.EasyHorpak.com/software - แหล่งรวมโปรแกรมสำหรับอพาร์ทเมนท์ 
http://www.EasyHorpak.com/move - แหล่งรวมผู้ให้บริการขนย้าย
http://www.EasyHorpak.com/coin - แหล่งรวมผู้ให้บริการตู้หยอดเหรียญ


[PHP] Using POST to pass variables

2005-11-30 Thread Todd Cary
When I have more than one button on a page, I us what I call a reentrant 
approach.  That is the page calls itself.


If the page is emailer.pgp, the the FORM tag would be

form method=get action=emailer.php

At the top is

?php
  $send= $_GET[btnSend];  // Send button pressed
  $cancel  = $_GET[btnCancel];// Cancel is pressed
  $message = $_GET[message];
  if ($send) {
header(location: send.php?message= . $message);
  }
  if ($cancel) {
header(location: index.php);
  }
?

Is there a better way to do this so I can use a POST form?

Thank you...

Todd

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



[PHP] Re: Using POST to pass variables

2005-11-30 Thread David Robley
Todd Cary wrote:

 When I have more than one button on a page, I us what I call a reentrant
 approach.  That is the page calls itself.
 
 If the page is emailer.pgp, the the FORM tag would be
 
 form method=get action=emailer.php
 
 At the top is
 
 ?php
$send= $_GET[btnSend];  // Send button pressed
$cancel  = $_GET[btnCancel];// Cancel is pressed
$message = $_GET[message];
if ($send) {
  header(location: send.php?message= . $message);
}
if ($cancel) {
  header(location: index.php);
}
 ?
 
 Is there a better way to do this so I can use a POST form?
 
 Thank you...
 
 Todd
What about:

form method=post action=emailer.php

and

if (isset($_POST['send']) ) {
  # do some sanitising on $_POST['message'] here
  header(location: http://f.q.d.n/path/to/send.php?message=; .
$_POST['message']);
}
exit();

if (isset($_POST['cancel']) ) {
   header(location: http://f.q.d.n/path/to/index.php;);
}

Add other sanity checks as required.


Cheers
-- 
David Robley

Do not put statements in the negative form.

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



[PHP] $_POST won't work for me

2005-11-30 Thread Fil


Ladies and Gentlemen,

Thankyou for this opportunity of picking someones brains before I tear 
the place apart.  I am just starting with PHP but have encountered an 
insurmountable hurdle..  I need to work through   HTML form  posting 
examples to a PHP script.  ONE STEP after Hello World


I have taken the following steps:

1:   My php.ini   (The only one on the system ) is located in /etc/php.ini

Because I am using an above 4.1 version of PHP
I have manually altered the values of

register_globals = On

2: I have repeatedly stopped and restarted Apache webserver.
(Version 2)

3.  I have a Hello World HTML -  hello.php  that loads and runs 
succesfully hence I have a valid   Webserver PHP HTML connection with my 
browser.


4. In Hello World I have taken the liberty of including a  phpinfo()

5. The output of phpinfo()  among others reveals:

post_max_size   8M  8M
precision   14  14
register_argc_argv  On  On
register_globalsOn  On
safe_mode   Off Off

5. I should   be able to use GLOBALS  ( even if this will become a
health hazard later on)


6. I have used the two examples from PHP's Documentation.

Literally cut and paste...

Action.html 


html
head
  meta content=text/html; charset=ISO-8859-1
 http-equiv=content-type
  titlefilsform/title
/head
body
div style=text-align: center;span
 style=text-decoration: underline;Fils Formbr
br
br
/span
div style=text-align: left;
form action=action.php method=post Name: input name=name
 type=textbr

Email: input name=email type=textbr
  input name=submit value=Submit me! type=submit/form
br
span style=text-decoration: underline;/span/div
/div
/body
/html


and  action.php

html
head
  titlePHP Test/title
/head
body
HI ?php echo $_POST['name']; ?.
Your email ?php echo $_POST['email']; ?
/body
/html



7.  After submitting  action.html  action.php loads and prints

Hi
Your email

The contents of $_POST['name']  and $_POST['email']  appear to be 
unavailable to action.php. If I understand the documentation correctly 
this should not be the case  and whatever strings are filled in the form 
of action.html should now be available???


What or where or how or why or whatever ? must I do next... 

Many thanks for those interested in advance

Fil

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



Re: [PHP] Using POST to pass variables

2005-11-30 Thread EasyHorpak.com

use $_POST[btnSend];  to use post method





- Original Message - 
From: Todd Cary [EMAIL PROTECTED]

To: php-general@lists.php.net
Sent: Thursday, December 01, 2005 11:50 AM
Subject: [PHP] Using POST to pass variables


When I have more than one button on a page, I us what I call a reentrant 
approach.  That is the page calls itself.


If the page is emailer.pgp, the the FORM tag would be

form method=get action=emailer.php

At the top is

?php
  $send= $_GET[btnSend];  // Send button pressed
  $cancel  = $_GET[btnCancel];// Cancel is pressed
  $message = $_GET[message];
  if ($send) {
header(location: send.php?message= . $message);
  }
  if ($cancel) {
header(location: index.php);
  }
?

Is there a better way to do this so I can use a POST form?

Thank you...

Todd

--
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: $_POST won't work for me

2005-11-30 Thread David Robley
Fil wrote:

 
 Ladies and Gentlemen,
 
 Thankyou for this opportunity of picking someones brains before I tear
 the place apart.  I am just starting with PHP but have encountered an
 insurmountable hurdle..  I need to work through   HTML form  posting
 examples to a PHP script.  ONE STEP after Hello World
 
 I have taken the following steps:
 
 1:   My php.ini   (The only one on the system ) is located in /etc/php.ini
 
 Because I am using an above 4.1 version of PHP
 I have manually altered the values of
 
 register_globals = On
 
 2: I have repeatedly stopped and restarted Apache webserver.
 (Version 2)
 
 3.  I have a Hello World HTML -  hello.php  that loads and runs
 succesfully hence I have a valid   Webserver PHP HTML connection with my
 browser.
 
 4. In Hello World I have taken the liberty of including a  phpinfo()
 
 5. The output of phpinfo()  among others reveals:
 
 post_max_size 8M  8M
 precision 14  14
 register_argc_argvOn  On
 register_globals  On  On
 safe_mode Off Off
 
 5. I should   be able to use GLOBALS  ( even if this will become a
 health hazard later on)
 
 
 6. I have used the two examples from PHP's Documentation.
 
 Literally cut and paste...
 
 Action.html 
 
 html
 head
   meta content=text/html; charset=ISO-8859-1
  http-equiv=content-type
   titlefilsform/title
 /head
 body
 div style=text-align: center;span
  style=text-decoration: underline;Fils Formbr
 br
 br
 /span
 div style=text-align: left;
 form action=action.php method=post Name: input name=name
  type=textbr
 
 Email: input name=email type=textbr
   input name=submit value=Submit me! type=submit/form
 br
 span style=text-decoration: underline;/span/div
 /div
 /body
 /html
 
 and  action.php
 html
 head
   titlePHP Test/title
 /head
 body
 HI ?php echo $_POST['name']; ?.
 Your email ?php echo $_POST['email']; ?
 /body
 /html
 
 
 7.  After submitting  action.html  action.php loads and prints
 
 Hi
 Your email
 
 The contents of $_POST['name']  and $_POST['email']  appear to be
 unavailable to action.php. If I understand the documentation correctly
 this should not be the case  and whatever strings are filled in the form
 of action.html should now be available???
 
 What or where or how or why or whatever ? must I do next... 
 
 Many thanks for those interested in advance
 
 Fil

In action.php, add this line after BODY

?php var_dump($_POST); ?

and see what you get. I would expect something like:

array
  'name' = 'David'
  'email' = '[EMAIL PROTECTED]'
HI David. Your email [EMAIL PROTECTED]

Cheers
-- 
David Robley

Plankton lobbyist: NUKE THE WHALES!

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



Re: [PHP] $_POST won't work for me

2005-11-30 Thread EasyHorpak.com

Could you let me know your OS and Webserver program.
Did you use appserv for begin learn php?

- Original Message - 
From: Fil [EMAIL PROTECTED]

To: php-general@lists.php.net
Sent: Thursday, December 01, 2005 11:58 AM
Subject: [PHP] $_POST won't work for me




Ladies and Gentlemen,

Thankyou for this opportunity of picking someones brains before I tear the 
place apart.  I am just starting with PHP but have encountered an 
insurmountable hurdle..  I need to work through   HTML form  posting 
examples to a PHP script.  ONE STEP after Hello World


I have taken the following steps:

1:   My php.ini   (The only one on the system ) is located in /etc/php.ini

Because I am using an above 4.1 version of PHP
I have manually altered the values of

register_globals = On

2: I have repeatedly stopped and restarted Apache webserver.
(Version 2)

3.  I have a Hello World HTML -  hello.php  that loads and runs 
succesfully hence I have a valid   Webserver PHP HTML connection with my 
browser.


4. In Hello World I have taken the liberty of including a  phpinfo()

5. The output of phpinfo()  among others reveals:

post_max_size 8M 8M
precision 14 14
register_argc_argv On On
register_globals On On
safe_mode Off Off

5. I should   be able to use GLOBALS  ( even if this will become a
health hazard later on)


6. I have used the two examples from PHP's Documentation.

Literally cut and paste...

Action.html 


html
head
  meta content=text/html; charset=ISO-8859-1
 http-equiv=content-type
  titlefilsform/title
/head
body
div style=text-align: center;span
 style=text-decoration: underline;Fils Formbr
br
br
/span
div style=text-align: left;
form action=action.php method=post Name: input name=name
 type=textbr

Email: input name=email type=textbr
  input name=submit value=Submit me! type=submit/form
br
span style=text-decoration: underline;/span/div
/div
/body
/html


and  action.php

html
head
  titlePHP Test/title
/head
body
HI ?php echo $_POST['name']; ?.
Your email ?php echo $_POST['email']; ?
/body
/html



7.  After submitting  action.html  action.php loads and prints

Hi
Your email

The contents of $_POST['name']  and $_POST['email']  appear to be 
unavailable to action.php. If I understand the documentation correctly 
this should not be the case  and whatever strings are filled in the form 
of action.html should now be available???


What or where or how or why or whatever ? must I do next... 

Many thanks for those interested in advance

Fil

--
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: Using POST to pass variables

2005-11-30 Thread Todd Cary
Except this passes the message in the URL.  Is there a way to pass 
variables as a POST (not in the URL)?


I have a class that creates a new socket, however on my client's shared 
server, the creation of sockets is not allowed.  With a new socket, I am 
able to pass the variable information via the socket (POST).


Todd

David Robley wrote:

Todd Cary wrote:


When I have more than one button on a page, I us what I call a reentrant
approach.  That is the page calls itself.

If the page is emailer.pgp, the the FORM tag would be

form method=get action=emailer.php

At the top is

?php
   $send= $_GET[btnSend];  // Send button pressed
   $cancel  = $_GET[btnCancel];// Cancel is pressed
   $message = $_GET[message];
   if ($send) {
 header(location: send.php?message= . $message);
   }
   if ($cancel) {
 header(location: index.php);
   }
?

Is there a better way to do this so I can use a POST form?

Thank you...

Todd

What about:

form method=post action=emailer.php

and

if (isset($_POST['send']) ) {
  # do some sanitising on $_POST['message'] here
  header(location: http://f.q.d.n/path/to/send.php?message=; .
$_POST['message']);
}
exit();

if (isset($_POST['cancel']) ) {
   header(location: http://f.q.d.n/path/to/index.php;);
}

Add other sanity checks as required.


Cheers


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



[PHP] Database Class Help

2005-11-30 Thread Ian Barnes
Hi,

We have a database class that we want to use to connect to multiple
databases at the same time using different variables.

Here is part of the db class:

class db {
  var $dbh = ;
  var $q   = ;

  function db($db_host, $db_user, $db_pass, $db_name) {
$this-dbh = @mysql_pconnect($db_host, $db_user, $db_pass);
$this-select_db($db_name);
  }

  function select_db($db) {
if ([EMAIL PROTECTED]($db, $this-dbh)) {
  die(emCannot select database because:/em/p\npcode .
mysql_error() . /code);
}
  }

  function num_rows($_q) {
if (!$this-q = mysql_query($_q, $this-dbh)) {
  die(Invalid query \code . $_q . /code\/p\npcode .
mysql_error() . /code);
} else {
  return mysql_num_rows($this-q);
}
@mysql_free_result($this-q);
  }
}

In my php file I say something like

?php

Include ( 'db.php' );
$db_1 = new db('server','username','password','db1');
$db_2 = new db('server','username','password','db2');

Echo $db_1-num_rows('select * from table1');
Echo $db_2-num_rows('select * from table2');

?


Now that happens is when I try and do the query for db1, I get told that
db2.table1 doesn't exist. I can swop anything around and it doesn't seem to
work for one of the classes.

Does anyone have any idea as to why this is happening?

Thanks a lot,
Ian

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



RE: [PHP] Database Class Help

2005-11-30 Thread Albert
Ian Barnes wrote:
 We have a database class that we want to use to connect to multiple
 databases at the same time using different variables.


  function db($db_host, $db_user, $db_pass, $db_name) {
$this-dbh = @mysql_pconnect($db_host, $db_user, $db_pass);
$this-select_db($db_name);
  }

 Now that happens is when I try and do the query for db1, I get told that
 db2.table1 doesn't exist. I can swop anything around and it doesn't seem 
 to work for one of the classes.

 Does anyone have any idea as to why this is happening?

You didn't specify but I guess all your databases are on the same server.

When accessing multiple databases on the same server using multiple
instances of a class, you need to make multiple connections to the server.

By default PHP creates only ONE connection to a server and the database you
select is linked to the connection. So instantiating another instance will
use the previous established connection and change the database.

To force a new connection, you need to use mysql_connect() instead of
mysql_pconnect(). When using mysql_connect() you can specify:

$this-dbh = @mysql_connect($db_host, $db_user, $db_pass, true);

[quote from=PHP manual]
resource mysql_connect ( [string server [, string username [, string
password [, bool new_link [, int client_flags ] )
[/quote]

Which will force a new connection. By default PHP will use a connection
which have already been established.

Take care when doing this as each time you instantiate a class a new
connection to the database will be created adding additional load on your
database which can cause a denial of service.

I normally store a list of connections to servers and databases in a
variable which can be accessed by the script. Every time I instantiate a new
instance of my database class I first make sure that a connection to that
server and database does not already exist. If it does exist then I call
mysql_connect() without the true for new_link otherwise I call
mysql_connect() with the true for new_link.

The downside of this is that you do not have persistent connections which
last beyond the end of the script.

Hope it helps

Albert



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.10/189 - Release Date: 2005/11/30
 

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



[PHP] problem in installing php5

2005-11-30 Thread R.Vijay Daniel
Hi,

I tried to install php5 in redhat7.2,but i was unable to do so.
There was some problem related to libxml2. I even tried down loading the 
libxml2 rpm and upgraded the package.Even then some other problem occured 
related to libxml2.

is that possible to install php5 in redhat7.2 ?.

with regards
 
vijay

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