php-general Digest 24 Aug 2009 19:27:56 -0000 Issue 6303
Topics (messages 297112 through 297140):
unset( $anobject) does not invoce __destruct()
297112 by: Ralph Deffke
297115 by: kranthi
297116 by: Stuart
297117 by: Lupus Michaelis
297118 by: Ralph Deffke
297120 by: Ashley Sheridan
297121 by: Ralph Deffke
297123 by: Luke
297124 by: Ralph Deffke
297127 by: Stuart
297138 by: hack988 hack988
Re: wierd behavior on parsing css with no php included
297113 by: Ralph Deffke
297114 by: Ashley Sheridan
Re: Is there limitation for switch case: argument's value?
297119 by: tedd
Re: preg_replace anything that isn't WORD
297122 by: tedd
Re: SESSIONS lost sometimes
297125 by: Angelo Zanetti
Multiple EXEC() hang Apache
297126 by: Andrioli Darvin
inserting php value in html shorter wayand downloading winword & mp3 files the
fancy way
297128 by: Grega Leskovšek
297129 by: Ashley Sheridan
297135 by: Paul M Foster
What if this code is right ? It worked perfectly for years!!
297130 by: Chris Carter
297131 by: Ashley Sheridan
297132 by: Lars Torben Wilson
297133 by: Paul M Foster
297134 by: Warren Vail
297136 by: Ashley Sheridan
297137 by: Chris Carter
PHP pages won't open correctly on my server.
297139 by: RRT
297140 by: Ryan Cavicchioni
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
but it should? shouldn't it how can I destroy a class instance invocing
__detruct() of the class ?!?!?
--- End Message ---
--- Begin Message ---
unset($obj) always calls the __destruct() function of the class.
in your case clearly you are missing something else. Probably
unset($anobject) is not being called at all ?
--- End Message ---
--- Begin Message ---
2009/8/24 kranthi <kranthi...@gmail.com>:
> unset($obj) always calls the __destruct() function of the class.
>
> in your case clearly you are missing something else. Probably
> unset($anobject) is not being called at all ?
That's not entirely correct. PHP uses reference counting, so if
unsetting a variable did not cause the object to be destructed then
it's highly likely that there is another variable somewhere that is
holding a reference to that object.
-Stuart
--
http://stut.net/
--- End Message ---
--- Begin Message ---
kranthi wrote:
unset($obj) always calls the __destruct() function of the class.
Never calls the dtor. The dtor will be called only when the reference
count reaches 0.
class c { function __destruct() { echo 'dying !' ; } }
$v1 = new c ;
$v2 = $v1 ;
unset($v1) ; // don't call the dtor
unset($v2) ; // call the dtor
--
Mickaël Wolff aka Lupus Michaelis
http://lupusmic.org
--- End Message ---
--- Begin Message ---
that is correct and that is the problem, and even that is not all !!!
try this
<?php
abstract class a {
public function __construct(){
echo "constructing....<br>";
}
public function __detruct(){
echo "destructing....<br>";
}
}
class b extends a{
}
$c = new b();
unset( $c );
?>
the constructor is inherited, the destructor not !!
PHP 5.2.9-1 and
PHP 5.3.0 behave the same
las trampas de la vida
ralph_def...@yahoo.de
"Stuart" <stut...@gmail.com> wrote in message
news:a5f019de0908240606x5fdca70bkb31dd32b072e5...@mail.gmail.com...
> 2009/8/24 kranthi <kranthi...@gmail.com>:
> > unset($obj) always calls the __destruct() function of the class.
> >
> > in your case clearly you are missing something else. Probably
> > unset($anobject) is not being called at all ?
>
> That's not entirely correct. PHP uses reference counting, so if
> unsetting a variable did not cause the object to be destructed then
> it's highly likely that there is another variable somewhere that is
> holding a reference to that object.
>
> -Stuart
>
> --
> http://stut.net/
--- End Message ---
--- Begin Message ---
On Mon, 2009-08-24 at 15:13 +0200, Ralph Deffke wrote:
> that is correct and that is the problem, and even that is not all !!!
>
> try this
> <?php
>
>
> abstract class a {
> public function __construct(){
> echo "constructing....<br>";
> }
> public function __detruct(){
> echo "destructing....<br>";
> }
> }
>
> class b extends a{
>
> }
> $c = new b();
> unset( $c );
> ?>
>
> the constructor is inherited, the destructor not !!
>
> PHP 5.2.9-1 and
> PHP 5.3.0 behave the same
>
> las trampas de la vida
>
>
>
> ralph_def...@yahoo.de
>
>
>
> "Stuart" <stut...@gmail.com> wrote in message
> news:a5f019de0908240606x5fdca70bkb31dd32b072e5...@mail.gmail.com...
> > 2009/8/24 kranthi <kranthi...@gmail.com>:
> > > unset($obj) always calls the __destruct() function of the class.
> > >
> > > in your case clearly you are missing something else. Probably
> > > unset($anobject) is not being called at all ?
> >
> > That's not entirely correct. PHP uses reference counting, so if
> > unsetting a variable did not cause the object to be destructed then
> > it's highly likely that there is another variable somewhere that is
> > holding a reference to that object.
> >
> > -Stuart
> >
> > --
> > http://stut.net/
>
>
>
That would seem sensible to me though really. A constructor only bears
true for the base class, so any classes which inherit it must
incorporate all the constructor parts. A destructor doesn't know about
further classes which will need to inherit it, so it shouldn't be
inherited and the new class should sort things out. At least, that's how
I see it.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
typing error sorry
forget my last post
is there a was to destroy an object if there is hold a reference somewhere?
"Stuart" <stut...@gmail.com> wrote in message
news:a5f019de0908240606x5fdca70bkb31dd32b072e5...@mail.gmail.com...
> 2009/8/24 kranthi <kranthi...@gmail.com>:
> > unset($obj) always calls the __destruct() function of the class.
> >
> > in your case clearly you are missing something else. Probably
> > unset($anobject) is not being called at all ?
>
> That's not entirely correct. PHP uses reference counting, so if
> unsetting a variable did not cause the object to be destructed then
> it's highly likely that there is another variable somewhere that is
> holding a reference to that object.
>
> -Stuart
>
> --
> http://stut.net/
--- End Message ---
--- Begin Message ---
2009/8/24 Ralph Deffke <ralph_def...@yahoo.de>
> typing error sorry
>
> forget my last post
>
> is there a was to destroy an object if there is hold a reference somewhere?
>
> "Stuart" <stut...@gmail.com> wrote in message
> news:a5f019de0908240606x5fdca70bkb31dd32b072e5...@mail.gmail.com...
> > 2009/8/24 kranthi <kranthi...@gmail.com>:
> > > unset($obj) always calls the __destruct() function of the class.
> > >
> > > in your case clearly you are missing something else. Probably
> > > unset($anobject) is not being called at all ?
> >
> > That's not entirely correct. PHP uses reference counting, so if
> > unsetting a variable did not cause the object to be destructed then
> > it's highly likely that there is another variable somewhere that is
> > holding a reference to that object.
> >
> > -Stuart
> >
> > --
> > http://stut.net/
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Then I assume you would have to copy the object into another variable rather
than reference the one you are trying to destroy?
--
Luke Slater
:O)
this text is protected by international copyright. it is illegal for
anybody apart from the recipient to keep a copy of this text.
dieser text wird von internationalem urheberrecht geschuetzt. allen
ausser dem/der empfaenger/-in ist untersagt, eine kopie dieses textes
zu behalten.
--- End Message ---
--- Begin Message ---
this is also not the full truth try this and it works
what are the circumstances that is causing this problem then, yes I do have
distributed references over my script and there are clearly references still
set, however after running the snipped script I can not see what I do
special in my script causing the problem. I even tried with public and
private static in other objects. it works. however the manual indicates the
refernce counter has to be 0.
<?php
abstract class a {
public function __construct(){
echo "constructing....<br>";
}
public function __destruct(){
echo "destructing....<br>";
}
}
class b extends a{
}
$c = new b();
$d = $c ; // works
$f[] = $c ; // works
class e {
private $m;
public function setM( $m ){
$this->m = $m;
}
}
$o = new e();
$o->setM( $c ); // works
unset( $c );
?>
"Lupus Michaelis" <mickael+...@lupusmic.org> wrote in message
news:41.f9.03363.01192...@pb1.pair.com...
> kranthi wrote:
> > unset($obj) always calls the __destruct() function of the class.
>
> Never calls the dtor. The dtor will be called only when the reference
> count reaches 0.
>
> class c { function __destruct() { echo 'dying !' ; } }
> $v1 = new c ;
> $v2 = $v1 ;
>
> unset($v1) ; // don't call the dtor
> unset($v2) ; // call the dtor
>
> --
> Mickaël Wolff aka Lupus Michaelis
> http://lupusmic.org
--- End Message ---
--- Begin Message ---
2009/8/24 Ralph Deffke <ralph_def...@yahoo.de>:
> this is also not the full truth try this and it works
> what are the circumstances that is causing this problem then, yes I do have
> distributed references over my script and there are clearly references still
> set, however after running the snipped script I can not see what I do
> special in my script causing the problem. I even tried with public and
> private static in other objects. it works. however the manual indicates the
> refernce counter has to be 0.
Assuming you're using PHP 5...
> <?php
>
>
> abstract class a {
> public function __construct(){
> echo "constructing....<br>";
> }
> public function __destruct(){
> echo "destructing....<br>";
> }
> }
>
> class b extends a{
>
> }
>
> $c = new b();
refcount = 1
> $d = $c ; // works
refcount = 2
> $f[] = $c ; // works
refcount = 3
> class e {
> private $m;
>
> public function setM( $m ){
> $this->m = $m;
> }
> }
>
> $o = new e();
> $o->setM( $c ); // works
refcount = 4 (due to assignment in setM)
> unset( $c );
refcount = 3
In PHP 5 all objects are passed by reference unless explicitly cloned.
This means that assigning an object variable to another variable does
nothing more than assign a reference and increment the referece count.
What exactly in the manual leads you to believe that after the unset
the refcount should be 0?
-Stuart
--
http://stut.net/
> "Lupus Michaelis" <mickael+...@lupusmic.org> wrote in message
> news:41.f9.03363.01192...@pb1.pair.com...
>> kranthi wrote:
>> > unset($obj) always calls the __destruct() function of the class.
>>
>> Never calls the dtor. The dtor will be called only when the reference
>> count reaches 0.
>>
>> class c { function __destruct() { echo 'dying !' ; } }
>> $v1 = new c ;
>> $v2 = $v1 ;
>>
>> unset($v1) ; // don't call the dtor
>> unset($v2) ; // call the dtor
>>
>> --
>> Mickaël Wolff aka Lupus Michaelis
>> http://lupusmic.org
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
see http://cn.php.net/manual/en/language.oop5.abstract.php
PHP 5 introduces abstract classes and methods. It is not allowed to
create an instance of a class that has been defined as abstract. Any
class that contains at least one abstract method must also be
abstract. Methods defined as abstract simply declare the method's
signature they cannot define the implementation.
You make misconception understand for abstract class,:(, correct code is:
abstract class a {
abstract public function __construct(){
}
abstract public function __destruct(){
}
}
class b extends a{
public function __construct(){
echo "constructing....<br>";
}
public function __destruct(){
echo "destructing....<br>";
}
}
$c = new b();
unset($c);
if you want to make it work correctly that you want,plase change code to follow
class c {
public function __construct(){
echo "constructing....<br/>";
}
public function __destruct(){
echo "destructing....<br/>";
}
}
class d extends c{
}
$e = new d();
unset($e);
--- End Message ---
--- Begin Message ---
perfect, thats what I was looking for, great thanks
ralph
"Jim Lucas" <li...@cmsws.com> wrote in message
news:4a923946.3020...@cmsws.com...
> Ralph Deffke wrote:
> > Hi folks, i did post this also on the Wamp page but maybe someone out
there
> > had to solve that problem as well.
> >
> > systems involved
> >
> > Firefox 3.0.13
> > Firefox 3.5.2
> > IE 6
> >
> > Wamp:
> > apache 2.2.11
> > PHP 5.2.9 & php 5.3
> >
> > I do parse css files through php
> >
>
> If you state that they have not PHP to parse, then why parse them? It is
a waist!
>
> > Problem: css files are loaded into the browsers but not interpreted or
used
> > on RAW HTML files no php included. The html files are produced with
> > phpDocumentor 1.4.2. IE6 uses parts of the css files loaded to display
the
> > page, Firefox NOT AT ALL.
> >
> > I think it might be possible that wamp throughs some wierd characters
into
> > the css files or is the header type a problem? It looks like parsing the
css
> > through the php engine changes the header of the css to text/html. this
> > would explain why IE6 can use them. on the other hand firebug shows the
> > loaded css, indicates however that no css is available.
> >
> > as an reverse check I did load the html files direktly from the disk
with
> > file:/// ... and the css are interpreted perfectly. so the source of the
> > problem is wamp.
> >
> > it seems that the @importcsss does the biggest problem.it creates a 404
> > error "file not found"
> >
> > it seems creating dynamic css files got some secrets involved with the
wamp.
> > I'm using this concept since ages on linux with no problem.
> >
> > on the @includecss it seems that the search for files are changing to
the
> > php include path or something.
> >
> > any idear what to check?
> >
> > is important for my work to create css dynamicly
> >
>
> My suggestion would be to have php run a script using the
auto_prepend_file ini option
>
> ; Automatically add files before or after any PHP document.
> auto_prepend_file = fix_headers.php
> auto_append_file =
>
> Then, in a script called fix_headers.php, somewhere in your path I hope,
you have this.
>
> <?php
>
> # The following regex is completely untested. It is meant to
> $ext = strtolower(preg_replace('|^.*\.([^.]+)$|',
$_SERVER['SCRIPT_NAME']));
>
> if ( 'css' === $ext ) {
> header('Content-Type: text/css');
> }
>
> ?>
>
> Another way to get around it is to have apache instruct PHP to change, and
output, the correct
> content type.
>
> http://httpd.apache.org/docs/1.3/mod/core.html#files
> http://us2.php.net/manual/en/ini.core.php#ini.sect.data-handling
> http://us2.php.net/manual/en/ini.core.php#ini.default-mimetype
>
> <Files ~ "\.css$">
> php_value default_mimetype "text/css"
> </Files>
>
> Hope this helps
>
> Jim Lucas
>
> > ralph_def...@yahoo.de
> >
> >
> >
>
>
> --
> Jim Lucas
>
> "Some men are born to greatness, some achieve greatness,
> and some have greatness thrust upon them."
>
> Twelfth Night, Act II, Scene V
> by William Shakespeare
--- End Message ---
--- Begin Message ---
On Mon, 2009-08-24 at 10:58 +0200, Ralph Deffke wrote:
> perfect, thats what I was looking for, great thanks
>
> ralph
>
> "Jim Lucas" <li...@cmsws.com> wrote in message
> news:4a923946.3020...@cmsws.com...
> > Ralph Deffke wrote:
> > > Hi folks, i did post this also on the Wamp page but maybe someone out
> there
> > > had to solve that problem as well.
> > >
> > > systems involved
> > >
> > > Firefox 3.0.13
> > > Firefox 3.5.2
> > > IE 6
> > >
> > > Wamp:
> > > apache 2.2.11
> > > PHP 5.2.9 & php 5.3
> > >
> > > I do parse css files through php
> > >
> >
> > If you state that they have not PHP to parse, then why parse them? It is
> a waist!
> >
> > > Problem: css files are loaded into the browsers but not interpreted or
> used
> > > on RAW HTML files no php included. The html files are produced with
> > > phpDocumentor 1.4.2. IE6 uses parts of the css files loaded to display
> the
> > > page, Firefox NOT AT ALL.
> > >
> > > I think it might be possible that wamp throughs some wierd characters
> into
> > > the css files or is the header type a problem? It looks like parsing the
> css
> > > through the php engine changes the header of the css to text/html. this
> > > would explain why IE6 can use them. on the other hand firebug shows the
> > > loaded css, indicates however that no css is available.
> > >
> > > as an reverse check I did load the html files direktly from the disk
> with
> > > file:/// ... and the css are interpreted perfectly. so the source of the
> > > problem is wamp.
> > >
> > > it seems that the @importcsss does the biggest problem.it creates a 404
> > > error "file not found"
> > >
> > > it seems creating dynamic css files got some secrets involved with the
> wamp.
> > > I'm using this concept since ages on linux with no problem.
> > >
> > > on the @includecss it seems that the search for files are changing to
> the
> > > php include path or something.
> > >
> > > any idear what to check?
> > >
> > > is important for my work to create css dynamicly
> > >
> >
> > My suggestion would be to have php run a script using the
> auto_prepend_file ini option
> >
> > ; Automatically add files before or after any PHP document.
> > auto_prepend_file = fix_headers.php
> > auto_append_file =
> >
> > Then, in a script called fix_headers.php, somewhere in your path I hope,
> you have this.
> >
> > <?php
> >
> > # The following regex is completely untested. It is meant to
> > $ext = strtolower(preg_replace('|^.*\.([^.]+)$|',
> $_SERVER['SCRIPT_NAME']));
> >
> > if ( 'css' === $ext ) {
> > header('Content-Type: text/css');
> > }
> >
> > ?>
> >
> > Another way to get around it is to have apache instruct PHP to change, and
> output, the correct
> > content type.
> >
> > http://httpd.apache.org/docs/1.3/mod/core.html#files
> > http://us2.php.net/manual/en/ini.core.php#ini.sect.data-handling
> > http://us2.php.net/manual/en/ini.core.php#ini.default-mimetype
> >
> > <Files ~ "\.css$">
> > php_value default_mimetype "text/css"
> > </Files>
> >
> > Hope this helps
> >
> > Jim Lucas
> >
> > > ralph_def...@yahoo.de
> > >
> > >
> > >
> >
> >
> > --
> > Jim Lucas
> >
> > "Some men are born to greatness, some achieve greatness,
> > and some have greatness thrust upon them."
> >
> > Twelfth Night, Act II, Scene V
> > by William Shakespeare
>
>
>
Just out of curiosity, which solution was it that worked?
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
At 9:44 PM -0700 8/22/09, Lars Torben Wilson wrote:
Hi Keith,
Glad it works! I'm not sure how inverting the case statement helps you
minimize the code in each case. As both I and Adam showed, you can do
the same thing more efficiently (and IMHO much more readably) like
this:
switch ($sum)
{
case 8:
break;
case 7:
case 6:
break;
case 2:
case 1:
break;
case 0:
break;
default:
break;
}
Additionally, I would argue there's nothing different below other
than it's even more easier to read and understand:
switch ($sum)
{
case 0:
break;
case 1:
case 2:
break;
case 6:
case 7:
break;
case 8:
break;
default:
break;
}
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
On Sat, Aug 22, 2009 at 12:32 PM, ÈýÏÝÂÔ<danondan...@gmail.com> wrote:
Lets assume I have the string "cats i saw a cat and a dog"
i want to strip everything except "cat" and "dog" so the result will be
"catcatdog",
using preg_replace.
I've tried something like /[^(dog|cat)]+/ but no success
> What should I do?
Lot's of ways to skin this cat/dog.
What's wrong with exploding the string using
spaces and then walking the array looking for cat
and dog while assembling the resultant string?
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
-----Original Message-----
From: Nitebirdz [mailto:nitebi...@sacredchaos.com]
Sent: 20 August 2009 02:58 PM
To: php-gene...@lists.php.net
Subject: Re: [PHP] SESSIONS lost sometimes
On Thu, Aug 20, 2009 at 02:34:54PM +0200, Angelo Zanetti wrote:
> Hi Leon,
>
> No harm intended :) Just thought that people were missing my post now and
> only answering yours.
>
Angelo, excuse me if I'm bringing up something very basic, but I'm new
to this. Just trying to help.
I imagine redirects couldn't be the cause of the problem, right?
http://www.oscarm.org/news/detail/1877-avoiding_frustration_with_php_session
s
http://www.webmasterworld.com/forum88/8486.htm
Hi thanks for the links it appears that its all in order also I'm not losing
SESSIONS on the redirect but somewhere else.
I have checked the garbage collection, disk space and other settings in the
PHP.ini file. ALL FINE.
So now I am really stuck and confused as to what could sometimes cause the
loss of these variables and other times it just works fine.
Is there possibly a way that I can call some function that will ensure that
the sessions are saved (I checked the manual - nothing much).
Any other ideas? Anything that you think might be causing issues?
Thanks
Angelo
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hi all
I'm upgrading PHP version from PHP 4 to 5.3.0 and Apache to 2.2.13, but I'm
facing a weird problem on the following statement:
$StringaParametri=exec('java -cp ..\\java rsa6230 ' . $Token);
It works on PHP 4 and PHP 5 CGI, but it hang Apache using MOD_PHP5. The
problem occurs when 2 or more requests are served at the same time.
PHP 4 doesn't have the problem but it works as CGI. On PHP 5 we rule out CGI
because it is too slow.
The problem seems to be related to exec/system/ functions family. Other
scripts using system(), running .NET program, hang in the same way.
Configuration:
Windows Server 2003
Apache 2.2.13
PHP 5.3.0 ( PHP 5.2.10 has the same problem too)
Any idea?
Thank you
Darvin
--- End Message ---
--- Begin Message ---
Hi, I am still a newbie in php. Is there a shorter way to include a php
value in a form?
<input type="text" name="fullname" size="40" value="<?php echo
{$user['fullname']}; ?>" />
is it possible to do smth like this <?=php {$user['fullname']}; ?> like in
JSP?
Can I omit the last whitespace before the closing ?> ?
***
I tried to download the file from another server the fancy way in PHP, but
it just display blank screen. Can You please look at my code:
<?php
$filepath = "http://aaaaaa.yolasite.com/resources/happytears.doc";
// $filepath =
"http://users.skavt.net/~gleskovs/else/happytears.doc<http://users.skavt.net/%7Egleskovs/else/happytears.doc>
";
if (file_exists($filepath)) {
header("Content-Type: application/force-download");
header("Content-Disposition:filename=\"happytears.doc\"");
$fd = fopen($filepath,'rb');//I tried also just 'r' and am not clear on
which documents should I add b for binary? As I understand only text plain
files and html files and php etc files are without 'b'. All documents,
presentations, mp3 files, video files should have also 'b' for binary along
r. Am I wrong?
fpassthru($fd);
fclose($fd);
}
?>
Both filepaths are valid and accessible to the same document. I double
checked them. Please help me. Thanks in advance, Yours, Grega
-- Peace refuge:
http://users.skavt.net/~gleskovs/<http://users.skavt.net/%7Egleskovs/>
When the sun rises I receive and when it sets I forgive;) Grega Leskovšek
--- End Message ---
--- Begin Message ---
On Mon, 2009-08-24 at 17:56 +0200, Grega Leskovšek wrote:
> Hi, I am still a newbie in php. Is there a shorter way to include a php
> value in a form?
> <input type="text" name="fullname" size="40" value="<?php echo
> {$user['fullname']}; ?>" />
> is it possible to do smth like this <?=php {$user['fullname']}; ?> like in
> JSP?
> Can I omit the last whitespace before the closing ?> ?
>
> ***
> I tried to download the file from another server the fancy way in PHP, but
> it just display blank screen. Can You please look at my code:
>
> <?php
> $filepath = "http://aaaaaa.yolasite.com/resources/happytears.doc";
> // $filepath =
> "http://users.skavt.net/~gleskovs/else/happytears.doc<http://users.skavt.net/%7Egleskovs/else/happytears.doc>
> ";
> if (file_exists($filepath)) {
> header("Content-Type: application/force-download");
> header("Content-Disposition:filename=\"happytears.doc\"");
> $fd = fopen($filepath,'rb');//I tried also just 'r' and am not clear on
> which documents should I add b for binary? As I understand only text plain
> files and html files and php etc files are without 'b'. All documents,
> presentations, mp3 files, video files should have also 'b' for binary along
> r. Am I wrong?
> fpassthru($fd);
> fclose($fd);
> }
> ?>
> Both filepaths are valid and accessible to the same document. I double
> checked them. Please help me. Thanks in advance, Yours, Grega
>
> -- Peace refuge:
> http://users.skavt.net/~gleskovs/<http://users.skavt.net/%7Egleskovs/>
> When the sun rises I receive and when it sets I forgive;) Grega Leskovšek
There is a shorttag syntax for a basic PHP echo, and you nearly had it
in your code example:
<?=$user['fullname']?>
But this will only work on a setup that has shorttags enabled, and a lot
of shared hosts don't by default. Have you looked at heredoc?
print <<<EOC
<form>
<input type="text" name="fullname" size="40"
value="{$user['fullname']}"/>
</form>
EOC;
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
On Mon, Aug 24, 2009 at 05:56:46PM +0200, Grega Leskov??ek wrote:
> Hi, I am still a newbie in php. Is there a shorter way to include a php
> value in a form?
> <input type="text" name="fullname" size="40" value="<?php echo
> {$user['fullname']}; ?>" />
> is it possible to do smth like this <?=php {$user['fullname']}; ?> like in
> JSP?
> Can I omit the last whitespace before the closing ?> ?
Yes, you can include a PHP value in a script. Like this:
...size="40" value="<?php echo $user['fullname']; ?>" />
Your curly braces are redundant, and you must quote the "fullname" index
if you're not quoting the whole $user['fullname'] expression. Yes, you
can remove the final space after $user['fullname']; and before the tag
closure (?>). But there's no reason to.
Paul
--
Paul M. Foster
--- End Message ---
--- Begin Message ---
Hi,
The code below actually takes input from a web form and sends the fields
captured in an email. It used to work quite well since past few years. It
has stopped now. I used Google's mail servers (google.com/a/website.com)
<?
$fName = $_REQUEST['fName'] ;
$emailid = $_REQUEST['emailid'] ;
$number = $_REQUEST['number'] ;
$message = $_REQUEST['message'] ;
mail( "ch...@gmail.com", $number, $message, "From: $emailid" );
header( "Location: http://www.thankyou.com/thankYouContact.php" );
?>
This is the simplest one, how could it simply stop? Any help would be
appreciated, I have already lost 148 queries that came through this form.
Thanks in advance,
Chris
--
View this message in context:
http://www.nabble.com/What-if-this-code-is-right---It-worked-perfectly-for-years%21%21-tp25118874p25118874.html
Sent from the PHP - General mailing list archive at Nabble.com.
--- End Message ---
--- Begin Message ---
On Mon, 2009-08-24 at 09:12 -0700, Chris Carter wrote:
> Hi,
>
> The code below actually takes input from a web form and sends the fields
> captured in an email. It used to work quite well since past few years. It
> has stopped now. I used Google's mail servers (google.com/a/website.com)
>
> <?
> $fName = $_REQUEST['fName'] ;
> $emailid = $_REQUEST['emailid'] ;
> $number = $_REQUEST['number'] ;
> $message = $_REQUEST['message'] ;
>
> mail( "ch...@gmail.com", $number, $message, "From: $emailid" );
> header( "Location: http://www.thankyou.com/thankYouContact.php" );
> ?>
>
> This is the simplest one, how could it simply stop? Any help would be
> appreciated, I have already lost 148 queries that came through this form.
>
> Thanks in advance,
>
> Chris
>
> --
> View this message in context:
> http://www.nabble.com/What-if-this-code-is-right---It-worked-perfectly-for-years%21%21-tp25118874p25118874.html
> Sent from the PHP - General mailing list archive at Nabble.com.
>
>
Have you tried it without the header redirect in there? There might be
some sort of error message that you are never seeing because of that.
Also, do you know for definite that the mail() function has stopped
working? It could be that you are just not receiving the emails anymore
due to some over zealous spam filter. Try sending the email to a variety
of email accounts and see what happens.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
2009/8/24 Chris Carter <chandan9sha...@yahoo.com>:
>
> Hi,
>
> The code below actually takes input from a web form and sends the fields
> captured in an email. It used to work quite well since past few years. It
> has stopped now. I used Google's mail servers (google.com/a/website.com)
>
> <?
> $fName = $_REQUEST['fName'] ;
> $emailid = $_REQUEST['emailid'] ;
> $number = $_REQUEST['number'] ;
> $message = $_REQUEST['message'] ;
>
> mail( "ch...@gmail.com", $number, $message, "From: $emailid" );
> header( "Location: http://www.thankyou.com/thankYouContact.php" );
> ?>
>
> This is the simplest one, how could it simply stop? Any help would be
> appreciated, I have already lost 148 queries that came through this form.
>
> Thanks in advance,
>
> Chris
Hi Chris,
More information would be very helpful. In exactly what way is it
failing? Blank page? Apparently normal operation, except the email
isn't being sent? Error messages? Log messages? etc. . .
One possibility is that the server config has changed to no longer
allow short open tags. This is easy to check for by simply replacing
'<?' with <?php' on the first line.
There are of course other possibilities but without knowing how it's
failing, any guesses would just be shots in the dark.
Regards,
Torben
--- End Message ---
--- Begin Message ---
On Mon, Aug 24, 2009 at 09:12:19AM -0700, Chris Carter wrote:
>
> Hi,
>
> The code below actually takes input from a web form and sends the fields
> captured in an email. It used to work quite well since past few years. It
> has stopped now. I used Google's mail servers (google.com/a/website.com)
>
> <?
> $fName = $_REQUEST['fName'] ;
> $emailid = $_REQUEST['emailid'] ;
> $number = $_REQUEST['number'] ;
> $message = $_REQUEST['message'] ;
>
> mail( "ch...@gmail.com", $number, $message, "From: $emailid" );
> header( "Location: http://www.thankyou.com/thankYouContact.php" );
> ?>
>
> This is the simplest one, how could it simply stop? Any help would be
> appreciated, I have already lost 148 queries that came through this form.
As a test, change $_REQUEST above to $_POST (assuming POST method on the
form), and try it.
Also check the return value of the mail() function to see if it thinks
it has succeeded or failed. If it fails, check the mail logs on the
server to find what the mail server thinks is wrong.
Paul
--
Paul M. Foster
--- End Message ---
--- Begin Message ---
You are absolutely right, more information is needed. Many ISP's are
changing port number assignments on their SMTP outgoing email to prevent
abuse. A simple change like that could cause the email to not go out, and
it has nothing to do with PHP.
Warren Vail
Vail Systems Technology
-----Original Message-----
From: Lars Torben Wilson [mailto:larstor...@gmail.com]
Sent: Monday, August 24, 2009 9:21 AM
To: Chris Carter
Cc: php-gene...@lists.php.net
Subject: Re: [PHP] What if this code is right ? It worked perfectly for
years!!
2009/8/24 Chris Carter <chandan9sha...@yahoo.com>:
>
> Hi,
>
> The code below actually takes input from a web form and sends the fields
> captured in an email. It used to work quite well since past few years. It
> has stopped now. I used Google's mail servers (google.com/a/website.com)
>
> <?
> $fName = $_REQUEST['fName'] ;
> $emailid = $_REQUEST['emailid'] ;
> $number = $_REQUEST['number'] ;
> $message = $_REQUEST['message'] ;
>
> mail( "ch...@gmail.com", $number, $message, "From: $emailid" );
> header( "Location: http://www.thankyou.com/thankYouContact.php" );
> ?>
>
> This is the simplest one, how could it simply stop? Any help would be
> appreciated, I have already lost 148 queries that came through this form.
>
> Thanks in advance,
>
> Chris
Hi Chris,
More information would be very helpful. In exactly what way is it
failing? Blank page? Apparently normal operation, except the email
isn't being sent? Error messages? Log messages? etc. . .
One possibility is that the server config has changed to no longer
allow short open tags. This is easy to check for by simply replacing
'<?' with <?php' on the first line.
There are of course other possibilities but without knowing how it's
failing, any guesses would just be shots in the dark.
Regards,
Torben
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
On Mon, 2009-08-24 at 12:26 -0400, Paul M Foster wrote:
> On Mon, Aug 24, 2009 at 09:12:19AM -0700, Chris Carter wrote:
>
> >
> > Hi,
> >
> > The code below actually takes input from a web form and sends the fields
> > captured in an email. It used to work quite well since past few years. It
> > has stopped now. I used Google's mail servers (google.com/a/website.com)
> >
> > <?
> > $fName = $_REQUEST['fName'] ;
> > $emailid = $_REQUEST['emailid'] ;
> > $number = $_REQUEST['number'] ;
> > $message = $_REQUEST['message'] ;
> >
> > mail( "ch...@gmail.com", $number, $message, "From: $emailid" );
> > header( "Location: http://www.thankyou.com/thankYouContact.php" );
> > ?>
> >
> > This is the simplest one, how could it simply stop? Any help would be
> > appreciated, I have already lost 148 queries that came through this form.
>
> As a test, change $_REQUEST above to $_POST (assuming POST method on the
> form), and try it.
>
> Also check the return value of the mail() function to see if it thinks
> it has succeeded or failed. If it fails, check the mail logs on the
> server to find what the mail server thinks is wrong.
>
> Paul
>
> --
> Paul M. Foster
>
The $_REQUEST will not have anything to do with it. $_REQUEST contains
any values sent by POST.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
Is there any alternative method to do this !!! Sending email through PHP?
Paul M Foster wrote:
>
> On Mon, Aug 24, 2009 at 09:12:19AM -0700, Chris Carter wrote:
>
>>
>> Hi,
>>
>> The code below actually takes input from a web form and sends the fields
>> captured in an email. It used to work quite well since past few years. It
>> has stopped now. I used Google's mail servers (google.com/a/website.com)
>>
>> <?
>> $fName = $_REQUEST['fName'] ;
>> $emailid = $_REQUEST['emailid'] ;
>> $number = $_REQUEST['number'] ;
>> $message = $_REQUEST['message'] ;
>>
>> mail( "ch...@gmail.com", $number, $message, "From: $emailid" );
>> header( "Location: http://www.thankyou.com/thankYouContact.php" );
>> ?>
>>
>> This is the simplest one, how could it simply stop? Any help would be
>> appreciated, I have already lost 148 queries that came through this form.
>
> As a test, change $_REQUEST above to $_POST (assuming POST method on the
> form), and try it.
>
> Also check the return value of the mail() function to see if it thinks
> it has succeeded or failed. If it fails, check the mail logs on the
> server to find what the mail server thinks is wrong.
>
> Paul
>
> --
> Paul M. Foster
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
--
View this message in context:
http://www.nabble.com/What-if-this-code-is-right---It-worked-perfectly-for-years%21%21-tp25118874p25120282.html
Sent from the PHP - General mailing list archive at Nabble.com.
--- End Message ---
--- Begin Message ---
PHP pages won't open at all on my server. HTML pages open fine, but when
going to the PHP pages that are on my server, the browser tries to download
the page like a file instead of presenting it by the browser. What can I do
to make the PHP processor to be handled properly? Do I need to recompile it
again, and if so, what switches should I use?
I am running Apache version 2.2.11. I'm on Fedora 2.6.11-1.1369_FC4 on that
particular server. I'm running PHP 5.2.9 which I downloaded directly from
the php web site, then untarred, ran make, and make install commands as
described in the php INSTALL file that was included with the distribution..
==================
Example 2-4. Installation Instructions (Apache 2 Shared Module Version)
1. gzip -d httpd-2_0_NN.tar.gz
2. tar xvf httpd-2_0_NN.tar
3. gunzip php-NN.tar.gz
4. tar -xvf php-NN.tar
5. cd httpd-2_0_NN
6. ./configure --enable-so
7. make
8. make install
==================
You will probably try to talk me into using yum, I would like to but it is
broken and fixing it leads to even more troblemshooting. I want to fix this
first, then I will tackle the yum issue next.
--- End Message ---
--- Begin Message ---
On Mon, Aug 24, 2009 at 01:30:00PM -0500, RRT wrote:
> PHP pages won't open at all on my server. HTML pages open fine, but when
> going to the PHP pages that are on my server, the browser tries to download
> the page like a file instead of presenting it by the browser. What can I do
> to make the PHP processor to be handled properly? Do I need to recompile it
> again, and if so, what switches should I use?
>
> I am running Apache version 2.2.11. I'm on Fedora 2.6.11-1.1369_FC4 on that
> particular server. I'm running PHP 5.2.9 which I downloaded directly from
> the php web site, then untarred, ran make, and make install commands as
> described in the php INSTALL file that was included with the distribution..
Hello,
If PHP is installed properly, look at step 14 (loading the module in
apache) and step 15 (Tell Apache to parse certain extensions as PHP)
in the PHP installation documentation.
http://www.php.net/manual/en/install.unix.apache2.php
Regards,
-- Ryan Cavicchioni
--- End Message ---