php-general Digest 16 Oct 2005 21:33:21 -0000 Issue 3741
Topics (messages 224194 through 224206):
Re: RegEx - Is this right?
224194 by: Oliver Grätz
Caching problems .. I think
224195 by: Søren Schimkat
224197 by: James Benson
No redirect with header()
224196 by: Dotan Cohen
224198 by: Paul Waring
224199 by: Dotan Cohen
224200 by: Paul Waring
QF & FB duplicate element form
224201 by: Jorge
Re: [PHP-WIN] Is this a PHP bug?
224202 by: tg-php.gryffyndevelopment.com
Silly regex giveing me a hard time
224203 by: Dotan Cohen
224204 by: Anas Mughal
224205 by: Darvin
224206 by: Dotan Cohen
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 ---
I don't know if these are equal.
What about \r\n line endings?
And what about \r line endings (from old Macs)?
I guess file() handles all of these cases (didn't test it though)
and your code doesn't (with \r you'll get a one line file!).
AllOlli
--- End Message ---
--- Begin Message ---
Hi guys
I have a rather simple setup:
A few forms chained after each other (the first leds to the second which
leeds to the third and so on)
I´m using sessions - and starting each page like this:
header('Expires: ' . gmdate('D, d M Y H:i:s', (time() + (60 * 10))) . '
GMT');
session_cache_limiter('private_no_expire');
session_start();
... which I believe gives each page (and form result) a caching time of
10 minutes. The problem is that when using the back button in IE - IE
complains about the page and tells med that this page is the result of a
form and that the content has been blocked.
Can anyone tell me how to awoid this problem, so the backbutton can be
used, and stil give each page a caching time of 10 minutes?
--
Regards Søren Schimkat
www.schimkat.dk
--- End Message ---
--- Begin Message ---
SOunds like your form is using POST which does what you desribe to avoid
submitting the same info twice. only way I know is to use GET but that
would put al data in the URL.
Søren Schimkat wrote:
Hi guys
I have a rather simple setup:
A few forms chained after each other (the first leds to the second which
leeds to the third and so on)
I´m using sessions - and starting each page like this:
header('Expires: ' . gmdate('D, d M Y H:i:s', (time() + (60 * 10))) . '
GMT');
session_cache_limiter('private_no_expire');
session_start();
... which I believe gives each page (and form result) a caching time of
10 minutes. The problem is that when using the back button in IE - IE
complains about the page and tells med that this page is the result of a
form and that the content has been blocked.
Can anyone tell me how to awoid this problem, so the backbutton can be
used, and stil give each page a caching time of 10 minutes?
--- End Message ---
--- Begin Message ---
I am working on a redirect script to log "out"'s. I was trying to do
it with a header redirect:
<?php
// Log in database
/*
-snip-
*/
// Send user away
header ("Location: ".$url);
?>
Does this seem like it should work? It doesn't. What is the correct
syntax for these things? You can see the 'prototype' at
http://lyricslist.com: Just click on the logo or the word "Song
Lyrics" above the ads. Thanks in advance for any help.
Dotan Cohen.
--- End Message ---
--- Begin Message ---
On Sun, Oct 16, 2005 at 05:04:09PM +0200, Dotan Cohen wrote:
> header ("Location: ".$url);
> ?>
>
> Does this seem like it should work? It doesn't. What is the correct
> syntax for these things?
That code should work, and the example on your site seems to work for
me. The only thing you should make sure is that $url is an absolute URL,
even if you're redirecting within your own site (e.g. you shouldn't use
../lyrics/ or /lyrics/) - you may be able to get away without doing this
but it's not the "correct" way to do things.
You may want to change your code to this:
header("Location: $url"); // no point in concatenating since double
quotes will interpolate the value of $url anyway
exit();
I can't remember why, but calling the exit(); function fixed a problem I
was having a while back when I was being sent to the right URL but the
old one was staying in my browser address bar.
Paul
--
Rogue Tory
http://www.roguetory.org.uk
--- End Message ---
--- Begin Message ---
On 10/16/05, Paul Waring <[EMAIL PROTECTED]> wrote:
> On Sun, Oct 16, 2005 at 05:04:09PM +0200, Dotan Cohen wrote:
> > header ("Location: ".$url);
> > ?>
> >
> > Does this seem like it should work? It doesn't. What is the correct
> > syntax for these things?
>
> That code should work, and the example on your site seems to work for
> me. The only thing you should make sure is that $url is an absolute URL,
> even if you're redirecting within your own site (e.g. you shouldn't use
> ../lyrics/ or /lyrics/) - you may be able to get away without doing this
> but it's not the "correct" way to do things.
>
> You may want to change your code to this:
>
> header("Location: $url"); // no point in concatenating since double
> quotes will interpolate the value of $url anyway
> exit();
>
> I can't remember why, but calling the exit(); function fixed a problem I
> was having a while back when I was being sent to the right URL but the
> old one was staying in my browser address bar.
>
> Paul
>
> Rogue Tory
> http://www.roguetory.org.uk
>
Thanks, Paul. I stuck $url inside the double quotes, like you said. I
also added the exit; function. No go for me. I get a blank page.
You say that it worked for you? Where did it take you? It _should_
take you to another lyrics site. Did you stay on http://lyricslist.com
or go somewhere else?
Thank you.
Dotan
--- End Message ---
--- Begin Message ---
On Sun, Oct 16, 2005 at 05:25:12PM +0200, Dotan Cohen wrote:
> You say that it worked for you? Where did it take you? It _should_
> take you to another lyrics site. Did you stay on http://lyricslist.com
> or go somewhere else?
If I go to lyricslist.com and click the logo or the "Song Lyrics" link,
then I get redirected to lyricsfreak.com. No blank pages, and the URL in
my address bar changes too.
Paul
--
Rogue Tory
http://www.roguetory.org.uk
--- End Message ---
--- Begin Message ---
Hi guys!
I'm getting crazy about the following error working with QuickForm +
FrontBuilder for a sign up form.
As usual, login / passwd are shown in form by FB:
<code>
[......]
$auth = DB_DataObject::factory('auth');
$fb_auth =& DB_DataObject_FormBuilder::create($auth);
$frm_auth =& $fb_auth->getForm();
$auth->postGenerateForm(&$frm_auth,&$fb_auth);
[....]
</code>
I need user retypes password, then I added postGenerateForm() function
within Auth class. I also added preProcessForm() for encrypt passwd and
it works.
<code>
[.....]
function postGenerateForm(&$form,&$fb) {
// FALLA!! Repite dos veces el campo
$form->addElement('password', 'passwordR', 'Retype password',
array('size'=>32, 'maxlenght'=>32));
$form->addRule('passwordR', 'Retype password', 'required');
$form->addRule(array('password', 'passwordR'), 'Password does not
match.', 'compare');
}
function preProcessForm(&$data) {
if(isset($data['password'])) {
if($data['password'] != $this->password) {
$data['password'] = md5($data['password']);
}
}
//igualar id_user(auth) e id_user(users)
}
[....]
</code>
I think this should be work fine but text element passwordR is shown
three times instead two. If postGenerateForm() is not called then only
one password element is shown. Does anybody know why?
Thanks
--
Jorge Gonzalez y Hurtado de Mendoza
[EMAIL PROTECTED]
http://www.la-nevera.com
soon on your screen http://www.webgout.com, check it out
--- End Message ---
--- Begin Message ---
It's because PHP is trying to convert different var types into a common var
type and then compare them when you use ==. === means compare value AND type
so that's why it fails.
Your string, 'Some kind of string' is getting converted down to the lowest
common denominator, an int. Since there are no numbers in the string to grab
onto, it gets converted to nothing, an int value of zero.
If you had $x = "0" or if $y had contained numbers at all, it wouldn't have
passed.
But this is why when you use $x.'' it works properly because now you have
"0<empty string>", it's been converted to a string value "0". Good catch on
that though, shows good methodical debugging :)
So in the future, either use === or be extra aware of your variable types and
make sure you're comparing properly.
Good luck!
-TG
= = = Original message = = =
$x = 0; // Numeric zero
$y = 'Some kind of string';
if ($x == $y) echo 'they equal using ==';
if ($x === $y) echo 'they equal using ===';
The above will echo 'they equal using =='.
The values don't look very equal to me.
Can anyone explain the logic behind this?
I'm heading home now but look forward to your explanations tomorrow.
PS
Incidently, to 'fix' it so it behaves as it should, you can code:
if ($x.'' == $y.'') echo 'this will not print and all is good.';
Regards .. Ross
___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.
--- End Message ---
--- Begin Message ---
I have a list like this:
235 Some info
12323 other 5 things
No number on this line!
43 something or other
I need to remove the first number from each line, so that I will get this:
Some info
other 5 things
No number on this line!
something or other
So I tried:
$data=preg_replace("//n[ ]*[0-9][ ]*/", "", $data);
That is (I think): any amount of spaces, followed by any number,
followed by any amount of spaces. This doesn't seem to be the way to
do it. Anybody have a better idea? Thanks.
Dotan
http://technology-sleuth.com
--- End Message ---
--- Begin Message ---
Try this:
^[ ]*[0-9]*[ ]*
This will also strip out any blank spaces at the beginning of the line.
--
Anas Mughal
On 10/16/05, Dotan Cohen <[EMAIL PROTECTED]> wrote:
>
> I have a list like this:
> 235 Some info
> 12323 other 5 things
> No number on this line!
> 43 something or other
>
> I need to remove the first number from each line, so that I will get this:
> Some info
> other 5 things
> No number on this line!
> something or other
>
> So I tried:
> $data=preg_replace("//n[ ]*[0-9][ ]*/", "", $data);
>
> That is (I think): any amount of spaces, followed by any number,
> followed by any amount of spaces. This doesn't seem to be the way to
> do it. Anybody have a better idea? Thanks.
>
> Dotan
> http://technology-sleuth.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
--- End Message ---
--- Begin Message ---
Dotan Cohen wrote:
I have a list like this:
235 Some info
12323 other 5 things
No number on this line!
43 something or other
I need to remove the first number from each line, so that I will get this:
Some info
other 5 things
No number on this line!
something or other
So I tried:
$data=preg_replace("//n[ ]*[0-9][ ]*/", "", $data);
That is (I think): any amount of spaces, followed by any number,
followed by any amount of spaces. This doesn't seem to be the way to
do it. Anybody have a better idea? Thanks.
Dotan
http://technology-sleuth.com
Try
preg_replace("/^[ ]*[0-9]+[ ]*/", "", $data);
It means: from the beginning of $data looks for space (if any), then
almost one number followed by space (if any).
If you don't use ^ you may remove the number 5 'from other 5 things'
Darvin
--- End Message ---
--- Begin Message ---
On 10/16/05, Darvin <[EMAIL PROTECTED]> wrote:
> Dotan Cohen wrote:
> > I have a list like this:
> > 235 Some info
> > 12323 other 5 things
> > No number on this line!
> > 43 something or other
> >
> > I need to remove the first number from each line, so that I will get this:
> > Some info
> > other 5 things
> > No number on this line!
> > something or other
> >
> > So I tried:
> > $data=preg_replace("//n[ ]*[0-9][ ]*/", "", $data);
> >
> > That is (I think): any amount of spaces, followed by any number,
> > followed by any amount of spaces. This doesn't seem to be the way to
> > do it. Anybody have a better idea? Thanks.
> >
> > Dotan
> > http://technology-sleuth.com
>
> Try
> preg_replace("/^[ ]*[0-9]+[ ]*/", "", $data);
>
> It means: from the beginning of $data looks for space (if any), then
> almost one number followed by space (if any).
>
> If you don't use ^ you may remove the number 5 'from other 5 things'
>
> Darvin
>
Thanks all for the help on this one! Darvin's pointing out about the ^
was great- I couldn't quite figure that one out. You guys are the
greatest.
Dotan
http://technology-sleuth.com/internet/index.php
--- End Message ---