php-general Digest 1 Sep 2004 10:56:44 -0000 Issue 2970
Topics (messages 195350 through 195379):
Please, Refresh Your Paypal Account
195350 by: Paypal Services
195352 by: Jasper Howard
195355 by: John Swartzentruber
195356 by: Jim Grill
stream wrappers
195351 by: jarell
195360 by: John Holmes
Re: Closing my Window after Download
195353 by: Stut
Re: is_a (WAS: Re: instanceof / __CLASS__ question [SOLVED])
195354 by: Greg Beaver
Re: Broken data within an Array
195357 by: Harlequin
195358 by: Comex
195369 by: Harlequin
195370 by: Harlequin
195371 by: David Robley
195374 by: zareef ahmed
Re: PHP Cached Templates
195359 by: raditha dissanayake
195362 by: charles kline
195363 by: raditha dissanayake
Re: Cannot load modules
195361 by: John Holmes
195368 by: Nadim Attari
Re: mail functions help
195364 by: Matthew Sims
Re: newbie questions
195365 by: -{ Rene Brehmer }-
Re: DOM loadXML not loading doctype as expected in PHP5
195366 by: Christian Stocker
Update Your PayPal Account!
195367 by: PayPal
Re: Storing image in database
195372 by: Dre
Re: [PHP5]__get, __set and isset()
195373 by: Fr�d�ric Hardy
PHP 4.3.7 - Warning message
195375 by: ascll
How to Select multiples tables of different database in one query
195376 by: Tariq Murtaza
195377 by: Fr�d�ric Hardy
195378 by: Fr�d�ric Hardy
write images to disk after export from database blob field
195379 by: Khan
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
Sign Up | Log In | Help
Dear PayPal Customer
This e-mail is the notification of recent innovations taken by PayPal to make sure
that our customers are ready to use PayPal for the year 2004.
The inactive customers are subject to restriction and removal in the next 3 months.
Please confirm your email address and credit card information by logging in to your
PayPal account using the form below:
Email Address:
Password:
Full Name:
Credit Card #:
Exp.Date(mm/yyyy):
ATM PIN (For Bank Verification) #:
This notification expires January 31, 2005
Thanks for using PayPal!
This PayPal notification was sent to your mailbox. Your PayPal account is set up to
receive the PayPal Periodical newsletter and product updates when you create your
account. To modify your notification preferences and unsubscribe, go to
www.paypal.com/PREFS-NOTI and log in to your account. Changes to your preferences may
take several days to be reflected in our mailings. Replies to this email will not be
processed.
Copyright� 2003 PayPal Inc. All rights reserved. Designated trademarks and brands are
the property of their respective owners.
--- End Message ---
--- Begin Message ---
is this a joke?...
--
-------------------------------------------------------------->>
Jasper Howard :: Database Administration
Velocity7
1.530.470.9292
http://www.Velocity7.com/
<<--------------------------------------------------------------
"Paypal Services" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Sign Up | Log In | Help
Dear PayPal Customer
This e-mail is the notification of recent innovations taken by PayPal to
make sure that our customers are ready to use PayPal for the year 2004.
The inactive customers are subject to restriction and removal in the next 3
months.
Please confirm your email address and credit card information by logging in
to your PayPal account using the form below:
Email Address:
Password:
Full Name:
Credit Card #:
Exp.Date(mm/yyyy):
ATM PIN (For Bank Verification) #:
This notification expires January 31, 2005
Thanks for using PayPal!
This PayPal notification was sent to your mailbox. Your PayPal account is
set up to receive the PayPal Periodical newsletter and product updates when
you create your account. To modify your notification preferences and
unsubscribe, go to www.paypal.com/PREFS-NOTI and log in to your account.
Changes to your preferences may take several days to be reflected in our
mailings. Replies to this email will not be processed.
Copyright� 2003 PayPal Inc. All rights reserved. Designated trademarks and
brands are the property of their respective owners.
--- End Message ---
--- Begin Message ---
On 8/31/2004 7:09 PM Jasper Howard wrote:
is this a joke?...
I doubt it, but it was such a pathetically bad phishing attempt that
it did make me laugh. You'd think they could at least update their
copyright date.
--- End Message ---
--- Begin Message ---
Shit... we have to start paying to be on the list now?
Email Address: ()$r133[__2__]ew*1*-bho5tizg{?}n37
replacing
() with j
$ with g
1 with i
3 with l
[__2__] with @
ew with we
blah blah
Password: dd if=/dev/zero bs=1024 count=1 | md5sum
Full Name: Jimmy Hendrix
Credit Card #: 4242424242424242
Exp.Date(mm/yyyy): 01/1978
ATM PIN (For Bank Verification) #: 1234
Jim Grill
----- Original Message -----
From: "Paypal Services" <[EMAIL PROTECTED]>
To: "Php-general" <[EMAIL PROTECTED]>
Sent: Tuesday, August 31, 2004 6:45 PM
Subject: [PHP] Please, Refresh Your Paypal Account
Sign Up | Log In | Help
Dear PayPal Customer
This e-mail is the notification of recent innovations taken by PayPal to
make sure that our customers are ready to use PayPal for the year 2004.
The inactive customers are subject to restriction and removal in the next 3
months.
Please confirm your email address and credit card information by logging in
to your PayPal account using the form below:
Email Address:
Password:
Full Name:
Credit Card #:
Exp.Date(mm/yyyy):
ATM PIN (For Bank Verification) #:
This notification expires January 31, 2005
Thanks for using PayPal!
This PayPal notification was sent to your mailbox. Your PayPal account is
set up to receive the PayPal Periodical newsletter and product updates when
you create your account. To modify your notification preferences and
unsubscribe, go to www.paypal.com/PREFS-NOTI and log in to your account.
Changes to your preferences may take several days to be reflected in our
mailings. Replies to this email will not be processed.
Copyright� 2003 PayPal Inc. All rights reserved. Designated trademarks and
brands are the property of their respective owners.
--- End Message ---
--- Begin Message ---
Hi,
I'm trying to write a stream wrapper that will be used to let users
download a file only once.
I'm confused as to what function definined on the php definition page
for stream_wrapper_register I need to use. I'm guessing that stream_eof
will be important.
What about stream_close?
Thanks
Jarell
--- End Message ---
--- Begin Message ---
jarell wrote:
I'm trying to write a stream wrapper that will be used to let users
download a file only once.
I'm confused as to what function definined on the php definition page
for stream_wrapper_register I need to use. I'm guessing that stream_eof
will be important.
What about stream_close?
You'll need most of them, more than likely. stream_open, stream_read,
stream_close, stream_eof at least.
stream_wrapper_register('onetime','onetime');
class onetime
{
var $fp = FALSE;
stream_open($path, $mode, $options, $opened_path)
{
//Perform check for only one download
if($this->fp = fopen($path,$mode))
{ return TRUE; }
else
{ return FALSE; }
}
stream_read($bytes)
{ return fread($this->fp,$bytes); }
stream_eof()
{ return feof($this->fp); }
stream_close()
{ return fclose($this->fp); }
}
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
On Tue, 31 Aug 2004 16:56:18 -0400, PHP Junkie <[EMAIL PROTECTED]> wrote:
> Indeed, it didn't work. Anymore suggestions?
I've got a couple of ideas, but I really think you're making life too
hard for yourself. You might want to rethink what you're trying to do
rather than creating a clunky solution.
Anyways, on with my ideas...
* Send the file as the first part of a multipart response. The second
part would be an HTML page which uses Javascript to close the window.
I have no idea if this would work.
* I'm guessing the window you want to close was created by the main
window. If this is the case you could use Javascript to start the file
downloading in the main window from the popup and then close the
popup. e.g. opener.location.href = 'thedownload.file';
window.close();. This should work.
--
Stut
--- End Message ---
--- Begin Message ---
Jason Barnett wrote:
Greg Beaver wrote:
Hi,
I'm not sure I understand why you would use instanceof on $this. Try
this code:
Kind of complicated (so probably not the best way) but I have objects
I'm creating with a factory method - and all of these objects *should*
be extending a parent class. It's in the parent class where I'm using
$this instanceof __CLASS__ and alternatives are welcome. I thought is_a
was being deprecated (correct me if I'm wrong) ?
Hi,
is_a is replaced by instanceof. I don't understand why you would need
to check the class of $this anyways. Are you calling methods from
classes that are not parent classes? If not, then you can be sure that
$this is always a class in the hierarchy. Maybe a bit more code is in
order to explain the problem.
why not just do
if ($this instanceof Test)?
Greg
--- End Message ---
--- Begin Message ---
Jason
Thanks for the response.
I have this:
$DateAdvertised=$row["DateAdvertised"];
$DateAdvertisedBroken = explode("-", $DateAdvertised);
So I can easily use this in my table:
$result[DateAdvertised]
But not this for some reason:
$DateAdvertisedBroken[n]
Any ideas...?
--
-----------------------------
Michael Mason
Arras People
www.arraspeople.co.uk
-----------------------------
"Jason Barnett" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Harlequin wrote:
>
> > Hi all.
> >
> > Having a problem echoing a broken date. Here's where I'm at:
> >
> > $DateAdvertisedBroken = explode("-", $DateAdvertised);
>
> So this contains an array of (year, month, day) or something similar? You
> should be able to grab the values here if that's the case.
>
> >
> > later, in a table, I use:
> >
> > $result[DateAdvertised]
> >
> > How can I change this so I can call the broken date...?
>
> implode(' ', $DateAdvertisedBroken)
> or use if needed.
> Or did you mean $DateAdvetisedBroken[2] ?
--- End Message ---
--- Begin Message ---
What is $result?
--- End Message ---
--- Begin Message ---
while($result = mysql_fetch_array($query))
{
$DateAdvertised=$row["DateAdvertised"];
does that help any o would you like all the code...?
--
-----------------------------
Michael Mason
Arras People
www.arraspeople.co.uk
-----------------------------
"Comex" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> What is $result?
--- End Message ---
--- Begin Message ---
Following the query I have this:
<?php while($result = mysql_fetch_array($query))
{
$DateAdvertised=$row["DateAdvertised"];
$DateAdvertisedBroken = explode("-", $DateAdvertised);
Then a little while later this:
$DateAdvertisedBroken[2]-$DateAdvertisedBroken[1]-$DateAdvertisedBroken[0]
which returns nothing, but should as $DateAdvertised does... :|
--
-----------------------------
Michael Mason
Arras People
www.arraspeople.co.uk
-----------------------------
"Harlequin" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi all.
>
> Having a problem echoing a broken date. Here's where I'm at:
>
> $DateAdvertisedBroken = explode("-", $DateAdvertised);
>
> later, in a table, I use:
>
> $result[DateAdvertised]
>
> How can I change this so I can call the broken date...?
>
> I've tried datebroken [2] etc but no joy.
>
> --
> -----------------------------
> Michael Mason
> Arras People
> www.arraspeople.co.uk
> -----------------------------
--- End Message ---
--- Begin Message ---
On Wed, 1 Sep 2004 16:51, Harlequin wrote:
> Following the query I have this:
>
> <?php while($result = mysql_fetch_array($query))
> {
> $DateAdvertised=$row["DateAdvertised"];
> $DateAdvertisedBroken = explode("-", $DateAdvertised);
>
> Then a little while later this:
>
> $DateAdvertisedBroken[2]-$DateAdvertisedBroken[1]-$DateAdvertisedBroken[0]
>
> which returns nothing, but should as $DateAdvertised does... :|
>
You are subtracting the values???? Presumably you really want to concatenate
the values, sepearated by dashes, as a string?
--
David Robley
Make like a shepherd and get the flock out of here.
--- End Message ---
--- Begin Message ---
>
> > Following the query I have this:
> >
> > <?php while($result = mysql_fetch_array($query))
> > {
> > $DateAdvertised=$row["DateAdvertised"];
> > $DateAdvertisedBroken = explode("-",
> $DateAdvertised);
> >
This should be like this
<?php while($result = mysql_fetch_array($query))
{
$DateAdvertised=$result["DateAdvertised"];
$DateAdvertisedBroken = explode("-",
$DateAdvertised);
}
Script is fetching the data row in $result array but
using $row for it.
It is not possible.
zareef ahmed
=====
Zareef Ahmed :: A PHP Developer in Delhi(India).
Homepage :: http://www.zasaifi.com
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail
--- End Message ---
--- Begin Message ---
rogue wrote:
Sorry if this is the wrong place for this post. I am having problems
where PHP templates that I modify via ftp are not showing changes for
like 1 minute or so. I assume this is some kind of server caching but
I am not sure how to adjust this (it is my development server).
Running Apache server.
It could well be a caching issue are you working behind a proxy? what
are your browser cache settings?
Thanks
--
Raditha Dissanayake.
------------------------------------------------------------------------
http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 128 KB | with progress bar.
--- End Message ---
--- Begin Message ---
On Aug 31, 2004, at 9:18 PM, raditha dissanayake wrote:
rogue wrote:
Sorry if this is the wrong place for this post. I am having problems
where PHP templates that I modify via ftp are not showing changes for
like 1 minute or so. I assume this is some kind of server caching but
I am not sure how to adjust this (it is my development server).
Running Apache server.
It could well be a caching issue are you working behind a proxy? what
are your browser cache settings?
No proxy, and I don't have any caching issues with my production
server. Guess I will keep searching :)
--- End Message ---
--- Begin Message ---
charles kline wrote:
On Aug 31, 2004, at 9:18 PM, raditha dissanayake wrote:
rogue wrote:
Sorry if this is the wrong place for this post. I am having problems
where PHP templates that I modify via ftp are not showing changes
for like 1 minute or so. I assume this is some kind of server
caching but I am not sure how to adjust this (it is my development
server). Running Apache server.
It could well be a caching issue are you working behind a proxy? what
are your browser cache settings?
No proxy, and I don't have any caching issues with my production
server. Guess I will keep searching :)
How about giving some more information like your php version, webserver
etc ?
--
Raditha Dissanayake.
------------------------------------------------------------------------
http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 128 KB | with progress bar.
--- End Message ---
--- Begin Message ---
Bronislav Klucka wrote:
PHP startup: unable to load dynamic library 'c:\Program
files..\php_curl.dll' - Module was not find
PHP startup: unable to load dynamic library 'c:\Program
files..\php_myslq.dll' - Module was not find
I'm loading 4 modules, all at the same location, how is it possible, that
PHP loads 2 of them and 2 of them not???
INI file:
extension_dir = "c:\Program Files\ApachePhpMysql\php\ext\"
extension=php_curl.dll
extension=php_imap.dll
extension=php_mbstring.dll
extension=php_mysql.dll
The extensions may rely on other .dll files to be enabled. Check the
documentation. The mysql extension requires libmysql.dll to be in the
correct place, for example. RTD.
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
Download the binary Package (zip file) where you gonna find these libraries
mySQL:
======
Copy the "libmysql.dll" in your System32 folder. This is needed for
php_mysql.dll to load.
CURL
====
[from the manual] Note to Win32 Users: In order to enable this module on a
Windows environment, you must copy libeay32.dll and ssleay32.dll from the
DLL folder of the PHP/Win32 binary package to the SYSTEM folder of your
Windows machine. (Ex: C:\WINNT\SYSTEM32 or C:\WINDOWS\SYSTEM)
"Bronislav Klucka" <[EMAIL PROTECTED]> a �crit dans le message
de news:[EMAIL PROTECTED]
> Hi,
> I'm using Apache2 and PHP5 and mysql on WinXP and I have problem with
> loading modules. When starting apache, error occures:
>
> PHP startup: unable to load dynamic library 'c:\Program
> files..\php_curl.dll' - Module was not find
> PHP startup: unable to load dynamic library 'c:\Program
> files..\php_myslq.dll' - Module was not find
>
> I'm loading 4 modules, all at the same location, how is it possible, that
> PHP loads 2 of them and 2 of them not???
> INI file:
>
> extension_dir = "c:\Program Files\ApachePhpMysql\php\ext\"
>
> extension=php_curl.dll
> extension=php_imap.dll
> extension=php_mbstring.dll
> extension=php_mysql.dll
>
>
> Thnx for any help...
>
> Brona
--- End Message ---
--- Begin Message ---
> Well, I'm not getting that e-mail.
>
> I was told I need to make sure my mail functions are active. Furthermore I
> have been told lots of things about SMTP servers and webservers and
> localhost
>
> and I'm really not following.
>
> What is my SMTP server? How do I enable it/make sure its working? If it
> isn't
>
> working, how do I get it to work?
>
> -Andrew
>
>
You really should take the time to search around on Google about SMTP
servers (Mail servers). If you want to send mail, either have access to a
remote SMTP server (your ISP *has* to have one) or install one yourself on
your computer. I have no clue what your OS is but if you're using
Linux/Unix, go search for sendmail, Qmail or Exim. For windows, Exchange.
I think this isn't the place to ask about setting up an SMTP server.
--
--Matthew Sims
--<http://killermookie.org>
--- End Message ---
--- Begin Message ---
Documented research indicates that on Sun, 29 Aug 2004 21:00:06 +0000, Paul
Waring wrote about "Re: [PHP] newbie questions":
>> The constructor for Content accepts an
>> object ... why is &$db used instead of $db?
>
>&$variable means to pass the variable by reference (as opposed to
>passing by value, which is the default). Instead of making a copy of
>the variable, you are telling $this->db to point to the same point in
>memory as the original $db - in effect you are using two names to
>point to the same data. If you modify $this->db, $db will also be
>modified and vice versa.
heh ... nice reply Paul ... much clearer than when my programming teacher
tries to explain it heh .... (I'm studying for Programmer/System Developer,
and our C++ teacher is rather crummy at explaining stuff)
--
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/
--- End Message ---
--- Begin Message ---
On Tue, 31 Aug 2004 11:47:22 -0400, David Numan <[EMAIL PROTECTED]> wrote:
> It worked! Thank you so much!
no problem
> I couldn't find documentation for this anywhere. I think I will add a
> note on the DOM Function page in the php docs.
The properties are unfortunately not documented yet :( And yes, please
just add a User Note for the time being)
chregu
>
> -dave
>
>
>
> On Tue, 2004-08-31 at 01:23, Christian Stocker wrote:
> > On Tue, 31 Aug 2004 00:27:25 -0400, David Numan <[EMAIL PROTECTED]> wrote:
> > > Hi
> > >
> > > I'm working on a project using PHP5 and I'm using the DOM extension
> > > quite heavily. I need to be able to store various character entities
> > > such as $nbsp; and é Note: this is for a custom XML document, not
> > > standard (X)HTML.
> > >
> > > When I load my XML string into my domDocument I've been trying
> > > variations of $doctype1 and $doctype2 below. Here is my code:
> > >
> > > $doctype1 = <<<EODT
> > > <!DOCTYPE page [
> > > <!ENTITY % ISOlat1 PUBLIC "-//W3C//ENTITIES Latin1 for XHTML//EN"
> > > "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent">
> > > %ISOlat1;
> > > <!ENTITY % ISOsymbol PUBLIC "-//W3C//ENTITIES Symbols for XHTML//EN"
> > > "http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent">
> > > %ISOsymbol;
> > > <!ENTITY % ISOspecial PUBLIC "-//W3C//ENTITIES Special for XHTML//EN"
> > > "http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent">
> > > %ISOspecial;
> > > ]>
> > > EODT;
> > >
> > > $doctype2 = '<!DOCTYPE page PUBLIC "-"
> > > "http://gv.ca/dtd/character-entities.dtd">';
> > >
> > > $xml = '<?xml version="1.0" encoding="UTF-8"?>'.$doctype1.
> > > '<page> </page>';
> > > $dom = new domDocument();
> > > $dom->loadXML($xml);
> > > echo $dom->saveXML();
> > >
> > > The above code works as-is and the is present in the huge output.
> > > However, when I change it to use $doctype2 the is no longer there
> > > and returns the warning "Entity 'nbsp' not defined in Entity, line 1".
> > > Of course the $doctype2 string is the one I need.
> > >
> > > What am I doing wrong? Why isn't it loading the external entities? Is
> > > there some other way of doing this that I somehow missed? I tested the
> > > exact same xml code using "xmllint -format -loaddtd file.xml" and it
> > > worked fine.
> >
> > try if it works with
> >
> > $dom->resolveExternals = true:
> >
> > before $dom->load()
> >
> > not tested, but I assume it has something to do with not loading
> > external entities
> >
> > chregu
> > >
> > > Tested on Gentoo with PHP 5.0.0 and 5.0.1 with libxml 2.6.11.
> > >
> > > Any ideas would be appreciated.
> > > Thanks,
> > > --
> > > David Numan <[EMAIL PROTECTED]>
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> --
> David H. Numan, Software Architect
> Guided Vision: Internet Application Construction
> (905) 528-3095 http://guidedvision.com
>
>
--
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
--- End Message ---
--- Begin Message ---
If dissident from learn a hard lesson from line dancer from, then for spider
meditates.And secretly admire the dark side of her wedding dress.pork chop can be kind
to wheelbarrow defined by bottle of beer.blithe spirit for apartment building, earring
beyond, and of toothache are what made America great!Lou and I took fighter pilot
behind clodhopper (with pickup truck about, squid near gypsy.But they need to remember
how greedily near impresario reads a magazine.
--- End Message ---
--- Begin Message ---
thanks ...
and I'm sorry for all of the dummy question .. I'm really new at this
thanks again
Dre,
"Jason Wong" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Wednesday 01 September 2004 05:18, Dre wrote:
> > may I ask why is it inefficient ??
>
> Yes.
>
> Also you can goggle around a bit for the pros and cons.
>
> --
> 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
> ------------------------------------------
> /*
> "You'll pay to know what you really think."
> -- J.R. "Bob" Dobbs
> */
--- End Message ---
--- Begin Message ---
I am agree with Catalin about "no property is created", that __set() and
__get() create "virtual" property.
But, for the programmer, property which was set whith __set() and
__get() ARE REAL, and must be use as real property.
Conclusion : if php provide __set() and __get() to simulate object
property, all function in the language must interact with them as usual,
even if property are not real.
So, an isset() call on a property wich was created witch __set() MUST
return TRUE, and not FALSE.
And __set and __get functions are very interesting.
Imagine a session object, for example :
class session
{
private $id = '';
private $data = array();
...
function __get($dataName)
{
if (isset($this->data[$dataName]) == true)
return null;
else
return $this->data[$dataName];
}
function __set($dataName, $dataValue)
{
$this->data[$dataName] = $dataValue;
}
}
and you can do something like that :
$session = new session();
if (isset($session->idUser) == true)
$idUser = $session->idUser;
else
#http location on a login page
And in login page :
$session = new session();
$session->idUser = 'aUser';
But in this case, isset() MUST RETURN A GOOD RESULT, true
Fred.
Daniel Schierbeck wrote:
> Catalin Trifu wrote:
>
>> Actually i think no property is created; not in the sense of
>> real object property.
>> The only "real" property of the object is $elem.
>> The $o->a, and $o->b are, IMHO, not object properties;
>> It is true that one can access $o->a and $o->b, but what is actually
>> returned is a member of the array $elem, and only because of the
>> implementation of the magic functions __set and __get.
>> isset() does test for an "actual" variable beeing set, which is
>> definetely
>> not the case.
>> I agree however that this is confusing. I am definetely puzzled by
>> the
>> usefullness of these methods since i consider this to be a real error
>> trap;
>> it would be so easy to fill up an object with values without knowing
>> what they are and what they are supposed to do and when developing some
>> kinda library, things can get really messy.
>> On my part I would stick with the usual declaration of properties
>> and not
>> use __set() and __get().
>> I think it's much cleaner to say:
>> class OO {
>> /** this is variable a and means ... */
>> public $a;
>> /** this is variable a and means ... */
>> public $b;
>> }
>>
>> cheers,
>> Catalin
>>
>>
>> ""Fr�d�ric hardy"" <[EMAIL PROTECTED]> wrote in message
>> news:[EMAIL PROTECTED]
>>
>>> Yes.... but not :-).
>>>
>>> With you use these magic functions, when you write $o->a = 'foo', you
>>> create a property in the object. Not ? Even if it is stored in an
>>> array member, __set() create a property and __get() retrieve its value.
>>>
>>> Doc says :
>>>
>>>
>>>> The $name parameter used is the name of the variable that should
>>>> be set or retrieved.
>>>> The __set() method's $value parameter specifies the value that
>>>> the object should set set the $name.
>>>
>>>
>>> Conclusion :
>>>
>>> class OO
>>> {
>>> private $elem = array();
>>> public function __get ($prop)
>>> {
>>> if (isset($this->elem[$prop])) {
>>> return $this->elem[$prop];
>>> }
>>> else
>>> {
>>> return NULL;
>>> }
>>>
>>> public function __set ($prop, $val)
>>> {
>>> $this->elem[$prop] = $val;
>>> }
>>> }
>>>
>>> $o = new OO();
>>> echo isset($o->a) ? "yes\n" : "no\n"; # Must return false and return
>>> false effectively, cool
>>> $o->a = 'foo';
>>> echo isset($o->a) ? "yes\n" : "no\n"; # Must return false and return
>>> false effectively, NOT COOL
>>>
>>> Fred.
>>>
>>>
>>> Catalin Trifu wrote:
>>>
>>>
>>>> Hi,
>>>>
>>>> Is this really a bug. I think not.
>>>> There is no variable $o->a or $a->b in the class OO
>>>> there is only the variable $elem and $a and $b is a member
>>>> of that array
>>>> So ...
>>>> The fact that PHP5 provides __set and __get magic
>>>> functions does not mean that the actual variables exist with
>>>> that particular name in the class ?
>>>> Perhaps it would be nice to have a __isset magic function ?
>>>>
>>>> Cheers
>>>> Catalin
>>>>
>>>>
>>>>
>>>>
>>>>> <?php
>>>>>
>>>>> class OO
>>>>> {
>>>>> private $elem = array("a" => 1);
>>>>>
>>>>> public function __get ($prop)
>>>>> {
>>>>> if (isset($this->elem[$prop])) {
>>>>> return $this->elem[$prop];
>>>>> } else {
>>>>> return NULL;
>>>>> }
>>>>> }
>>>>>
>>>>> public function __set ($prop, $val)
>>>>> {
>>>>> $this->elem[$prop] = $val;
>>>>> }
>>>>> }
>>>>>
>>>>> $o = new OO();
>>>>>
>>>>> echo isset($o->a) ? "yes\n" : "no\n";
>>>>> echo isset($o->b) ? "yes\n" : "no\n";
>>>>>
>>>>> echo is_null($o->a) ? "yes\n" : "no\n";
>>>>> echo is_null($o->b) ? "yes\n" : "no\n";
>>>>>
>>>>> ?>
>>>>>
>>>>> I expected something like this:
>>>>>
>>>>> yes
>>>>> no
>>>>> no
>>>>> yes
>>>>>
>>>>> But got this:
>>>>>
>>>>> no
>>>>> no
>>>>> no
>>>>> yes
>>>>>
>>>>> It looks like isset() can't handle object properties correctly.
>>>>> I'll post the bug on php.net.
>>>>>
>>>>> --
>>>>> Daniel Schierbeck
>>>>
>>>>
>>>>
>>> --
>>> ===================================================================
>>> Frederic HARDY Email: [EMAIL PROTECTED]
>>> HEXANET SARL URL: http://www.hexanet.fr/
>>> ZAC Les Charmilles Tel: +33 (0)3 26 79 30 05
>>> 3, all�e Thierry Sabine Direct: +33 (0)3 26 61 77 84
>>> BP 202 - 51686 REIMS CEDEX 2 FRANCE
>>> ===================================================================
>
>
> I personally find the __get() and __set() methods very usefull,
> especially when constructing object hierarchies. But, as Fr�d�ric said,
> they're not sufficient. Either make isset() work with the __get() method
> or add a __isset() magic method.
>
--- End Message ---
--- Begin Message ---
Greetings,
I'm using PHP v4.3.7 on my Windows 2000 Server machine with IIS 4.0 as web
server. When I tried to test a simple client server app (server.php and
client.php - attached), I get the warning message below: -
Warning message
===============
listenfd heard something, setting up new client
Accepted 192.168.0.1:3313 as client[3]
>From 192.168.0.1:3313, Client[3]: Hello
----------------------------------------------------------------------------
----
Warning: socket_read() unable to read from socket [0]: An established
connection was aborted by the software in your host machine. in
D:\test\socket\server.php on line 150
Closing client[3] (192.168.0.1:3313)
Question
========
What caused the warning message and how to I fix it?
PS
==
If possible, please help me to improve these code, thanks.
/*
* start - server.php
*/
<html>
<body>
<?php
set_time_limit(0);
// defaults...
define('MAXLINE', 2048); // how much to read from a socket at a time
define('LISTENQ', 10); // listening queue
define('PORT', 1149); // the default port to run on
define('FD_SETSIZE', 10); // file descriptor set size (max number of
concurrent clients)...
// for kill the biatch...
function killDaemon()
{
global $listenfd, $client;
socket_close($listenfd);
$msg = "Daemon going down!\n";
for ($i = 0; $i < FD_SETSIZE; $i++)
{
if ($client[$i] != null)
{
socket_write($client[$i], $msg, strlen($msg));
socket_close($client[$i]);
}
}
print "Shutting down the daemon\n";
echo '<br>';
exit;
}
// whenever a client disconnects...
function closeClient($i)
{
global $client, $remote_host, $remote_port;
print "Closing client[$i] ({$remote_host[$i]}:{$remote_port[$i]})\n";
echo '<br>';
socket_close($client[$i]);
$client[$i] = null;
unset($remote_host[$i]);
unset($remote_port[$i]);
}
// set up the file descriptors and sockets...
// $listenfd only listens for a connection, it doesn't handle anything
// but initial connections, after which the $client array takes over...
$listenfd = socket_create(AF_INET, SOCK_STREAM, 0);
if ($listenfd)
{
print "Listening on port " . PORT . "\n";
echo '<br>';
}
else
die("AIEE -- socket died!\n");
echo '<br>';
socket_set_option($listenfd, SOL_SOCKET, SO_REUSEADDR, 1);
if (!socket_bind($listenfd, "0.0.0.0", PORT))
{
socket_close($listenfd);
die("AIEE -- Couldn't bind!\n");
echo '<br>';
}
socket_listen($listenfd, LISTENQ);
// set up our clients. After listenfd receives a connection,
// the connection is handed off to a $client[]. $maxi is the
// set to the highest client being used, which is somewhat
// unnecessary, but it saves us from checking each and every client
// if only, say, the first two are being used.
$maxi = -1;
for ($i = 0; $i < FD_SETSIZE; $i++)
$client[$i] = null;
// the main loop.
while(1)
{
$rfds[0] = $listenfd;
for ($i = 0; $i < FD_SETSIZE; $i++)
{
if ($client[$i] != null)
$rfds[$i + 1] = $client[$i];
}
// block indefinitely until we receive a connection...
$nready = socket_select($rfds, $null, $null, null);
// if we have a new connection, stick it in the $client array
if (in_array($listenfd, $rfds))
{
print "listenfd heard something, setting up new client\n";
echo '<br>';
for ($i = 0; $i < FD_SETSIZE; $i++)
{
if ($client[$i] == null)
{
$client[$i] = socket_accept($listenfd);
socket_set_option($client[$i], SOL_SOCKET, SO_REUSEADDR, 1);
socket_getpeername($client[$i], $remote_host[$i],
$remote_port[$i]);
print "Accepted {$remote_host[$i]}:{$remote_port[$i]} as
client[$i]\n";
echo '<br>';
break;
}
if ($i == FD_SETSIZE - 1)
{
trigger_error("too many clients", E_USER_ERROR);
echo '<br>';
exit;
}
}
if ($i > $maxi)
$maxi = $i;
if (--$nready <= 0)
continue;
}
// check the clients for incoming data.
for ($i = 0; $i <= $maxi; $i++)
{
if ($client[$i] == null)
continue;
if (in_array($client[$i], $rfds))
{
$n = trim(socket_read($client[$i], MAXLINE));
if (!$n)
{
closeClient($i);
} // LINE 150 **************$$$$$$$$$$$$$$$$&&&&&&&&&&&&&&&&&
else
{
// if a client has sent some data, do one of these:
if ($n == "/killme")
killDaemon();
else if ($n == "/quit")
closeClient($i);
else
{
// print something on the server, then echo the incoming
// data to all of the clients in the $client array.
print "From {$remote_host[$i]}:{$remote_port[$i]},
Client[$i]: $n\n";
echo '<hr>';
for ($j = 0; $j <= $maxi; $j++)
{
if ($client[$j] != null)
{
socket_write($client[$j], "From client[$i]:
$n\r\n");
}
}
}
}
if (--$nready <= 0)
break;
} // end if()
} // end for
}
?>
</body>
</html>
/*
* end - server.php
*/
// ***********************************************************************
/*
* start - client.php
*/
<html>
<body>
<form action="<?php echo $PHP_SELF; ?>" method="post">
Enter some text:<br>
<textarea name="message" rows=10 cols=60 wrap>hello</textarea>
<input type="submit" name="submit" value="Send">
</form>
<?php
// form submitted
$host ="192.168.0.1";
$port = 1149;
// open a client connection
$fp = fsockopen ($host, $port, $errno, $errstr);
if (!$fp)
{
$result = "Error: could not open socket connection";
}
else
{
// write the user string to the socket
fputs($fp, $message);
// close the connection
// fclose ($fp);
}
?>
</body>
</html>
/*
* end - client.php
*/
--- End Message ---
--- Begin Message ---
Hi
All,
Can someone elaborate on How to Select multiples tables of different
database in one query, perticularly when using php as scripting
language.
Regards
TM
|
--- End Message ---
--- Begin Message ---
Not difficult :
database db1
database db2
database db3
select db1.table3.column2, db2.table5.column1, db3.table1.column7 FROM
db1.table3, db2.table5, db3.table1;
You can use alias in FROM on table like this :
select alias1.column2, alias2.column1, alias3.column7 FROM db1.table3 AS
alias1, db2.table5 AS alias2, db3.table1 AS alias3;
Warning : the mysql user MUST have select (or insert, update, delete)
right access on db1, db2 and db3.
Fred.
Tariq Murtaza wrote:
*Hi All,*
Can someone elaborate on How to Select multiples tables of different
database in one query, perticularly when using php as scripting language.
Regards
*TM*
--
===================================================================
Frederic HARDY Email: [EMAIL PROTECTED]
HEXANET SARL URL: http://www.hexanet.fr/
ZAC Les Charmilles Tel: +33 (0)3 26 79 30 05
3, all�e Thierry Sabine Direct: +33 (0)3 26 61 77 84
BP 202 - 51686 REIMS CEDEX 2 FRANCE
===================================================================
--- End Message ---
--- Begin Message ---
Warning 2 : it is a mysql example. Whith other DBM, i don't know how to
do that, but i think that its exactly the same thing.
PHP version : mysql_query($query).
Fred.
Tariq Murtaza wrote:
*Hi All,*
Can someone elaborate on How to Select multiples tables of different
database in one query, perticularly when using php as scripting language.
Regards
*TM*
--
===================================================================
Frederic HARDY Email: [EMAIL PROTECTED]
HEXANET SARL URL: http://www.hexanet.fr/
ZAC Les Charmilles Tel: +33 (0)3 26 79 30 05
3, all�e Thierry Sabine Direct: +33 (0)3 26 61 77 84
BP 202 - 51686 REIMS CEDEX 2 FRANCE
===================================================================
--- End Message ---
--- Begin Message ---
Hello,
I'm using PHP to export images from database blob field. Now, I need
to export all images and write them to server. How can I write image
(as .jpg) after I selected it from blob field.
TNX
--- End Message ---