php-general Digest 1 Sep 2007 05:05:25 -0000 Issue 4993
Topics (messages 261564 through 261581):
Re: Reload page after form submit
261564 by: Afan Pasalic
261577 by: brian
regular expression question
261565 by: Matthew Lasar
261566 by: Per Jessen
261567 by: Matthew Lasar
261569 by: Per Jessen
PHP + PDO + MySQL + Stored Procedure + PREPARE = Problem
261568 by: Uzed
Is a small memory footprint better for a php script?
261570 by: Mark
261571 by: Robert Cummings
Re: About Session And Cookies
261572 by: Dan
Re: text to HTML
261573 by: Dan
261578 by: M. Sokolewicz
Re: help with session
261574 by: Dan
Re: Which CAPTCHA is the besta?
261575 by: Dan
Re: for loop inside a switch
261576 by: Dan
261579 by: Robert Cummings
261581 by: jekillen
How to implement Open-ID on my web server?
261580 by: Ronald Wiplinger
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 ---
brian wrote:
Instruct ICC wrote:
From your rough code, I'd say the OP always needs the select block
(just remove the "else" keyword and keep the block) for the current
info at the present page refresh/load. But I'd like clarification on
how the OP thinks about it.
That's close, i think. But the select isn't necessary if the user has
submitted a post because, either way, $first & $last will be set to
the latest values.
The problem that i see is here:
if (isset($_POST))
This will always return TRUE. It should rather be:
if (isset($_POST['name_of_your_submit_btn']))
or some other form element, at least.
I don't know if this was simply because it was a rough draft of the
code or even if it's the cause of the problem (which i still don't
quite understand) but, anyway ...
brian
nope. ONLY when form with method POST is submitted. if you open the page
first time "else" block will be executed.
though, I agree it's much better to have if(isset($_POST['SubmitForm'])
and $_POST['SubmitForm'] == 'Submit')
where <input type=Submit name=SubmitForm value="Submit">
but, as I said earlier, it's not the code, just an idea.
-afan
--- End Message ---
--- Begin Message ---
Afan Pasalic wrote:
brian wrote:
The problem that i see is here:
if (isset($_POST))
This will always return TRUE. It should rather be:
if (isset($_POST['name_of_your_submit_btn']))
or some other form element, at least.
I don't know if this was simply because it was a rough draft of the
code or even if it's the cause of the problem (which i still don't
quite understand) but, anyway ...
brian
nope. ONLY when form with method POST is submitted. if you open the page
first time "else" block will be executed.
though, I agree it's much better to have if(isset($_POST['SubmitForm'])
and $_POST['SubmitForm'] == 'Submit')
where <input type=Submit name=SubmitForm value="Submit">
but, as I said earlier, it's not the code, just an idea.
<?php
if (isset($_POST))
{
print('What did i tell you?');
}
?>
--- End Message ---
--- Begin Message ---
Hello:
I've adapted this regular expression script from a book, but I'm not
clear why it works.
$email = "[EMAIL PROTECTED]";
$pattern = "/[EMAIL PROTECTED]@([-a-z0-9]+\.)+[a-z]{2,}/";
_______
if ( preg_match($pattern,$email) )
{
print "yes! " . $email . " matches!";
}
else { print "no match"; }
_______
When I run this script, I get the "yes! [EMAIL PROTECTED]
matches!" statement.
But I don't understand why the second half of the regular expression
works. I'm talking about this part:
@([-a-z0-9]+\.)+[a-z]{2,}/";
why is it able to detect repeated sections of the email address after
"@" that are separated by periods? like "@email.alaska.com" . It
looks to me like it's only looking for one example of that pattern.
Does the "()" allow an unlimited number of patterns to pass?
thanks for any and all guidance
Matthew
Matthew Lasar || llfcc.net
--- End Message ---
--- Begin Message ---
Matthew Lasar wrote:
> But I don't understand why the second half of the regular expression
> works. I'm talking about this part:
>
> @([-a-z0-9]+\.)+[a-z]{2,}/";
>
> why is it able to detect repeated sections of the email address after
> "@" that are separated by periods? like "@email.alaska.com" . It
> looks to me like it's only looking for one example of that pattern.
> Does the "()" allow an unlimited number of patterns to pass?
No, but the following '+' does.
/Per Jessen, Zürich
--- End Message ---
--- Begin Message ---
At 11:32 AM 8/31/2007, Per Jessen wrote:
Matthew Lasar wrote:
> But I don't understand why the second half of the regular expression
> works. I'm talking about this part:
>
> @([-a-z0-9]+\.)+[a-z]{2,}/";
>
> why is it able to detect repeated sections of the email address after
> "@" that are separated by periods? like "@email.alaska.com" . It
> looks to me like it's only looking for one example of that pattern.
> Does the "()" allow an unlimited number of patterns to pass?
No, but the following '+' does.
But how? The +[a-z]{2,} seems to allow at least
two a-z clusters, but it doesn't include a period. /ml
/Per Jessen, Zürich
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.484 / Virus Database: 269.13.0/980
- Release Date: 8/30/2007 6:05 PM
--- End Message ---
--- Begin Message ---
Matthew Lasar wrote:
> At 11:32 AM 8/31/2007, Per Jessen wrote:
>>Matthew Lasar wrote:
>>
>> > But I don't understand why the second half of the regular
>> > expression works. I'm talking about this part:
>> >
>> > @([-a-z0-9]+\.)+[a-z]{2,}/";
>> >
>> > why is it able to detect repeated sections of the email address
>> > after "@" that are separated by periods? like "@email.alaska.com" .
>> > It looks to me like it's only looking for one example of that
>> > pattern. Does the "()" allow an unlimited number of patterns to
>> > pass?
>>
>>No, but the following '+' does.
>
> But how? The +[a-z]{2,} seems to allow at least
> two a-z clusters, but it doesn't include a period. /ml
>
That plus applies to the grouping () before it:
([-a-z0-9]+\.)+ one or more sequences of -a-z0-9 followed by a period
/Per Jessen, Zürich
--- End Message ---
--- Begin Message ---
Hi all,
I've found a bug when working on a PHP script using a PDO connector.
When I made a Store Procedure using the PREPARE statement something
messed up the result im my PHP script.
Please go to my blog http://huzed.com/zed/?p=21 and see code.
Tanks for help.
ZED
--- End Message ---
--- Begin Message ---
Hey,
I'm wondering something about memory usage.
I just looked at how much memory the newest phpbb is using and that's
over 2 mega bytes!!
Now i'm working on a php script that is currently using around 600 kilo bytes.
The question now is: what is better? a script with a small memory
usage? or is that something i don't need to look at?
And when is memory usage gonna be a issue? is that when you have ALOT
of simultaneous users? (lets say 100 all the time.. not that i have
that.. but just for the idea).
Thanx,
Mark.
--- End Message ---
--- Begin Message ---
On Fri, 2007-08-31 at 23:06 +0200, Mark wrote:
>
> The question now is: what is better? a script with a small memory
> usage? or is that something i don't need to look at?
It depends... do you find the following script better? Better than what?
It definitely has a small memory footpring:
<?php
echo 'Brought to you by the ridiculous question department.';
?>
> And when is memory usage gonna be a issue? is that when you have ALOT
> of simultaneous users? (lets say 100 all the time.. not that i have
> that.. but just for the idea).
Let's see... (100 * 2) = 200 megs.
My desktop computer... (2048 - 200) = 1848.
I'm not seeing an issue... A greater problem is going to be
database/filesystem bottlenecks, or possible poorly written scripts that
suck the life out of your processor(s)/core(s).
Cheers,
Rob.
--
...........................................................
SwarmBuy.com - http://www.swarmbuy.com
Leveraging the buying power of the masses!
...........................................................
--- End Message ---
--- Begin Message ---
Wow, you really need to be carefull when ever you're dealing with money,
although if you're just handing the objects in a cart and passing that to a
secure payment system then it's not as big of a deal.
Cookies can be stolen.
Sessions are vulnerable to snooping if you're on a shared server.
They have their pros and cons, and it would take way to long to explain the
way each of them work. You're best off to learn about both in a depth with
a security standpoint.
"Kelvin Park" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
I am trying to setup a secure login system.
I've heard that if I use just cookies for login, members without cookie
turned out won't be able to see the member pages.
Is using session recommended for e-commerce websites with shopping carts?
Or, using both of them might be more effective in some way.
--- End Message ---
--- Begin Message ---
As I know there's no real WYSIWYG text to html converters. Plus this
wouldn't do much more than handling paragraphs and new lines.
If you're looking for a way to write html from a textbox check out
FCKEditor.
Sorry I couldn't help much. If you really do have only the limited need of
paragaphs and newlines then go with Ron's solution, it'll work just fine.
- Dan
"Ron Piggott" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Is there a PHP command that turns text into HTML?
EXAMPLE:
"before"
Hi.
How are you doing?
"after"
Hi.<p>
How are you doing?<p>
--- End Message ---
--- Begin Message ---
Dan wrote:
As I know there's no real WYSIWYG text to html converters. Plus this
wouldn't do much more than handling paragraphs and new lines.
If you're looking for a way to write html from a textbox check out
FCKEditor.
Sorry I couldn't help much. If you really do have only the limited need
of paragaphs and newlines then go with Ron's solution, it'll work just
fine.
- Dan
"Ron Piggott" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Is there a PHP command that turns text into HTML?
EXAMPLE:
"before"
Hi.
How are you doing?
"after"
Hi.<p>
How are you doing?<p>
Since using <p> to insert line-breaks is bad style, use <br> instead (or
the <br /> variant if using XHTML).
You can use php's built-in nl2br() function to do this.
--- End Message ---
--- Begin Message ---
You should be sanatizing code here. When you save it to the session and
when it's output. Look arround the newsgroups or online for info about it,
it's everywhere.
- Dan
"mike" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
On 8/26/07, Jason Cartledge <[EMAIL PROTECTED]> wrote:
I would replace $_REQUEST with $_GET or $_POST (as appropriate)
if ( !empty($_REQUEST['gender']) )
{
$registrationGender=$_REQUEST['gender'];
}
else {
Personally I would use if(isset($_SESSION['registrationGender'])) here
if (session_is_registered('registrationGender'))
{
$registrationGender=$_SESSION['registrationGender'];
print "you are preregistered as a $registrationGender";
}
else
{
print "your gender is unknown, youare assumed to be a
male";
$_SESSION['registrationGender']='male';
I would change it to assign it here. No need to assign it a second
time below, since you are just printing the session variable if it is
already set
}
}
Those are a couple quick things my tired bloodshot eyes thought of.
--- End Message ---
--- Begin Message ---
Well what do you mean by "best"? Best at keeping spammers away, ease of
use(playing sound for handicapped people), fastest?
If you want to keep spammers away you could go with some super complicated
script that distorts letters so much that it's really hard. This keeps away
not only spambots but also your users :'(. If you go for ease of use then
it's probably a popular script and people already have bots that look for
sites using those particular scripts and have other bots which can crack the
capchas.
In my opinion the best of both worlds can be done by making it yourslef...
yes form scratch. If there's a one of a kind script nobody has seen it
before and they probably dont' have programs to crack it. Plus it's really
easy for users to use since it can be made simple. Plus then you have
control over the source.
- Dan
""Tony Di Croce"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
I need a CAPTCHA script.... Which one is the best? (I dont mind if its
somewhat difficult).
--- End Message ---
--- Begin Message ---
Sanjeev is right. You're thinking about the problem backwards. You're
trying to build a Switch inside a loop. Remember, if you ever have to do
some operating multiple times you're using a forloop, then the thing that
you want to repeat(switch case) is INSIDE the for loop.
- Dan
""Sanjeev N"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
This will not work at all..
Instead of switch try with if condition as follows
for ($i=0; $i <21; $i++) {
if(faq$i == $q){
echo $faq1;
break;
}
}
Now it works..
You can write the code to display the result how you want.. but you cant
write the code to write a code :)
Cheers
Warm Regards,
Sanjeev
http://www.sanchanworld.com
http://webdirectory.sanchanworld.com - Submit your website URL
http://webhosting.sanchanworld.com - Choose your best web hosting plan
-----Original Message-----
From: Hulf [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 16, 2007 3:11 PM
To: [EMAIL PROTECTED]
Subject: [PHP] for loop inside a switch
Hi,
switch ($q) {
for ($i=0; $i <21; $i++) {
case 'faq$i':
echo $faq1;
break;
}
}
I just want to loop out a big long list of cases.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
On Fri, 2007-08-31 at 15:56 -0700, Dan wrote:
> Sanjeev is right. You're thinking about the problem backwards. You're
> trying to build a Switch inside a loop. Remember, if you ever have to do
> some operating multiple times you're using a forloop, then the thing that
> you want to repeat(switch case) is INSIDE the for loop.
Not always true. Sometimes once you've made the switch it applies to all
members of a data array. In which case switching on every iteration is a
waste of processor since you can check a single time outside the loop.
Cheers,
Rob.
--
...........................................................
SwarmBuy.com - http://www.swarmbuy.com
Leveraging the buying power of the masses!
...........................................................
--- End Message ---
--- Begin Message ---
On Aug 31, 2007, at 6:26 PM, Robert Cummings wrote:
On Fri, 2007-08-31 at 15:56 -0700, Dan wrote:
Sanjeev is right. You're thinking about the problem backwards.
You're
trying to build a Switch inside a loop. Remember, if you ever have
to do
some operating multiple times you're using a forloop, then the thing
that
you want to repeat(switch case) is INSIDE the for loop.
Not always true. Sometimes once you've made the switch it applies to
all
members of a data array. In which case switching on every iteration is
a
waste of processor since you can check a single time outside the loop.
Cheers,
Rob.
--
You can run a switch inside a for loop and when a case is matched set a
variable to true.
the break statement will break out of the switch, then inside the
iteration code, after
the switch block, test the variable for true. If it is true the use
another break instruction.
That should break out of the loop altogether at the end on that
particular iteration.
like so:
for($i = 0; $i < somevalue; $i++)
{
$bar = false;
switch($anotherValue[$i]) // /this assumes you are looping
through an indexed array
{ case 'foo':
$bar = true
//other code;
break;
default;
// $bar is not set to true so the loop continues
}
if($bar == true)
{
break;
}
/* instead of the default line in the switch statement
else
{
continue;
}
*/
}
Hope this is useful.
Jeff K
--- End Message ---
--- Begin Message ---
Hi,
I am looking for a way to implement OpenID on my webserver. Can anybody
point me on ONE place that describes ONE way, please!
I found many links, but I am now confused what I really need ;-(
I want that the customer can use his/her openid to login to signup/login
to our web sites. Herby the user should get the choice to use some of
the Open-ID preset field values to complete the signup process faster.
Thanks!
bye
Ronald
--- End Message ---