php-general Digest 5 Aug 2005 06:44:55 -0000 Issue 3607
Topics (messages 220025 through 220045):
Re: How to determine if a script instance is already running?
220025 by: Matthew Weier O'Phinney
Re: Performace and segfault errors with Php5 + Apache 1.3.x + linux-2.6.x
220026 by: Matthew Weier O'Phinney
Re: Do I need to use --with-pic with configure?
220027 by: Rasmus Lerdorf
Re: overwrite private class members in php5?
220028 by: Matthew Weier O'Phinney
Re: Class constants
220029 by: Matthew Weier O'Phinney
Sessions again....
220030 by: Suhas
220031 by: James
220032 by: Suhas
220033 by: James
220034 by: Suhas
220038 by: Jochem Maas
Re: very simple, yet can't think how.
220035 by: Esteamedpw.aol.com
Timing out a remote call
220036 by: Brian Dunning
220037 by: Torgny Bjers
Re: WAMP Performance Tuning
220039 by: JM
220044 by: Matthew Weier O'Phinney
Re: Interesting Referer behaviour- how to copy it?
220040 by: Jochem Maas
220041 by: Dotan Cohen
220042 by: Jochem Maas
Re: strip out too many newlines
220043 by: Al
login check
220045 by: sub.pudlz.com
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 ---
* Matt <[EMAIL PROTECTED]> :
> Perhaps "svscan" and its associated "daemontools" programs could be
> used to monitor the script instead of relying on cron.
Just a note: The above suggestion would assume you control the box, and
that you're running on a *nix system (i.e., you've got root on a linux,
bsd, solaris, AIX, etc. server).
> On 8/2/05, André Medeiros <[EMAIL PROTECTED]> wrote:
> > On Tue, 2005-08-02 at 15:09 +0100, Stut wrote:
> > > André Medeiros wrote:
> > > > Do like some services do:
> > > >
> > > > 1) Check if script.pid exists
> > > > 2) If it doesn't
> > > > 2.1) Write the process's PID onto the file
> > > > (http://pt.php.net/manual/en/function.getmypid.php)
> > > > 3) If it does
> > > > 3.1) Die gracefully :)
> > >
> > > Personally I'd extend that slightly to have the process touch the PID
> > > file every so often and to check that it's been touched recently when it
> > > starts up. Alternatively use the ps shell command to check that a
> > > process with that PID is still running, but that tends to be less
> > > reliable.
> > >
> > > If the process does decide to continue in spite of the PID file existing
> > > it should issue a a shell kill command to kill that PID in case it's
> > > hung or a zombie.
> > >
> > > -Stut
> >
> > Excelent point!
--
Matthew Weier O'Phinney
Zend Certified Engineer
http://weierophinney.net/matthew/
--- End Message ---
--- Begin Message ---
* Edwin Barrios <[EMAIL PROTECTED]>:
> i'am developing a web framework SifEngine (Secure Web Inteface
> framework) that implement MVC applaying the security ideas from
> http://phpsec.org. I'am using DomXML, Sqlite, Mcrypt and PostgreSql.
>
> After of post my development on the internet ( i have been thinking
> to post on PEAR ), i made simple tests of aplications with my
> framework. During the implementation, i used Slackware 10.1 with
> kernel 2.4.29 + php5.0.4 + Apache 1.3.2, with no problems. I didn't
> detect performace problems or segfaults by apache. Then i decided to
> do the same test but with kernel 2.6.10, wating that no problems
> occur. However my expectation, on this new configuration all the
> aplications develped with my framework, had performance issues or in
> the worst situation produce apache forks to be restarted, or a lot of
> apache forks.
>
> i don't undestand why this occur, i try to use valigrand to verify
> memorie lacks without results.
Are you using __call() or any of the other overloading methods? I had a
situation several months ago where __call() was going into an infinite
loop and causing segfaults. Once I tracked that down and fixed it,
everything worked fine.
--
Matthew Weier O'Phinney
Zend Certified Engineer
http://weierophinney.net/matthew/
--- End Message ---
--- Begin Message ---
Denis Solovyov wrote:
> I have a question I can't answer by myself. :)
>
> Do I need to use "--with-pic" option when configuring php 4?
>
> I'm going to build it as an Apache 1.3 DSO module and going to
> run multiple instances of Apache (under different users). I
> use Linux (kernel 2.4.30).
>
> Generally, when one may need to use "--with-pic"?
--with-pic is the default, so you don't need to add it.
-Rasmus
--- End Message ---
--- Begin Message ---
* Norbert Wenzel <[EMAIL PROTECTED]>:
> Hi, I've done something like this:
>
> class MyClass {
>
> private $var;
>
> function __construct($value) {
> $this->var = $value;
> }
>
> public function printVar() {
> echo($this->var);
> }
>
> }
>
> $object = new MyClass('1');
> $object->printVar(); // prints 1
> $object->var = 3; // Fatal Error as expected
> $object->$var = 2; // no error msg
$var is empty, so this is setting a non-existent class property to 2.
> $object->printVar(); // prints 2
I got 1 when running this -- just as I would expect. Are you sure it
printed 2?
Basically, if a property is undeclared, it is assumed public, so you can
set undefined properties without issue. If defined private or protected,
the calling script will not be able to alter the value.
--
Matthew Weier O'Phinney
Zend Certified Engineer
http://weierophinney.net/matthew/
--- End Message ---
--- Begin Message ---
* Marcus Bointon <[EMAIL PROTECTED]>:
> I'm not sure if this is a bug or a feature, but it seems you can't
> use class constants to set default values for class properties. You
> can, however, use them for default values for method params, e.g.:
>
> class foo {}
> const BAR = 100;
> private $thing = self::BAR;
> function wibble($a = self::BAR) {
> echo $a;
> }
> }
>
> In this case $this->thing will be undefined, but wibble() will get
> the correct default value for $a.
>
> Comments?
This has been the case since PHP4. From http://php.net/oop:
In PHP 4, only constant initializers for var variables are allowed. To
initialize variables with non-constant values, you need an
initialization function which is called automatically when an object is
being constructed from the class.
What is meant by 'constant initializers' is that you cannot define class
variables based on variables, constants, or globals -- defined in the
class or otherwise. So, the following is okay:
private $thing = 100;
But, as you saw, the following will barf:
private $thing = self::BAR;
private $thing = BAR;
private $thing = $_SERVER['SCRIPT_NAME'];
// etc.
So, in other words, the issues you're seeing are consistent with the
documentation.
--
Matthew Weier O'Phinney
Zend Certified Engineer
http://weierophinney.net/matthew/
--- End Message ---
--- Begin Message ---
Hello,
I am trying to understand how sessions work. I have this code. My
understanding is after 1 sec of script completion, (may be little
after that), the session should destroy.
I understand that it is huge overhead for server, not planning to do
this but want to understand how it really works.
This server uses cookie to store session. Setings in php.ini file are
defaut (1440 and probility is 1)
ini_set('session.auto_start', '0');
session_id('SSP');
session_cache_limiter("nocache");
ini_set('session.cookie_lifetime', '0');
ini_set('session.gc_probability', '100');
ini_set('session.gc_divisor', '100');
ini_set('session.gc_maxlifetime', '1');
session_start();
if(!session_is_registered('count'))
session_register('count');
echo ++$_SESSION['count'];
Any help will be appriciated!
Thanks
SP
--- End Message ---
--- Begin Message ---
So what is your question...?
----- Original Message -----
From: "Suhas" <[EMAIL PROTECTED]>
To: "php-general" <[email protected]>
Sent: Thursday, August 04, 2005 4:13 PM
Subject: [PHP] Sessions again....
Hello,
I am trying to understand how sessions work. I have this code. My
understanding is after 1 sec of script completion, (may be little
after that), the session should destroy.
I understand that it is huge overhead for server, not planning to do
this but want to understand how it really works.
This server uses cookie to store session. Setings in php.ini file are
defaut (1440 and probility is 1)
ini_set('session.auto_start', '0');
session_id('SSP');
session_cache_limiter("nocache");
ini_set('session.cookie_lifetime', '0');
ini_set('session.gc_probability', '100');
ini_set('session.gc_divisor', '100');
ini_set('session.gc_maxlifetime', '1');
session_start();
if(!session_is_registered('count'))
session_register('count');
echo ++$_SESSION['count'];
Any help will be appriciated!
Thanks
SP
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hello,
I am trying to understand how sessions work. I have this code. My
understanding is after 1 sec of script completion, (may be little
after that), the session should destroy.
I understand that it is huge overhead for server, not planning to do
this but want to understand how it really works.
This server uses cookie to store session. Setings in php.ini file are
defaut (1440 and probility is 1)
ini_set('session.auto_start', '0');
session_id('SSP');
session_cache_limiter("nocache");
ini_set('session.cookie_lifetime', '0');
ini_set('session.gc_probability', '100');
ini_set('session.gc_divisor', '100');
ini_set('session.gc_maxlifetime', '1');
session_start();
if(!session_is_registered('count'))
session_register('count');
echo ++$_SESSION['count'];
Any help will be appriciated!
Thanks
SP
--- End Message ---
--- Begin Message ---
session.cookie_lifetime integer
session.cookie_lifetime specifies the lifetime of the cookie in seconds
which is sent to the browser. The value 0 means "until the browser is
closed." Defaults to 0. See also session_get_cookie_params() and
session_set_cookie_params().
----- Original Message -----
From: "Suhas" <[EMAIL PROTECTED]>
To: "James" <[EMAIL PROTECTED]>; "php-general"
<[email protected]>
Sent: Thursday, August 04, 2005 4:35 PM
Subject: Re: [PHP] Sessions again....
Well script is not working as it is supposed to be. Even after 2 hrs I
visit the page the count variable increases by 1 than prevois value.
Any reason why is that so? If my understanding is not correct please correct
me.
Thanks
SP
On 8/4/05, James <[EMAIL PROTECTED]> wrote:
So what is your question...?
----- Original Message -----
From: "Suhas" <[EMAIL PROTECTED]>
To: "php-general" <[email protected]>
Sent: Thursday, August 04, 2005 4:13 PM
Subject: [PHP] Sessions again....
Hello,
I am trying to understand how sessions work. I have this code. My
understanding is after 1 sec of script completion, (may be little
after that), the session should destroy.
I understand that it is huge overhead for server, not planning to do
this but want to understand how it really works.
This server uses cookie to store session. Setings in php.ini file are
defaut (1440 and probility is 1)
ini_set('session.auto_start', '0');
session_id('SSP');
session_cache_limiter("nocache");
ini_set('session.cookie_lifetime', '0');
ini_set('session.gc_probability', '100');
ini_set('session.gc_divisor', '100');
ini_set('session.gc_maxlifetime', '1');
session_start();
if(!session_is_registered('count'))
session_register('count');
echo ++$_SESSION['count'];
Any help will be appriciated!
Thanks
SP
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Well script is not working as it is supposed to be. Even after 2 hrs I
visit the page the count variable increases by 1 than prevois value.
Any reason why is that so? If my understanding is not correct please correct me.
Thanks
SP
On 8/4/05, James <[EMAIL PROTECTED]> wrote:
> So what is your question...?
>
> ----- Original Message -----
> From: "Suhas" <[EMAIL PROTECTED]>
> To: "php-general" <[email protected]>
> Sent: Thursday, August 04, 2005 4:13 PM
> Subject: [PHP] Sessions again....
>
>
> Hello,
> I am trying to understand how sessions work. I have this code. My
> understanding is after 1 sec of script completion, (may be little
> after that), the session should destroy.
>
> I understand that it is huge overhead for server, not planning to do
> this but want to understand how it really works.
>
> This server uses cookie to store session. Setings in php.ini file are
> defaut (1440 and probility is 1)
>
>
> ini_set('session.auto_start', '0');
> session_id('SSP');
> session_cache_limiter("nocache");
> ini_set('session.cookie_lifetime', '0');
> ini_set('session.gc_probability', '100');
> ini_set('session.gc_divisor', '100');
> ini_set('session.gc_maxlifetime', '1');
> session_start();
>
> if(!session_is_registered('count'))
> session_register('count');
>
> echo ++$_SESSION['count'];
>
> Any help will be appriciated!
>
> Thanks
> SP
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Suhas wrote:
Hello,
I am trying to understand how sessions work. I have this code. My
understanding is after 1 sec of script completion, (may be little
after that), the session should destroy.
I understand that it is huge overhead for server, not planning to do
this but want to understand how it really works.
This server uses cookie to store session. Setings in php.ini file are
defaut (1440 and probility is 1)
ini_set('session.auto_start', '0');
this ini setting can onyl be set before php
starts - setting inside your script does nothing. I THINK.
session_id('SSP');
I wouldn't make the call to session_id() - not like that
anyway - insecure springs to mind - read more here:
http://php.net/session_id
IHMO you should just let php handle session id generation.
session_cache_limiter("nocache");
this function call determine the kind of
caching headers that will be sent.
yuor pages should not be cached by the browser
or any intermediary proxy.
ini_set('session.cookie_lifetime', '0');
this sets you session cookie to last for as long as you
keep the browser open.
ini_set('session.gc_probability', '100');
ini_set('session.gc_divisor', '100');
ini_set('session.gc_maxlifetime', '1');
these 3 ini setting have to do with garbage collection
(gc) of stale session data (files) - the numbers you use
100 & 100 mean that the garbage collector will be run
at the end of every request - thats very bad for performance.
session.gc_maxlifetime doesn't seem to be being honored ..
this may be down to your version of php, your OS, a combination
thereof - or it may even be that the value is too small to
be meaningful. or the session.cookie_lifetime may be
interfering - I just don't know but seems _like_ incorrect behaviour
bare in mind that although you are calling ini_set() on all these
setting that does not mean that any of the values you give are actually
being set successfully - use ini_get() after your call to session_start()
and echo out the results to determine what values are actually in
affect.
session_start();
indeed - you must call session_start() before trying to
use $_SESSION
if(!session_is_registered('count'))
session_register('count');
echo ++$_SESSION['count'];
don't mix the use session_register() and the $_SESSION
superglobal - in fact just use the $_SESSION superglobal
and forget session_reigster completely i.e.
you can just do:
if (!isset($_SESSION['count'])) {
$_SESSION['count'] = 0;
}
$_SESSION['count']++;
Any help will be appriciated!
HTH (I might need correcting on some of the details - anyone
care to chip in?)
Thanks
SP
--- End Message ---
--- Begin Message ---
Thanks! tried googling - only found "using ruby to automatically generate
php sites"...
the SW-Soft "Site Builder" program is a great program - looking all through
it now.
Thanks!
--- End Message ---
--- Begin Message ---
For one project, I'm required to access a web service for every page.
Basically it returns a little bit of random text. I have no control
over the web service, and there is no possibility of cacheing or
bringing it locally: the requirements are that it be accessed live
across the Internet every time.
Most times it's instantaneous, but sometimes it can hang. I want to
give it a half-second timeout, which we're allowed to do, but there's
no documentation provided. Here is how we call it now (really simple):
include('http://04planet.info/kfc/grab_one.php');
I have STFW and RTFM and could only find vague references like "use
fsockopen instead" or "stream_set_timeout()" but I can't find an
actual complete working example anywhere. Any pointers?
--- End Message ---
--- Begin Message ---
Brian Dunning wrote:
> For one project, I'm required to access a web service for every page.
> Basically it returns a little bit of random text. I have no control
> over the web service, and there is no possibility of cacheing or
> bringing it locally: the requirements are that it be accessed live
> across the Internet every time.
>
> Most times it's instantaneous, but sometimes it can hang. I want to
> give it a half-second timeout, which we're allowed to do, but there's
> no documentation provided. Here is how we call it now (really simple):
>
> include('http://04planet.info/kfc/grab_one.php');
>
> I have STFW and RTFM and could only find vague references like "use
> fsockopen instead" or "stream_set_timeout()" but I can't find an
> actual complete working example anywhere. Any pointers?
>
Generally, using include or file_get_contents() for a remote call is a
Bad Idea. Perhaps if you used curl instead? You have a lot more control
over the entire call that way. Of course, the curl code might be a bit
bulkier in PHP, but I find it works quite well.
As for fsockopen(), it works just like a file pointer.
http://www.php.net/manual/en/function.fsockopen.php
That manual page gives a pretty good description of how to use it.
Idea: "The socket will by default be opened in blocking mode. You can
switch it to non-blocking mode by using stream_set_blocking()."
The last parameter to fsockopen() is the timeout for connecting to the
socket, and the manual describes it as such:
"Note: If you need to set a timeout for reading/writing data over the
socket, use stream_set_timeout(), as the timeout parameter to
fsockopen() only applies while connecting the socket."
Regards,
Torgny
--- End Message ---
--- Begin Message ---
I'm quoting out a system for a Windows/Apache/PHP/MySQL
database-driven web application I've written. I've never gotten too
deep into determining what is the actual performance bottleneck in
this scenario. Is it the disk or the RAM?
I expect about 75-100 users during business hours. 90% will be in the
LAN and 10% will go over the WAN.
I'm wondering if I can get good performance out of a small system with
2GB RAM, 1GBps NIC, and a SATA disk or three spanned.
--- End Message ---
--- Begin Message ---
* JM <[EMAIL PROTECTED]>:
> I'm quoting out a system for a Windows/Apache/PHP/MySQL
> database-driven web application I've written. I've never gotten too
> deep into determining what is the actual performance bottleneck in
> this scenario. Is it the disk or the RAM?
>
> I expect about 75-100 users during business hours. 90% will be in the
> LAN and 10% will go over the WAN.
>
> I'm wondering if I can get good performance out of a small system with
> 2GB RAM, 1GBps NIC, and a SATA disk or three spanned.
You don't indicate how many queries are made on a given page, how much
data is handled, etc., Without seeing some code, it's hard to say what
the bottleneck for performance will be.
I've done some fairly critical stuff that, because I took the time to
optimize the database, optimize how much data gets displayed at a given
time (pagination is a *good* thing), streamlined the code to minimize
file and database calls, and setup the box to only run what was
necessary for serving pages, I was able to get away with using a
sub-400Mhz box with 384MB of RAM and a 20GB drive (this was a LAMP
setup). And it performed well, even with decent user load.
Disk calls are always more expensive than RAM calls -- but if you're
hitting a database, you're hitting the disk anyways (unless the queries
are getting cached). Run benchmarks, and try to minimize the number of
file calls and database calls to what is absolutely necessary.
Consider dumping Windows for a Linux flavor, or one of the BSDs. You can
tune these better to only run the services needed for the web stack
(Apache, MySQL, cron, firewall, formail/msmtp/sendmail).
Because of the shared-nothing architecture of PHP, you really don't need
heavy hitting boxes in order to get good performance. They don't hurt,
but they're not necessary.
--
Matthew Weier O'Phinney
Zend Certified Engineer
http://weierophinney.net/matthew/
--- End Message ---
--- Begin Message ---
Dotan Cohen wrote:
I creating a out.php file that will record clicks, and the redirect
the user to the site that he wanted. I am currently using
header("Location: $url"); which works as expected. The only problem
is, that the browser does not send $HTTP_REFERER info to the recieving
site.
However, that particular site is also linking to me via a out.php
file, and the browser DOES set $HTTP_REFERER on my site. So I've been
googleing for two days, and came up with this: There is a site that
displays the server reesponse of any server. So I put both of our
out.php files to the test. First, his server response:
HTTP/1.1 302 Found
Connection: close
Date: Thu, 04 Aug 2005 15:19:01 GMT
Location: http://lyricslist.com
Server: Apache/2.0.50 (FreeBSD) PHP/5.0.0
Vary: Accept-Encoding
Content-Length: 0
Content-Type: text/html; charset=ISO-8859-1
Client-Date: Thu, 04 Aug 2005 15:32:32 GMT
Client-Response-Num: 1
X-Powered-By: PHP/5.0.0
he runs php5, you run php4 - is the following set on his server perchance?:
echo $_SERVER['HTTP_REFERER'];
//or
echo getenv("HTTP_REFERER");
note that $HTTP_REFERER is depreciated in php5.
also the freeBSD box may have a firewall that is stripping the referer header
- freeBSD is the paranoid man's *nix of choice after all - at least all the
security freaks I know prefer it.
actually I did a bit of googling and there is a slim possiblity that the
firewall software on your PC is munging the referer header - try turning it off
also proxy servers may be stripping the header.
This redirects to lyricslist.com and correctly sets the $HTTP_REFERER
variable. Now, my server response:
HTTP/1.1 302 Found
Connection: close
Date: Thu, 04 Aug 2005 15:39:25 GMT
Location: http://lyricslist.com
Server: Apache/1.3.33 (Unix) mod_auth_passthrough/1.8
mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.3.11 FrontPage/5.0.2.2635
mod_ssl/2.8.22 OpenSSL/0.9.7a
Vary: Accept-Encoding
Content-Length: 0
Content-Type: text/html; charset=ISO-8859-1
Client-Date: Thu, 04 Aug 2005 15:39:29 GMT
Client-Response-Num: 1
X-Powered-By: PHP/4.3.11
This just does not set the $HTTP_REFERER variable! The referer
variable is even set to the original page that linked to out.php, and
not out.php itself! I have tried in IE 6.x, Firefox 1.0.6, Pheonix 0.7
(remember that!), and Opera 8.0. What could be the difference?
Thanks to all who rack thier brains on this one! It's been a fruitless
two days for me...
Dotan Cohen
http://lyricslist.com/lyrics/artist_albums/118/chumbawamba.php
Chumbawamba Song Lyrics
--- End Message ---
--- Begin Message ---
On 8/5/05, Jochem Maas <[EMAIL PROTECTED]> wrote:
> he runs php5, you run php4 - is the following set on his server perchance?:
>
> echo $_SERVER['HTTP_REFERER'];
> //or
> echo getenv("HTTP_REFERER");
>
> note that $HTTP_REFERER is depreciated in php5.
> also the freeBSD box may have a firewall that is stripping the referer header
> - freeBSD is the paranoid man's *nix of choice after all - at least all the
> security freaks I know prefer it.
>
> actually I did a bit of googling and there is a slim possiblity that the
> firewall software on your PC is munging the referer header - try turning it
> off
>
> also proxy servers may be stripping the header.
>
Thanks, Jochem, for looking into this. I just this minute figured out
my mistake- I was typing in the address out.php into the browser,
because I was expecting the referer to be out.php. But, the referer
that is sent is the page that LINKS to out.php!! As there was nothing
linking to it, there was no referer! I'm now digging a deep hole to
bury myself in...
Dotan
http://lyricslist.com/lyrics/artist_albums/137/crosby_stills_and_nash.php
Crosby, Stills And Nash Song Lyrics
--- End Message ---
--- Begin Message ---
Dotan Cohen wrote:
On 8/5/05, Jochem Maas <[EMAIL PROTECTED]> wrote:
he runs php5, you run php4 - is the following set on his server perchance?:
echo $_SERVER['HTTP_REFERER'];
//or
echo getenv("HTTP_REFERER");
note that $HTTP_REFERER is depreciated in php5.
also the freeBSD box may have a firewall that is stripping the referer header
- freeBSD is the paranoid man's *nix of choice after all - at least all the
security freaks I know prefer it.
actually I did a bit of googling and there is a slim possiblity that the
firewall software on your PC is munging the referer header - try turning it off
also proxy servers may be stripping the header.
Thanks, Jochem, for looking into this. I just this minute figured out
my mistake- I was typing in the address out.php into the browser,
because I was expecting the referer to be out.php. But, the referer
that is sent is the page that LINKS to out.php!! As there was nothing
linking to it, there was no referer! I'm now digging a deep hole to
bury myself in...
have a spade on me my friend ;-)
Dotan
http://lyricslist.com/lyrics/artist_albums/137/crosby_stills_and_nash.php
Crosby, Stills And Nash Song Lyrics
--- End Message ---
--- Begin Message ---
Sebastian wrote:
im working on a comment/forum app and when a user enters too many
carriage returns i want to remove them before insert to db.
example, user input:
-----snip-----
[quote=user]
foo
[/quote]
<bunch of extra lines>
more text...
-----snip-----
I to change to:
[quote=user]foo[/quote]
more text...
i try this regexp:
$message =
preg_replace('#(\[quote(=("|"|\'|)([^\]]*)\\3)?\])\s+#i', "\\1\n",
$_POST['message']);
doesn't remove / replace anything.
I need for it to work when they use [quote=xx] or [quote] and ends with
[/quote]
any help?
$str= preg_replace("%(\r\n|\r|\n)%", "\n", $str);
$str= preg_replace("%\n\n+%", "\n\n", $str); //max 2 \n
--- End Message ---
--- Begin Message ---
I think this is the way I need to write my if statement.
if ( $min && $user[ "min" ] == $min && $user[ "pin" ] == $pin || $pin ==
'allow')
$min login name entered by the customer at the form.
$user[min] is the login name from my sql db that matches $min
$user[pin] is the password from mysql db that matches $min
$pin is the password that is entered by the user
There's 4 checks
1) $min must have a value
2) $user[ "min" ] must equal $min
3) $user[ "pin" ] must equal $pin
4) $pin == 'allow'
I want it so that both 1 and 2 must be true and either 3 or 4 must be true.
Will this if statement work?
Andrew Darrow
Kronos1 Productions
www.pudlz.com
--- End Message ---