php-general Digest 24 Jun 2004 05:22:06 -0000 Issue 2839

Topics (messages 188892 through 188928):

Re: bad programming?
        188892 by: bbonkosk.tampabay.rr.com
        188893 by: Kim Steinhaug

Php survey+database
        188894 by: tommie ramirez.andujar
        188896 by: Chris W. Parker
        188924 by: Ligaya Turmelle

Re: printing out messages while processing a file
        188895 by: Gerben

SQL Case sensitivity
        188897 by: Gabe

Re: Form + database / PHP survey + database
        188898 by: James E Hicks III

Filesize
        188899 by: Jay Blanchard
        188900 by: Matt Matijevich
        188901 by: Geethanandh Kandasamy
        188902 by: Jay Blanchard
        188903 by: Marek Kilimajer
        188904 by: Geethanandh Kandasamy
        188908 by: Justin Patrin

Re: Filesize SOLVED
        188905 by: Jay Blanchard

Get users MAC-address of visitor
        188906 by: Yngve
        188907 by: Travis Low
        188909 by: Marek Kilimajer
        188911 by: Matt Matijevich

issue with inheriting private property from abstract class in php5rc3
        188910 by: Chris
        188914 by: Justin Patrin
        188915 by: Marek Kilimajer
        188923 by: Curt Zirzow

MHTML in email
        188912 by: Juan Pablo Herrera
        188913 by: Justin Patrin
        188919 by: Manuel Lemos

PHP+GD on FreeBSD 5.1
        188916 by: Jason Williard
        188928 by: Curt Zirzow

attach ICO [icon] files to a file thru php
        188917 by: grahama.siren.cc

Re: I don't want to use include
        188918 by: Ulrik S. Kofod

Re: issue with inheriting private property from abstract class
        188920 by: Chris
        188921 by: Justin Patrin

Php newbe need help with a script
        188922 by: PHPme.fantasymail.de

Determine whether $_GET has a value
        188925 by: Terence
        188927 by: Chris Shiflett

Sort a text string by last word before separator
        188926 by: Andre Dubuc

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 ---
Try:
if ($_SERVER['REQUEST_METHOD'] == 'POST')

and then read:
http://us4.php.net/reserved.variables

-Brad

----- Original Message -----
From: Amanda Hemmerich <[EMAIL PROTECTED]>
Date: Wednesday, June 23, 2004 12:13 pm
Subject: [PHP] bad programming?

> We just moved a bunch of code from one web hosting company to another.
> Now, one of the pages no longer works.  I have been sort of 
> starting from
> scratch, and the first line is still not working.  Am I using 
> somethingthat I shouldn't be?  Here is a code snippet:
> 
> if ($REQUEST_METHOD=='POST') {
>   for(reset($HTTP_POST_VARS);
>                      $key=key($HTTP_POST_VARS);
>                      next($HTTP_POST_VARS)) {
>         $this = addslashes($HTTP_POST_VARS[$key]);
>         $this = strtr($this, ">", " ");
>         $this = strtr($this, "<", " ");
>         $this = strtr($this, "|", " ");
>         $$key = $this;
>   }
> }
> 
> The part that's not working is the $REQUEST_METHOD=='POST' line.  
> If I
> replace that with if ($login) (and $login is the name of the 
> submit button
> on the form), it works fine.  I am leary of using $login...any other
> suggestions?
> 
> Thanks.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

--- End Message ---
--- Begin Message ---
Could be something about the server environment,
you could try changing to :

$_SERVER["REQUEST_METHOD"]

Run a phpinfo() and see what variables are active on your new
server. I know that IIS webservers lack alot of the variables we
take for granted mostly.

--
--
Kim Steinhaug
----------------------------------------------------------------------
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
----------------------------------------------------------------------
www.steinhaug.com - www.easywebshop.no - www.webkitpro.com
----------------------------------------------------------------------

"Amanda Hemmerich" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> We just moved a bunch of code from one web hosting company to another.
> Now, one of the pages no longer works.  I have been sort of starting from
> scratch, and the first line is still not working.  Am I using something
> that I shouldn't be?  Here is a code snippet:
>
> if ($REQUEST_METHOD=='POST') {
>    for(reset($HTTP_POST_VARS);
>                       $key=key($HTTP_POST_VARS);
>                       next($HTTP_POST_VARS)) {
>          $this = addslashes($HTTP_POST_VARS[$key]);
>          $this = strtr($this, ">", " ");
>          $this = strtr($this, "<", " ");
>          $this = strtr($this, "|", " ");
>          $$key = $this;
>    }
> }
>
> The part that's not working is the $REQUEST_METHOD=='POST' line.  If I
> replace that with if ($login) (and $login is the name of the submit button
> on the form), it works fine.  I am leary of using $login...any other
> suggestions?
>
> Thanks.

--- End Message ---
--- Begin Message ---
Dear colleagues..

I am new to php and I am trying to do the following, to create a php file
that may contain some kind of form or survey and the data entered may be
added to a database...
Here the code of the html form

-----
<html>
<head>
<title>Survey</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
 <p ><strong>Survey</strong></p>
<form action="" method="post" name="importance"  id="importance">
  <table width="605" border="0">
    <tr>
      <td ><strong>Is reading important? </strong></td>
    </tr>
    <tr>
      <td > yes 
        <input name="radiobutton" type="radio" value="radiobutton"></td>
    </tr>
    <tr>
      <td >no
        <input name="radiobutton" type="radio" value="radiobutton"></td>
    </tr>
    <tr>
      <td >maybe
        <input name="radiobutton" type="radio" value="radiobutton"></td>
    </tr>
    <tr>
      <td >i don't know
        <input name="radiobutton" type="radio" value="radiobutton"></td>
    </tr>
    <tr>
      <td >&iquest;Why? </td>
    </tr>
    <tr>
      <td ><textarea name="textarea" cols="85" rows="5" ></textarea></td>
    </tr>
  </table>
</form>
<br>
</body>
</html>
----


______________________________
msc. tomas alberto ramirez.andujar
webmaster - cejisoft - +53 32 26 24 51
universidad pedagogica jose marti. camaguey
circunvalacion norte km 51/2 cp 74670. cuba
email : [EMAIL PROTECTED]
url: http://www.esicm.cu/cejisoft 



............................................................
Este mensaje ha sido analizado por MDaemon Antivirus v2.21.
Instituto Superior Pedagógico de Camaguey, Cuba.

--- End Message ---
--- Begin Message ---
tommie ramirez.andujar <mailto:[EMAIL PROTECTED]>
    on Wednesday, June 23, 2004 12:31 PM said:

> I am new to php and I am trying to do the following, to create a php
> file that may contain some kind of form or survey and the data
> entered may be added to a database...
> Here the code of the html form

what is it that you need help with?



chris.

--- End Message ---
--- Begin Message ---
So what is your question.

Respectfully,
Ligaya Turmelle

"Tommie Ramirez.Andujar" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Dear colleagues..
>
> I am new to php and I am trying to do the following, to create a php file
> that may contain some kind of form or survey and the data entered may be
> added to a database...
> Here the code of the html form
>
> -----
> <html>
> <head>
> <title>Survey</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> </head>
>
> <body>
>  <p ><strong>Survey</strong></p>
> <form action="" method="post" name="importance"  id="importance">
>   <table width="605" border="0">
>     <tr>
>       <td ><strong>Is reading important? </strong></td>
>     </tr>
>     <tr>
>       <td > yes
>         <input name="radiobutton" type="radio" value="radiobutton"></td>
>     </tr>
>     <tr>
>       <td >no
>         <input name="radiobutton" type="radio" value="radiobutton"></td>
>     </tr>
>     <tr>
>       <td >maybe
>         <input name="radiobutton" type="radio" value="radiobutton"></td>
>     </tr>
>     <tr>
>       <td >i don't know
>         <input name="radiobutton" type="radio" value="radiobutton"></td>
>     </tr>
>     <tr>
>       <td >&iquest;Why? </td>
>     </tr>
>     <tr>
>       <td ><textarea name="textarea" cols="85" rows="5" ></textarea></td>
>     </tr>
>   </table>
> </form>
> <br>
> </body>
> </html>
> ----
>
>
> ______________________________
> msc. tomas alberto ramirez.andujar
> webmaster - cejisoft - +53 32 26 24 51
> universidad pedagogica jose marti. camaguey
> circunvalacion norte km 51/2 cp 74670. cuba
> email : [EMAIL PROTECTED]
> url: http://www.esicm.cu/cejisoft
>
>
>
> ............................................................
> Este mensaje ha sido analizado por MDaemon Antivirus v2.21.
> Instituto Superior Pedagógico de Camaguey, Cuba.
>

--- End Message ---
--- Begin Message ---
just use the flush() method. this will send all text that is already pinted
see the documentation for more info

example:
print "hello";
flush();
sleep(1000);
print " world";

gr GB

"Merlin" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi there,
>
> I am writing a backup_restore file which creates directories and picture
files
> with different resolutions out of an original file.
>
> After each process completes I would like to print out a [ok] message, but
> unfortunatelly it prints those msg out only when the script is completely
> through and done.
>
> How can I echo out status messages?
>
> The script is run by console php. ( I also noticed that \n or <br> does
not work
> for the console?!)
>
> Thank you for any help,
>
> Merlin

--- End Message ---
--- Begin Message --- I hope I don't get too chastised for a double post ( posted in .db first ), but I'm hoping someone can help me.

I'm using PHP with ADOdb ( and an MS Access 2000 db ) to write a simple SQL statement but was running into some case sensitivity issues. Here's my SQL currently:

SELECT autoQuesID,fldQuesTitle,fldBody
FROM tblFAQ_Question
WHERE fldBody LIKE '%$strSearchFor%';

All I'm trying to do is have the users search string searched for in the "fldBody" field. However, I'm having problems trying to get it so that the search is case-insensitive. For instance:

If I search on "Airline", I get 1 record.
If I search on "airline", I get 0 records.

I make the value of $strSearchFor lower case ( using strtolower() ), but I don't know how to get it so that the contents of the "fldBody" field is lower case also. I can't seem to find any functions or operators that remove the case-sensitivity. However, I have tried this where clause to no avail:

WHERE LCase(fldBody) LIKE '%$strSearchFor%'

Any help would be much appreciated!
--- End Message ---
--- Begin Message ---
On Wednesday 23 June 2004 03:32 pm, tommie ramirez.andujar wrote:
> Dear colleagues..
>
> I am new to mysql and I am trying to do the following, to create a php file
> that may contain some kind of form or survey and the data entered may be
> added to a database. Here's the code of the html form
>

Dearest Colleague,

        Start writing your project now. No one on this list or the PHP list is going 
to write this code for you. Either list will be glad to help you with 
problems you are having with code that you have written. Neither list is 
going to produce your project for you. I would suggest looking at 
sourceforge.net for pre-written code.


Not Your Code-Monkey,

        Your Colleagues

--- End Message ---
--- Begin Message ---
Boy you'd think that this would be simple, but I get no filesize with
the following

for($i = 4; $i < count($arrDirectory); $i++){
        if(is_dir($arrDirectory[$i])){
                if($theDir = opendir($arrDirectory[$i])){
                        while(($theFile = readdir($theDir)) !== FALSE){
                        $theSize = filesize($theFile);
                        echo $theFile . "\t" . $theSize . "\n";
                        }
                }
                fclose($theDir);        
        } 
}

Heck, I even get some warnings...

PHP Warning:  filesize(): Stat failed for cw.tol.1040606180942.txt.gz
(errno=2 - No such file or directory) in
/usr/local/www/data.default/test/dvdArchivePackager.php on line 50
PHP Warning:  filesize(): Stat failed for cw.tol.1040607181154.txt.gz
(errno=2 - No such file or directory) in
/usr/local/www/data.default/test/dvdArchivePackager.php on line 50
cw.acc.1040605182621.txt.gz
cw.acc.1040606182502.txt.gz
cw.acc.1040607182719.txt.gz
cw.tol.1040519181155.txt.gz

Have I gone loopy? Wait, don't answer that. Do I need to do something
else to get the file size? I have read and searched, but to no avail
yet. TIA!

--- End Message ---
--- Begin Message ---
[snip]
Have I gone loopy? Wait, don't answer that. Do I need to do something
else to get the file size? I have read and searched, but to no avail
yet. TIA!
[/snip]

Have you tried absolute path in  filesize($theFile); or maybe chdir to
$arrDirectory[$i]

--- End Message ---
--- Begin Message ---
the file should be in he same folder as that of the php script,
otherwise you have to mention the absolute/relative path

Geethanandh

On Wed, 23 Jun 2004 15:06:52 -0500, Jay Blanchard
<[EMAIL PROTECTED]> wrote:
> 
> Boy you'd think that this would be simple, but I get no filesize with
> the following
> 
> for($i = 4; $i < count($arrDirectory); $i++){
>        if(is_dir($arrDirectory[$i])){
>                if($theDir = opendir($arrDirectory[$i])){
>                        while(($theFile = readdir($theDir)) !== FALSE){
>                        $theSize = filesize($theFile);
>                        echo $theFile . "\t" . $theSize . "\n";
>                        }
>                }
>                fclose($theDir);
>        }
> }
> 
> Heck, I even get some warnings...
> 
> PHP Warning:  filesize(): Stat failed for cw.tol.1040606180942.txt.gz
> (errno=2 - No such file or directory) in
> /usr/local/www/data.default/test/dvdArchivePackager.php on line 50
> PHP Warning:  filesize(): Stat failed for cw.tol.1040607181154.txt.gz
> (errno=2 - No such file or directory) in
> /usr/local/www/data.default/test/dvdArchivePackager.php on line 50
> cw.acc.1040605182621.txt.gz
> cw.acc.1040606182502.txt.gz
> cw.acc.1040607182719.txt.gz
> cw.tol.1040519181155.txt.gz
> 
> Have I gone loopy? Wait, don't answer that. Do I need to do something
> else to get the file size? I have read and searched, but to no avail
> yet. TIA!
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--- End Message ---
--- Begin Message ---
[snip]
the file should be in he same folder as that of the php script,
otherwise you have to mention the absolute/relative path
[/snip]

I have tried the absolute path, it doesn't waork. Crud.

--- End Message ---
--- Begin Message --- Jay Blanchard wrote --- napísal::
Boy you'd think that this would be simple, but I get no filesize with
the following

for($i = 4; $i < count($arrDirectory); $i++){
        if(is_dir($arrDirectory[$i])){
                if($theDir = opendir($arrDirectory[$i])){
                        while(($theFile = readdir($theDir)) !== FALSE){
                        //  $theSize = filesize($theFile);

$theSize = filesize($arrDirectory[$i] . '/' . $theFile);


echo $theFile . "\t" . $theSize . "\n";
}
}
fclose($theDir);
} }


Heck, I even get some warnings...

PHP Warning:  filesize(): Stat failed for cw.tol.1040606180942.txt.gz
(errno=2 - No such file or directory) in
/usr/local/www/data.default/test/dvdArchivePackager.php on line 50
PHP Warning:  filesize(): Stat failed for cw.tol.1040607181154.txt.gz
(errno=2 - No such file or directory) in
/usr/local/www/data.default/test/dvdArchivePackager.php on line 50
cw.acc.1040605182621.txt.gz
cw.acc.1040606182502.txt.gz
cw.acc.1040607182719.txt.gz
cw.tol.1040519181155.txt.gz

Have I gone loopy? Wait, don't answer that. Do I need to do something
else to get the file size? I have read and searched, but to no avail
yet. TIA!


--- End Message ---
--- Begin Message ---
while(($theFile = readdir($theDir)) !== FALSE){

!= not !==


On Wed, 23 Jun 2004 15:06:52 -0500, Jay Blanchard
<[EMAIL PROTECTED]> wrote:
> 
> Boy you'd think that this would be simple, but I get no filesize with
> the following
> 
> for($i = 4; $i < count($arrDirectory); $i++){
>        if(is_dir($arrDirectory[$i])){
>                if($theDir = opendir($arrDirectory[$i])){
>                        while(($theFile = readdir($theDir)) !== FALSE){
>                        $theSize = filesize($theFile);
>                        echo $theFile . "\t" . $theSize . "\n";
>                        }
>                }
>                fclose($theDir);
>        }
> }
> 
> Heck, I even get some warnings...
> 
> PHP Warning:  filesize(): Stat failed for cw.tol.1040606180942.txt.gz
> (errno=2 - No such file or directory) in
> /usr/local/www/data.default/test/dvdArchivePackager.php on line 50
> PHP Warning:  filesize(): Stat failed for cw.tol.1040607181154.txt.gz
> (errno=2 - No such file or directory) in
> /usr/local/www/data.default/test/dvdArchivePackager.php on line 50
> cw.acc.1040605182621.txt.gz
> cw.acc.1040606182502.txt.gz
> cw.acc.1040607182719.txt.gz
> cw.tol.1040519181155.txt.gz
> 
> Have I gone loopy? Wait, don't answer that. Do I need to do something
> else to get the file size? I have read and searched, but to no avail
> yet. TIA!
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--- End Message ---
--- Begin Message ---
On Wed, 23 Jun 2004 16:30:59 -0400, Geethanandh Kandasamy
<[EMAIL PROTECTED]> wrote:
> 
> while(($theFile = readdir($theDir)) !== FALSE){
> 
> != not !==
> 

!== is correct, check the manual. If you had a directory named 0, !=
false would be false.

--
paperCrane --Justin Patrin--

--- End Message ---
--- Begin Message ---
[snip]
> Boy you'd think that this would be simple, but I get no filesize with
> the following
[/snip]

I HAVE gone loopy.... I was concating the directory HANDLE instead of
the directory PATH...problem solved, idiot slapped in/on forehead....

--- End Message ---
--- Begin Message ---
Hi!

I wonder how i can retrive the MAC-address of the visitor using PHP?

What i am thinking about is using the MAC-address instead of the IP-address
to ban troublesome users from forums etc.

If i just use the IP-address some users will just change it. I know that
it´s possibly to spoof the MAC address but it´s much harder than just
changing the IP-address.

Do you think that there is a big speed penalty by using the MAC-address? I
could just use it when the users first arrives to the site. Then he/she
could be logged in using a session the rest of his visit. I could also store
the MAC-address of the user in encoded form in a cookie so that i won´t have
to retrive the MAC-address "the hard way" on every visit.

Comments and tips would be greatly appreciated!

Yours supersinerely, Yngve

--- End Message ---
--- Begin Message --- I don't think you can get that information. The packet at the MAC level is encpasulating the IP datagram. When the datagram is passed along to another network (e.g. through a router), another MAC packet is constructed, and the payload (datagram) of the original MAC packet is placed into the new MAC packet. At that point, the original MAC address is lost.

cheers,

Travis

Yngve wrote:
Hi!

I wonder how i can retrive the MAC-address of the visitor using PHP?

What i am thinking about is using the MAC-address instead of the IP-address
to ban troublesome users from forums etc.

If i just use the IP-address some users will just change it. I know that
it´s possibly to spoof the MAC address but it´s much harder than just
changing the IP-address.

Do you think that there is a big speed penalty by using the MAC-address? I
could just use it when the users first arrives to the site. Then he/she
could be logged in using a session the rest of his visit. I could also store
the MAC-address of the user in encoded form in a cookie so that i won´t have
to retrive the MAC-address "the hard way" on every visit.

Comments and tips would be greatly appreciated!

Yours supersinerely, Yngve


-- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com>

--- End Message ---
--- Begin Message --- Yngve wrote --- napísal::
Hi!

I wonder how i can retrive the MAC-address of the visitor using PHP?

What i am thinking about is using the MAC-address instead of the IP-address
to ban troublesome users from forums etc.

If i just use the IP-address some users will just change it. I know that
it´s possibly to spoof the MAC address but it´s much harder than just
changing the IP-address.

Do you think that there is a big speed penalty by using the MAC-address? I
could just use it when the users first arrives to the site. Then he/she
could be logged in using a session the rest of his visit. I could also store
the MAC-address of the user in encoded form in a cookie so that i won´t have
to retrive the MAC-address "the hard way" on every visit.

Comments and tips would be greatly appreciated!

Yours supersinerely, Yngve


You can get it only if the visitor is from your LAN. Execute arp program if that's true.

--- End Message ---
--- Begin Message ---
[snip]
What i am thinking about is using the MAC-address instead of the
IP-address
to ban troublesome users from forums etc.
[/snip]

Do you make people login? If you do couldn't you just flag troublesome
users and not allow them to login.

--- End Message ---
--- Begin Message --- if anyone can, would you please explain why the below code does what it does? I would expect $this->test in TestInstance to refer to the inherited $test from Test. Using php5RC3. Thanks.

<?php
abstract class Test {
    private $test;
    abstract public function addToTest($i);
}

class TestInstance extends Test {
    public function __construct() {
        $this->test = 0;
    }

    public function addToTest($i) {
        $this->test += $i;
    }
}

$t = new TestInstance();
$t->addToTest(3);

var_dump($t);

// test var SHOULD be private
echo "private test (shouldn't be able to access it directly, but i can): ".$t->test."\n\n";


/*
output
-------------------------------
object(TestInstance)#1 (2) {
  ["test:private"]=>
  NULL
  ["test"]=>
  int(3)
}
private test (shouldn't be able to access it directly, but i can): 3
*/
?>

--- End Message ---
--- Begin Message ---
Do you have E_STRICT turned on? If not, I believe PHP5 lets you access
private / protected vars wherever you want.

On Wed, 23 Jun 2004 13:40:48 -0400, Chris <[EMAIL PROTECTED]> wrote:
> 
> if anyone can, would you please explain why the below code does what it
> does?  I would expect $this->test in TestInstance to refer to the
> inherited $test from Test.  Using php5RC3.  Thanks.
> 
> <?php
> abstract class Test {
>      private $test;
>      abstract public function addToTest($i);
> }
> 
> class TestInstance extends Test {
>      public function __construct() {
>          $this->test = 0;
>      }
> 
>      public function addToTest($i) {
>          $this->test += $i;
>      }
> }
> 
> $t = new TestInstance();
> $t->addToTest(3);
> 
> var_dump($t);
> 
> // test var SHOULD be private
> echo "private test (shouldn't be able to access it directly, but i can):
> ".$t->test."\n\n";
> 
> /*
> output
> -------------------------------
> object(TestInstance)#1 (2) {
>    ["test:private"]=>
>    NULL
>    ["test"]=>
>    int(3)
> }
> private test (shouldn't be able to access it directly, but i can): 3
> */
> ?>
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
paperCrane --Justin Patrin--

--- End Message ---
--- Begin Message --- Chris wrote --- napísal::
if anyone can, would you please explain why the below code does what it does? I would expect $this->test in TestInstance to refer to the inherited $test from Test. Using php5RC3. Thanks.

<?php
abstract class Test {
    private $test;
    abstract public function addToTest($i);
}

class TestInstance extends Test {
    public function __construct() {
        $this->test = 0;
    }

    public function addToTest($i) {
        $this->test += $i;
    }
}

$t = new TestInstance();
$t->addToTest(3);

var_dump($t);

// test var SHOULD be private
echo "private test (shouldn't be able to access it directly, but i can): ".$t->test."\n\n";


/*
output
-------------------------------
object(TestInstance)#1 (2) {
  ["test:private"]=>
  NULL
  ["test"]=>
  int(3)
}
private test (shouldn't be able to access it directly, but i can): 3
*/
?>


The variable is private for Test, so TestInstance does not have access to it. By assigning 0 to $this->test in the constructor of TestInstance, you create a new property of TestInstance that is public (the default).


var_dump() shows it clearly:
object(TestInstance)#1 (2) {
  ["test:private"]=> NULL   <---- belongs to Test
  ["test"]=> int(3)         <---- belongs to TestInstance
}

--- End Message ---
--- Begin Message ---
* Thus wrote Marek Kilimajer:
> Chris wrote --- napísal::
> >if anyone can, would you please explain why the below code does what it 
> >does?  I would expect $this->test in TestInstance to refer to the 
> >inherited $test from Test.  Using php5RC3.  Thanks.
> >
> ><?php
> >abstract class Test {
> >    private $test;
> >    abstract public function addToTest($i);
> >}
> >
> >class TestInstance extends Test {
> >    public function __construct() {
> >        $this->test = 0;
> >    }
> ...
> 
> The variable is private for Test, so TestInstance does not have access 
> to it. By assigning 0 to $this->test in the constructor of TestInstance, 
> you create a new property of TestInstance that is public (the default).
> 
> var_dump() shows it clearly:
> object(TestInstance)#1 (2) {
>   ["test:private"]=> NULL   <---- belongs to Test
>   ["test"]=> int(3)         <---- belongs to TestInstance
> }

I think one could argue that that test:private shouldn't even be
there. To me that test:private would imply that is TestIntance's
private variable.



Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

--- End Message ---
--- Begin Message ---
Hi!
I need to attach a file extension .mhtml in function mail, but i too need
view the content from the body of e-mail.That is everything!

Regards,
Juan

--- End Message ---
--- Begin Message ---
You could just put the file contents in the body and set its
content-type to text/html.

On Wed, 23 Jun 2004 18:15:03 -0300 (ART), Juan Pablo Herrera
<[EMAIL PROTECTED]> wrote:
> 
> Hi!
> I need to attach a file extension .mhtml in function mail, but i too need
> view the content from the body of e-mail.That is everything!
> 
> Regards,
> Juan
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
--
paperCrane --Justin Patrin--

--- End Message ---
--- Begin Message ---
Hello,

On 06/23/2004 06:15 PM, Juan Pablo Herrera wrote:
I need to attach a file extension .mhtml in function mail, but i too need
view the content from the body of e-mail.That is everything!

MHTML messages are just HTML messages with alternative plain text version in the same body.


You may want to take a look at this class that lets you compose MHTML messages easily:

http://www.phpclasses.org/mimemessage


--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html

--- End Message ---
--- Begin Message ---
I have been having an extremely difficult getting PHP installed with
GD support on a FreeBSD 5.1 system.  While I can get the default GD
package installed, I can't seem to get it installed with JPEG support.
 Does anyone know of any good tutorials or instructions for people
with basic general knowledge of FreeBSD?

--- End Message ---
--- Begin Message ---
* Thus wrote Jason Williard:
> I have been having an extremely difficult getting PHP installed with
> GD support on a FreeBSD 5.1 system.  While I can get the default GD
> package installed, I can't seem to get it installed with JPEG support.
>  Does anyone know of any good tutorials or instructions for people
> with basic general knowledge of FreeBSD?

You're going to need to obtain the jpeg library, a simple
  pkg_add -r jpeg

Will add the library, and when you configure php:

  ./configure --with-gd --with-jpeg-dir=/usr/local [other options]


Might be wise to read this part of the handbood:

http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports.html


Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

--- End Message ---
--- Begin Message --- is it possible to attach a custom icon [like an ICO file on the server] to a file thru php ?

I want to automatically generate a generic text file [ which is XML that launches a Quicktime Movie] that has a custom icon attached to it...
then, I want to automatically send that newly created file in an email...with a user id code for verification


the php used to generate the text file [minus the icon] would be something like:

<?php
$buffer = '<?xml version="1.0"?>' . "\n" .
'<?quicktime type="application/x-quicktime-media-link"?>' . "\n" .
'<embed src="newly_generated_quicktime_movie" autoplay="true"
moviename="<id>'.$_GET['user_id_generated_from_mysql_db'].'</id>" />';

Header('Content-Type: application/x-quicktimeplayer');
Header('Content-Length: '.strlen($buffer));
Header('Content-disposition: inline; filename=theMovie.qtl');

print $buffer;
?>



is this possible?

g
--- End Message ---
--- Begin Message ---
If calling the backup function can wait till after your output is generated, then
you can echo/print the output call  " flush(); " and then call the backup routine.

Then the backup won't apper to be slowing down as it is running after the output is
send to the user.

brgds

QT sagde:
> Dear sirs,
>
> Actually I am using virtual server and I think I have no write to use
> crontab/ But this methods become to me interesting. I will try to learn more
> about how to use crontab and where can I find that in my virtual server?
>
> If I use include in my script, I need to wait result of included script and
> it takes some time because included script should connect one of the my
> other server and write some data there for backup reason. Actually this
> backup reason is not so important to slow my main script. Thats why I don't
> want to result of the backup writing.
>
> "Jason Barnett" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> Qt wrote:
>>
>> > Dear Sirs,
>> >
>> > When I use include, my script is waiting included script results. But I
> just
>> > want to run another local script without wait result.
>> >
>> > Which command I should to use?
>> >
>> >
>> > Best Regards
>>
>> Are you hoping to set up a task as part of a batch for later processing?
>>   There are several ways you could do this.  You can set up crontab /
>> scheduled tasks to run a script every so often.  Then just make sure the
>> script has a datafile / directory that can run all of the tasks at the
>> scheduled time.
>>
>> If this isn't what you're trying to do, leave a message here and give us
>> a better idea of why you want to run the script without waiting and what
>> you intend to do with the result of the "included" script.
>>
>> Jason
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message --- ok, i understand now that private members are NOT inherited. i guess it was just throwing me off that var_dump()/print_r() display the parents private member, even tho its not really a member of the subclass.

thanks

Marek Kilimajer wrote:
Chris wrote --- napísal::

if anyone can, would you please explain why the below code does what it does? I would expect $this->test in TestInstance to refer to the inherited $test from Test. Using php5RC3. Thanks.

<?php
abstract class Test {
    private $test;
    abstract public function addToTest($i);
}

class TestInstance extends Test {
    public function __construct() {
        $this->test = 0;
    }

    public function addToTest($i) {
        $this->test += $i;
    }
}

$t = new TestInstance();
$t->addToTest(3);

var_dump($t);

// test var SHOULD be private
echo "private test (shouldn't be able to access it directly, but i can): ".$t->test."\n\n";


/*
output
-------------------------------
object(TestInstance)#1 (2) {
  ["test:private"]=>
  NULL
  ["test"]=>
  int(3)
}
private test (shouldn't be able to access it directly, but i can): 3
*/
?>


The variable is private for Test, so TestInstance does not have access to it. By assigning 0 to $this->test in the constructor of TestInstance, you create a new property of TestInstance that is public (the default).


var_dump() shows it clearly:
object(TestInstance)#1 (2) {
  ["test:private"]=> NULL   <---- belongs to Test
  ["test"]=> int(3)         <---- belongs to TestInstance
}

--- End Message ---
--- Begin Message ---
It's still a member, it just can't be accessed by the sub-class's
methods. If you call the parent's methods or a method in the parent is
called that isn't defined in the subclass, the private property is
still there are still used as normal.

On Wed, 23 Jun 2004 18:35:14 -0400, Chris <[EMAIL PROTECTED]> wrote:
> 
> ok, i understand now that private members are NOT inherited.  i guess it
> was just throwing me off that var_dump()/print_r() display the parents
> private member, even tho its not really a member of the subclass.
> 
> thanks
> 
> Marek Kilimajer wrote:
> > Chris wrote --- napísal::
> >
> >> if anyone can, would you please explain why the below code does what
> >> it does?  I would expect $this->test in TestInstance to refer to the
> >> inherited $test from Test.  Using php5RC3.  Thanks.
> >>
> >> <?php
> >> abstract class Test {
> >>     private $test;
> >>     abstract public function addToTest($i);
> >> }
> >>
> >> class TestInstance extends Test {
> >>     public function __construct() {
> >>         $this->test = 0;
> >>     }
> >>
> >>     public function addToTest($i) {
> >>         $this->test += $i;
> >>     }
> >> }
> >>
> >> $t = new TestInstance();
> >> $t->addToTest(3);
> >>
> >> var_dump($t);
> >>
> >> // test var SHOULD be private
> >> echo "private test (shouldn't be able to access it directly, but i
> >> can): ".$t->test."\n\n";
> >>
> >> /*
> >> output
> >> -------------------------------
> >> object(TestInstance)#1 (2) {
> >>   ["test:private"]=>
> >>   NULL
> >>   ["test"]=>
> >>   int(3)
> >> }
> >> private test (shouldn't be able to access it directly, but i can): 3
> >> */
> >> ?>
> >>
> >
> > The variable is private for Test, so TestInstance does not have access
> > to it. By assigning 0 to $this->test in the constructor of TestInstance,
> > you create a new property of TestInstance that is public (the default).
> >
> > var_dump() shows it clearly:
> > object(TestInstance)#1 (2) {
> >   ["test:private"]=> NULL   <---- belongs to Test
> >   ["test"]=> int(3)         <---- belongs to TestInstance
> > }
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
paperCrane --Justin Patrin--

--- End Message ---
--- Begin Message ---
Hi There!

I only "used" php and never did any scripts
in the last time by my self. Now i searched
a script but its so frustrated - i didnt had
found anything that i can use for my needs.

I want to get a script that can do the following:

If a user visits my Website - the visitor should
get send to a rendom url from a link list.

Example .../myscript?=page1 should open a url
.../myscript?=page2 an other one and so on.

There are a lot of scripts for it i know but
i want that the users only see a page one time
in 24 hours (ip-block list) and on the next visit
an other url. If he refresh a lot of times and all
links are visited the last link should stay as standard
til his IP go expired (maybe a  use with a cookie can
be used too).

Is there anyone who can help me a bit?

Thanks a lot!

--- End Message ---
--- Begin Message ---
Hi,

Say you have a querystring - index.php?myname=joe

To determine whether myname has a value I have come to the following conclusions / shortcomings when using one of the following:

ISSET = as long as the variable myname exists it's set, but there's no guarantee of a value

!EMPTY = if your name = 0 (zero) then it's considered empty, for all else it seems to work

STRLEN = I have found this to be the only sure way to know.

Is there any other way, or should we always use a combination of ISSET and STRLEN?
--- End Message ---
--- Begin Message ---
--- Terence <[EMAIL PROTECTED]> wrote:
> Say you have a querystring - index.php?myname=joe
> 
> To determine whether myname has a value I have come to the following 
> conclusions / shortcomings when using one of the following:

There is an inherent problem in the varying ways that people interpret
"has a value."

> ISSET = as long as the variable myname exists it's set, but there's no 
> guarantee of a value

If it's set, it has a value. There's no guarantee as to what value, of
course, but that's not what isset() is meant to tell you. It only tells
you whether the variable is set.

To me, the only way for a variable to be defined and not have a value is
for it to be set to null:

$foo = null;

isset(null) returns false, so this follows what I would expect. I can see
a valid argument that isset() should return true for this case (since
you're setting the variable), but I don't agree with any of the arguments
that say isset() returns true when it should be false. Well, I also agree
with the way it handles null, but I understand the confusion with that
one.

> !EMPTY = if your name = 0 (zero) then it's considered empty, for all 
> else it seems to work

Yes, this one is a bit weird. For integers, it makes perfect sense. For
example:

$foo = 0;

Here, it is clear that I intend $foo to be an integer, so 0 is pretty much
what I would consider empty. However, if I have a string:

$foo = '0';

I may no longer consider 0 to be empty. Unfortunately, this is not what
empty() will indicate, so I can understand the complaints. This is just
one of those (rare, in my opinion) cases where a loosely-typed language
can be tricky.

> STRLEN = I have found this to be the only sure way to know.

It is best to decide what you really want to test for. "Whether something
has a value" is terribly ambiguous, and thus, there is no way to test for
this in a way that will satisfy everyone. It's far too open to
interpretation. Just imagine what your has_a_value() function might test
for (if you were to write one), and I think you'll begin to see how others
might disagree with your approach.

If you simply want your string to not be of zero length, strlen() is a
fine test. You might want to throw a trim() in there if you don't consider
whitespace by itself to count.

Lastly, I think you'll find this to be a good reference:

http://www.blueshoes.org/en/developer/php_cheat_sheet/

Hope that helps.

Chris

=====
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly
     Coming Fall 2004
HTTP Developer's Handbook - Sams
     http://httphandbook.org/
PHP Community Site
     http://phpcommunity.org/

--- End Message ---
--- Begin Message ---
Given a text string:

$OK = "Joe Blow, William Howard Anser, Hannie Jansen, etc, etc,";

$_SESSION['txt'] = "$OK";
session_write_close();
$txt = $_SESSION['txt'];

$sorted = explode(", ", $txt); 
sort($sorted); 
print "$sorted";

results in a sort based on the first name:

"Hannie Jansen, Joe Blow, William Howard Anser, etc, etc"


I tried a another function (before_last) 

******

function before ($this, $inthat)
{
        return substr($inthat, 0, strpos($inthat, $this));
}

function strrevpos($instr, $needle)
{
        $rev_pos = strpos (strrev($instr), strrev($needle));
        if ($rev_pos===false) return false;
        else return strlen($instr) - $rev_pos - strlen($needle);
};

function after_last ($this, $inthat)
{
        if (!is_bool(strrevpos($inthat, $this)))
        return substr($inthat, strrevpos($inthat, $this)+strlen($this));
};

function before_last ($this, $inthat)
{
        return substr($inthat, 0, strrevpos($inthat, $this));
};

********

to sort on last name, and it does work, but gives only the last item:

$test2 = between_last(' ', ', ', $OK);
print "$test2";

"Jansen"

How would I get this 'before_last' function to iterate through the initial 
string, so I could build a sorted list with both first and last names, sorted 
by last name? I can't seem to get a proper 'foreach' statement to work, nor a 
'while' statement.

I'm really confused. I've read almost every entry on arrays/strings and 
searched code snippets. Almost all focus on one element arrays such "apple, 
orange, peach" rather than 2 or more elements such as  "fancy cars, big 
trucks, fast dangerous motorcycles,"

Is it even possible to accomplish this type sort on a string?



Any advice, pointers, or help will be greatly appreciated,
Tia,
Andre

--- End Message ---

Reply via email to