php-general Digest 27 Nov 2010 13:57:29 -0000 Issue 7057

Topics (messages 309692 through 309709):

Re: code quest
        309692 by: Bastien
        309705 by: Ashley Sheridan

Re: preg_match fails to resolve variable as a subject
        309693 by: Da Rock
        309695 by: Tamara Temple
        309698 by: Da Rock

PHP Add +1 mysql updates by 2?
        309694 by: Richard West
        309696 by: Tamara Temple
        309697 by: Tommy Pham
        309699 by: Richard West
        309700 by: Richard West
        309701 by: Peter Lind
        309702 by: Richard West
        309703 by: Peter Lind
        309704 by: Tommy Pham
        309706 by: Ashley Sheridan
        309707 by: Richard West
        309708 by: Richard West

Problem with RegEx for BBCode
        309709 by: Asmann, Roland

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 ---



On 2010-11-26, at 7:33 PM, Adam Richardson <simples...@gmail.com> wrote:

> On Fri, Nov 26, 2010 at 7:03 PM, Kirk Bailey <kbai...@howlermonkey.net>wrote:
> 
>> Hello all, my name is Kirk Bailey, and I am new to php, so please be
>> forbearing. I code in python, and am trying to learn this language as our
>> new client runs a web business based in it.
>> 
>> I need a routine that will return a list of every directory immediately
>> under the current directory- but nothing else, just a list of directories, 1
>> level deep, NO FILES, no listing of current dir or prior dir either.
>> 
>> Now in python, I would use os.walk, and use the list of dirs and throw the
>> other 2 lists away, but this ain't Kansas anymore. Does php even DO lists?
>> 
>> Um, a list is a 1 dimenional array, if have a list ALIST and you plug in 3,
>> you get back the contents of cell 3 in the list, whaqtever that content is.
>> so if cell 3 in a 6 celled list was "Ruby" then ALIST[3] would return the
>> string "ruby".
>> 
>> It's easy to iterate lists. For instance:
>> 
>>  print '<ul>'
>>  for dir in ALIST:
>>      print '<li><a href=\"/dir>",dir,'</a>
>>  print '</ul>
>> 
>> This would let me produce an ordered list of directories, each a link to
>> that directory.
>> This way, when a client installs a new product, the home page area listing
>> products offered automatically updates.
>> 
>> Further embellishment would let me replace the dir name with a BRIEF
>> description from a descriptor file read from that dir. Now how to do this in
>> php?
>> 
>> --
>> end
>> 
>> Very Truly yours,
>>               - Kirk Bailey,
>>                 Largo Florida
>> 
>>                     kniht                        +-----+
>>    | BOX |                       +-----+                        think
>> 
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
>> 
> To get you started:
> 
> function get_directories($path)
> {
>   $files_and_dirs = scandir($path);
>   $dirs = array_filter($files_and_dirs, function($elem) { return
> is_dir($elem); });
>   // $dirs also contains "." and "..", but you can get rid of them quite
> easily
>   return $dirs;
> }
> 
> Happy coding :)
> 
> Adam
> 
> -- 
> Nephtali:  PHP web framework that functions beautifully
> http://nephtaliproject.com


Code igniter, a php framework can do this with one call. It could be worth 
looking into

Bastien Koert
905-904-0334
Sent from my iPhone

--- End Message ---
--- Begin Message ---
On Fri, 2010-11-26 at 20:27 -0500, Bastien wrote:

> 
> 
> 
> On 2010-11-26, at 7:33 PM, Adam Richardson <simples...@gmail.com> wrote:
> 
> > On Fri, Nov 26, 2010 at 7:03 PM, Kirk Bailey 
> > <kbai...@howlermonkey.net>wrote:
> > 
> >> Hello all, my name is Kirk Bailey, and I am new to php, so please be
> >> forbearing. I code in python, and am trying to learn this language as our
> >> new client runs a web business based in it.
> >> 
> >> I need a routine that will return a list of every directory immediately
> >> under the current directory- but nothing else, just a list of directories, 
> >> 1
> >> level deep, NO FILES, no listing of current dir or prior dir either.
> >> 
> >> Now in python, I would use os.walk, and use the list of dirs and throw the
> >> other 2 lists away, but this ain't Kansas anymore. Does php even DO lists?
> >> 
> >> Um, a list is a 1 dimenional array, if have a list ALIST and you plug in 3,
> >> you get back the contents of cell 3 in the list, whaqtever that content is.
> >> so if cell 3 in a 6 celled list was "Ruby" then ALIST[3] would return the
> >> string "ruby".
> >> 
> >> It's easy to iterate lists. For instance:
> >> 
> >>  print '<ul>'
> >>  for dir in ALIST:
> >>      print '<li><a href=\"/dir>",dir,'</a>
> >>  print '</ul>
> >> 
> >> This would let me produce an ordered list of directories, each a link to
> >> that directory.
> >> This way, when a client installs a new product, the home page area listing
> >> products offered automatically updates.
> >> 
> >> Further embellishment would let me replace the dir name with a BRIEF
> >> description from a descriptor file read from that dir. Now how to do this 
> >> in
> >> php?
> >> 
> >> --
> >> end
> >> 
> >> Very Truly yours,
> >>               - Kirk Bailey,
> >>                 Largo Florida
> >> 
> >>                     kniht                        +-----+
> >>    | BOX |                       +-----+                        think
> >> 
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >> 
> >> 
> > To get you started:
> > 
> > function get_directories($path)
> > {
> >   $files_and_dirs = scandir($path);
> >   $dirs = array_filter($files_and_dirs, function($elem) { return
> > is_dir($elem); });
> >   // $dirs also contains "." and "..", but you can get rid of them quite
> > easily
> >   return $dirs;
> > }
> > 
> > Happy coding :)
> > 
> > Adam
> > 
> > -- 
> > Nephtali:  PHP web framework that functions beautifully
> > http://nephtaliproject.com
> 
> 
> Code igniter, a php framework can do this with one call. It could be worth 
> looking into
> 
> Bastien Koert
> 905-904-0334
> Sent from my iPhone



I'm not sure CodeIgniter would be of any help here. I don't recall any
function in the CodeIgniter framework that lists directories like this,
so he'd still have to end up coding it himself.

Also, python tends to be used more for command line stuff than websites.
CodeIgniter does have a CLI extension, but the app would just be
severely bloated running an entire PHP framework for what might only
need a light script. Bit like using a sledgehammer to hammer in a thumb
tack, can be done, but not really the best tool for the job.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
On 11/27/10 00:57, Richard Quadling wrote:
On 26 November 2010 00:07, Da Rock<php-l...@herveybayaustralia.com.au>  wrote:
preg_match("/(\d{1,3})(\.)$/", exec($mixer . ' ' . $command),&$matches)
Can you ...

var_dump(exec($mixer . ' ' . $command));

I wonder if the output includes a new line which you are not
accounting for in the regex.

Haven't tried yet, but isn't that what $ is for? End of line?

And exec only gives one line- the last line of the output of the command. You have to provide a reference to an array for the entire output.

var_dump gives:
string(41) "Mixer vol is currently set to 75:75"

Any thoughts?

--- End Message ---
--- Begin Message ---

On Nov 26, 2010, at 7:28 PM, Da Rock wrote:

On 11/27/10 00:57, Richard Quadling wrote:
On 26 November 2010 00:07, Da Rock<php- l...@herveybayaustralia.com.au> wrote:

preg_match("/(\d{1,3})(\.)$/", exec($mixer . ' ' . $command),& $matches)

Can you ...

var_dump(exec($mixer . ' ' . $command));

I wonder if the output includes a new line which you are not
accounting for in the regex.


Haven't tried yet, but isn't that what $ is for? End of line?



$ matches end of line, but since your last match expression is to match explicitly the character '.' before end of line, and there's a newline, it won't match. Again, use trim() to get rid of the newline character at the end of the string returned by exec(). Looking at the output or

And exec only gives one line- the last line of the output of the command. You have to provide a reference to an array for the entire output.

var_dump gives:
string(41) "Mixer vol is currently set to 75:75"


It also looks like \d{1,3}\. won't match anything in the output string given by the command.



--- End Message ---
--- Begin Message ---
On 11/27/10 13:51, Tamara Temple wrote:

On Nov 26, 2010, at 7:28 PM, Da Rock wrote:

On 11/27/10 00:57, Richard Quadling wrote:
On 26 November 2010 00:07, Da Rock<php-l...@herveybayaustralia.com.au> wrote:

preg_match("/(\d{1,3})(\.)$/", exec($mixer . ' ' . $command),&$matches)

Can you ...

var_dump(exec($mixer . ' ' . $command));

I wonder if the output includes a new line which you are not
accounting for in the regex.


Haven't tried yet, but isn't that what $ is for? End of line?



$ matches end of line, but since your last match expression is to match explicitly the character '.' before end of line, and there's a newline, it won't match. Again, use trim() to get rid of the newline character at the end of the string returned by exec(). Looking at the output or

And exec only gives one line- the last line of the output of the command. You have to provide a reference to an array for the entire output.

var_dump gives:
string(41) "Mixer vol is currently set to 75:75"


It also looks like \d{1,3}\. won't match anything in the output string given by the command.



Thank you for that- that did it. I removed the \.

I am a little confused though; that regex was tested on several test sites and was deemed accurate on them, and one of them actually supplied the preg_match code. And if I run the command on a shell it actually outputs exactly the right subject for the regex- not to mention it got printed inadvertently (using system() ) via the php exactly the same. So I don't think I missed it somehow.

What I have constantly seen come up (shell and php/html) is: Mixer vol is currently set to 75:75. (including the period)

Don't get me wrong- you guys make sense; my system doesn't. I need to get to the bottom of this so I can ensure my code will port well. I don't want to get it all working and find it breaks when I run it on another system, albeit same OS (FreeBSD). Could be updates or variations of releases.

Just to check again, I ran the command on the shell again and sure enough the period is no longer there- but I can't for the life of me figure out when that changed as this code has never worked (and yes, I added in the \. to match the end of line because it originally wasn't working). Another great mystery? Weird... :)

Thanks again guys.

--- End Message ---
--- Begin Message ---
Hey guys,
I've never run into this before.
I have a field in mysql for page views.
So I pull out value and do +1 to new value - after UPDATE SET it has 
incremented by 2?

$val = $row['a_downloads'] ;

$new_val = $val+1;

mysql_query("UPDATE cbn_articles SET a_downloads='$new_val' WHERE a_id = 
'".$_GET['id']."' ");

Any ideas? What am I missing?
RD

--- End Message ---
--- Begin Message ---

On Nov 26, 2010, at 8:36 PM, Richard West wrote:

Hey guys,
I've never run into this before.
I have a field in mysql for page views.
So I pull out value and do +1 to new value - after UPDATE SET it has incremented by 2?

$val = $row['a_downloads'] ;

$new_val = $val+1;

mysql_query("UPDATE cbn_articles SET a_downloads='$new_val' WHERE a_id = '".$_GET['id']."' ");

Any ideas? What am I missing?
RD

a_downloads wouldn't happen to be an autoincrement value, would it?



--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Tamara Temple [mailto:tamouse.li...@gmail.com]
> Sent: Friday, November 26, 2010 7:54 PM
> To: Richard West
> Cc: PHP General Mailing List
> Subject: Re: [PHP] PHP Add +1 mysql updates by 2?
> 
> 
> On Nov 26, 2010, at 8:36 PM, Richard West wrote:
> 
> > Hey guys,
> > I've never run into this before.
> > I have a field in mysql for page views.
> > So I pull out value and do +1 to new value - after UPDATE SET it has
> > incremented by 2?
> >
> > $val = $row['a_downloads'] ;
> >
> > $new_val = $val+1;
> >
> > mysql_query("UPDATE cbn_articles SET a_downloads='$new_val' WHERE
> a_id
> > = '".$_GET['id']."' ");
> >
> > Any ideas? What am I missing?
> > RD
> 
> a_downloads wouldn't happen to be an autoincrement value, would it?
> 

IIRC, the auto_increment should only increment on an INSERT statement and
the field is omitted.  Besides, in MySQL, auto_increment must also be part
of the primary key.  From Richard's query, I'd say that his primary key
field is most likely a_id.  IMO, the best way to count something is to set
the field to an int(eger) type.  Then just run 'UPDATE table_name SET
count_field = count_field +1 WHERE criteria_column =  $criteria'.  This is
more safe as you many have simultaneous users downloading.  This would
ensure an accurate count, whereas your logic wouldn't.

Regards,
Tommy

PS:  Richard, you should validate and sanitize all inputs.  Your query is
prone to injection attack (deletion of rows or your entire DB deleted).  Use
either mysql_escape_string or, better yet, mysqli to prepare the statement
and bind the parameters.


--- End Message ---
--- Begin Message ---
No


On Nov 26, 2010, at 10:53 PM, Tamara Temple wrote:

> 
> On Nov 26, 2010, at 8:36 PM, Richard West wrote:
> 
>> Hey guys,
>> I've never run into this before.
>> I have a field in mysql for page views.
>> So I pull out value and do +1 to new value - after UPDATE SET it has 
>> incremented by 2?
>> 
>> $val = $row['a_downloads'] ;
>> 
>> $new_val = $val+1;
>> 
>> mysql_query("UPDATE cbn_articles SET a_downloads='$new_val' WHERE a_id = 
>> '".$_GET['id']."' ");
>> 
>> Any ideas? What am I missing?
>> RD
> 
> a_downloads wouldn't happen to be an autoincrement value, would it?
> 
> 


--- End Message ---
--- Begin Message ---
Hey Tommy,

I get the same when seting it to a_downloads=a_downloads+1  
It still increments by 2
I've never run into this before.
RD


On Nov 26, 2010, at 11:45 PM, Tommy Pham wrote:

>> -----Original Message-----
>> From: Tamara Temple [mailto:tamouse.li...@gmail.com]
>> Sent: Friday, November 26, 2010 7:54 PM
>> To: Richard West
>> Cc: PHP General Mailing List
>> Subject: Re: [PHP] PHP Add +1 mysql updates by 2?
>> 
>> 
>> On Nov 26, 2010, at 8:36 PM, Richard West wrote:
>> 
>>> Hey guys,
>>> I've never run into this before.
>>> I have a field in mysql for page views.
>>> So I pull out value and do +1 to new value - after UPDATE SET it has
>>> incremented by 2?
>>> 
>>> $val = $row['a_downloads'] ;
>>> 
>>> $new_val = $val+1;
>>> 
>>> mysql_query("UPDATE cbn_articles SET a_downloads='$new_val' WHERE
>> a_id
>>> = '".$_GET['id']."' ");
>>> 
>>> Any ideas? What am I missing?
>>> RD
>> 
>> a_downloads wouldn't happen to be an autoincrement value, would it?
>> 
> 
> IIRC, the auto_increment should only increment on an INSERT statement and
> the field is omitted.  Besides, in MySQL, auto_increment must also be part
> of the primary key.  From Richard's query, I'd say that his primary key
> field is most likely a_id.  IMO, the best way to count something is to set
> the field to an int(eger) type.  Then just run 'UPDATE table_name SET
> count_field = count_field +1 WHERE criteria_column =  $criteria'.  This is
> more safe as you many have simultaneous users downloading.  This would
> ensure an accurate count, whereas your logic wouldn't.
> 
> Regards,
> Tommy
> 
> PS:  Richard, you should validate and sanitize all inputs.  Your query is
> prone to injection attack (deletion of rows or your entire DB deleted).  Use
> either mysql_escape_string or, better yet, mysqli to prepare the statement
> and bind the parameters.
> 


--- End Message ---
--- Begin Message ---
On Saturday, November 27, 2010, Richard West <p...@cbnisp.com> wrote:
> Hey Tommy,
>
> I get the same when seting it to a_downloads=a_downloads+1
> It still increments by 2
> I've never run into this before.
> RD
>
>
> On Nov 26, 2010, at 11:45 PM, Tommy Pham wrote:
>
>>> -----Original Message-----
>>> From: Tamara Temple [mailto:tamouse.li...@gmail.com]
>>> Sent: Friday, November 26, 2010 7:54 PM
>>> To: Richard West
>>> Cc: PHP General Mailing List
>>> Subject: Re: [PHP] PHP Add +1 mysql updates by 2?
>>>
>>>
>>> On Nov 26, 2010, at 8:36 PM, Richard West wrote:
>>>
>>>> Hey guys,
>>>> I've never run into this before.
>>>> I have a field in mysql for page views.
>>>> So I pull out value and do +1 to new value - after UPDATE SET it has
>>>> incremented by 2?
>>>>
>>>> $val = $row['a_downloads'] ;
>>>>
>>>> $new_val = $val+1;
>>>>
>>>> mysql_query("UPDATE cbn_articles SET a_downloads='$new_val' WHERE
>>> a_id
>>>> = '".$_GET['id']."' ");
>>>>
>>>> Any ideas? What am I missing?
>>>> RD
>>>
>>> a_downloads wouldn't happen to be an autoincrement value, would it?
>>>
>>
>> IIRC, the auto_increment should only increment on an INSERT statement and
>> the field is omitted.  Besides, in MySQL, auto_increment must also be part
>> of the primary key.  From Richard's query, I'd say that his primary key
>> field is most likely a_id.  IMO, the best way to count something is to set
>> the field to an int(eger) type.  Then just run 'UPDATE table_name SET
>> count_field = count_field +1 WHERE criteria_column =  $criteria'.  This is
>> more safe as you many have simultaneous users downloading.  This would
>> ensure an accurate count, whereas your logic wouldn't.
>>
>> Regards,
>> Tommy
>>
>> PS:  Richard, you should validate and sanitize all inputs.  Your query is
>> prone to injection attack (deletion of rows or your entire DB deleted).  Use
>> either mysql_escape_string or, better yet, mysqli to prepare the statement
>> and bind the parameters.
>>
>

Sounds like you're hitting the page twice. Check for missing image,
css files, favicons, js files etc.

-- 
<hype>
WWW: plphp.dk / plind.dk
LinkedIn: plind
BeWelcome/Couchsurfing: Fake51
Twitter: kafe15
</hype>

--- End Message ---
--- Begin Message ---
I took that into consideration so I added the update at the very end of 
document...
Still the same,
RD




On Nov 27, 2010, at 12:31 AM, Peter Lind wrote:

> On Saturday, November 27, 2010, Richard West <p...@cbnisp.com> wrote:
>> Hey Tommy,
>> 
>> I get the same when seting it to a_downloads=a_downloads+1
>> It still increments by 2
>> I've never run into this before.
>> RD
>> 
>> 
>> On Nov 26, 2010, at 11:45 PM, Tommy Pham wrote:
>> 
>>>> -----Original Message-----
>>>> From: Tamara Temple [mailto:tamouse.li...@gmail.com]
>>>> Sent: Friday, November 26, 2010 7:54 PM
>>>> To: Richard West
>>>> Cc: PHP General Mailing List
>>>> Subject: Re: [PHP] PHP Add +1 mysql updates by 2?
>>>> 
>>>> 
>>>> On Nov 26, 2010, at 8:36 PM, Richard West wrote:
>>>> 
>>>>> Hey guys,
>>>>> I've never run into this before.
>>>>> I have a field in mysql for page views.
>>>>> So I pull out value and do +1 to new value - after UPDATE SET it has
>>>>> incremented by 2?
>>>>> 
>>>>> $val = $row['a_downloads'] ;
>>>>> 
>>>>> $new_val = $val+1;
>>>>> 
>>>>> mysql_query("UPDATE cbn_articles SET a_downloads='$new_val' WHERE
>>>> a_id
>>>>> = '".$_GET['id']."' ");
>>>>> 
>>>>> Any ideas? What am I missing?
>>>>> RD
>>>> 
>>>> a_downloads wouldn't happen to be an autoincrement value, would it?
>>>> 
>>> 
>>> IIRC, the auto_increment should only increment on an INSERT statement and
>>> the field is omitted.  Besides, in MySQL, auto_increment must also be part
>>> of the primary key.  From Richard's query, I'd say that his primary key
>>> field is most likely a_id.  IMO, the best way to count something is to set
>>> the field to an int(eger) type.  Then just run 'UPDATE table_name SET
>>> count_field = count_field +1 WHERE criteria_column =  $criteria'.  This is
>>> more safe as you many have simultaneous users downloading.  This would
>>> ensure an accurate count, whereas your logic wouldn't.
>>> 
>>> Regards,
>>> Tommy
>>> 
>>> PS:  Richard, you should validate and sanitize all inputs.  Your query is
>>> prone to injection attack (deletion of rows or your entire DB deleted).  Use
>>> either mysql_escape_string or, better yet, mysqli to prepare the statement
>>> and bind the parameters.
>>> 
>> 
> 
> Sounds like you're hitting the page twice. Check for missing image,
> css files, favicons, js files etc.
> 
> -- 
> <hype>
> WWW: plphp.dk / plind.dk
> LinkedIn: plind
> BeWelcome/Couchsurfing: Fake51
> Twitter: kafe15
> </hype>


--- End Message ---
--- Begin Message ---
And what difference will that make if the document is requested twice with
every browser load?
On Nov 27, 2010 6:39 AM, "Richard West" <p...@cbnisp.com> wrote:
> I took that into consideration so I added the update at the very end of
document...
> Still the same,
> RD
>
>
>
>
> On Nov 27, 2010, at 12:31 AM, Peter Lind wrote:
>
>> On Saturday, November 27, 2010, Richard West <p...@cbnisp.com> wrote:
>>> Hey Tommy,
>>>
>>> I get the same when seting it to a_downloads=a_downloads+1
>>> It still increments by 2
>>> I've never run into this before.
>>> RD
>>>
>>>
>>> On Nov 26, 2010, at 11:45 PM, Tommy Pham wrote:
>>>
>>>>> -----Original Message-----
>>>>> From: Tamara Temple [mailto:tamouse.li...@gmail.com]
>>>>> Sent: Friday, November 26, 2010 7:54 PM
>>>>> To: Richard West
>>>>> Cc: PHP General Mailing List
>>>>> Subject: Re: [PHP] PHP Add +1 mysql updates by 2?
>>>>>
>>>>>
>>>>> On Nov 26, 2010, at 8:36 PM, Richard West wrote:
>>>>>
>>>>>> Hey guys,
>>>>>> I've never run into this before.
>>>>>> I have a field in mysql for page views.
>>>>>> So I pull out value and do +1 to new value - after UPDATE SET it has
>>>>>> incremented by 2?
>>>>>>
>>>>>> $val = $row['a_downloads'] ;
>>>>>>
>>>>>> $new_val = $val+1;
>>>>>>
>>>>>> mysql_query("UPDATE cbn_articles SET a_downloads='$new_val' WHERE
>>>>> a_id
>>>>>> = '".$_GET['id']."' ");
>>>>>>
>>>>>> Any ideas? What am I missing?
>>>>>> RD
>>>>>
>>>>> a_downloads wouldn't happen to be an autoincrement value, would it?
>>>>>
>>>>
>>>> IIRC, the auto_increment should only increment on an INSERT statement
and
>>>> the field is omitted. Besides, in MySQL, auto_increment must also be
part
>>>> of the primary key. From Richard's query, I'd say that his primary key
>>>> field is most likely a_id. IMO, the best way to count something is to
set
>>>> the field to an int(eger) type. Then just run 'UPDATE table_name SET
>>>> count_field = count_field +1 WHERE criteria_column = $criteria'. This
is
>>>> more safe as you many have simultaneous users downloading. This would
>>>> ensure an accurate count, whereas your logic wouldn't.
>>>>
>>>> Regards,
>>>> Tommy
>>>>
>>>> PS: Richard, you should validate and sanitize all inputs. Your query is
>>>> prone to injection attack (deletion of rows or your entire DB deleted).
Use
>>>> either mysql_escape_string or, better yet, mysqli to prepare the
statement
>>>> and bind the parameters.
>>>>
>>>
>>
>> Sounds like you're hitting the page twice. Check for missing image,
>> css files, favicons, js files etc.
>>
>> --
>> <hype>
>> WWW: plphp.dk / plind.dk
>> LinkedIn: plind
>> BeWelcome/Couchsurfing: Fake51
>> Twitter: kafe15
>> </hype>
>

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Richard West [mailto:p...@cbnisp.com]
> Sent: Friday, November 26, 2010 9:40 PM
> To: Peter Lind
> Cc: Tommy Pham; Tamara Temple; PHP General Mailing List
> Subject: Re: [PHP] PHP Add +1 mysql updates by 2?
> 
> I took that into consideration so I added the update at the very end of
> document...
> Still the same,
> RD
> 
<snip>

Things to consider as part of your application design/flow:

1) Are you doing all PHP processing (application initialization, DB
retrieval, user preference settings, etc.) before any header, echo, print,
printf, output buffer, etc... ?  At which point is the update done?
2) Are you sure the DB update is only called for or included/required once
for that particular URL request?
3) Do you any have other page (js - or in page ajax calls, css, php, html,
etc) that requests the page (with the update) again, as Peter mentioned?

It will help you if you do an UML or a flow chart of the application flow.

Regards,
Tommy


--- End Message ---
--- Begin Message ---
On Fri, 2010-11-26 at 22:29 -0800, Tommy Pham wrote:

> > -----Original Message-----
> > From: Richard West [mailto:p...@cbnisp.com]
> > Sent: Friday, November 26, 2010 9:40 PM
> > To: Peter Lind
> > Cc: Tommy Pham; Tamara Temple; PHP General Mailing List
> > Subject: Re: [PHP] PHP Add +1 mysql updates by 2?
> > 
> > I took that into consideration so I added the update at the very end of
> > document...
> > Still the same,
> > RD
> > 
> <snip>
> 
> Things to consider as part of your application design/flow:
> 
> 1) Are you doing all PHP processing (application initialization, DB
> retrieval, user preference settings, etc.) before any header, echo, print,
> printf, output buffer, etc... ?  At which point is the update done?
> 2) Are you sure the DB update is only called for or included/required once
> for that particular URL request?
> 3) Do you any have other page (js - or in page ajax calls, css, php, html,
> etc) that requests the page (with the update) again, as Peter mentioned?
> 
> It will help you if you do an UML or a flow chart of the application flow.
> 
> Regards,
> Tommy
> 
> 


Because you're running the query as a response to a GET call, the
browser is allowed to call it multiple times and grab select parts of
the output to speed up rendering of the page. I've run into this before,
and it's annoying.

There are basically two ways to prevent this. Have the page called as
part of a POST request, which is preferred as GET requests should never
change data, hence why browsers are allowed to request them in a
slightly different way to speed up the page display times.

The second way is to also update a timestamp in the DB, and then before
you update check to see if it has been updated within a certain time
period. Depending on what you're updating this for (stat counter, etc)
then this may not work.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
First let me say thanks to everyone who replied!

Ashley, I got it fixed but I have not a clue what did it :)
RD


On Nov 27, 2010, at 6:49 AM, Ashley Sheridan wrote:

> On Fri, 2010-11-26 at 22:29 -0800, Tommy Pham wrote:
>> 
>> > -----Original Message-----
>> > From: Richard West [mailto:p...@cbnisp.com]
>> > Sent: Friday, November 26, 2010 9:40 PM
>> > To: Peter Lind
>> > Cc: Tommy Pham; Tamara Temple; PHP General Mailing List
>> > Subject: Re: [PHP] PHP Add +1 mysql updates by 2?
>> > 
>> > I took that into consideration so I added the update at the very end of
>> > document...
>> > Still the same,
>> > RD
>> > 
>> <snip>
>> 
>> Things to consider as part of your application design/flow:
>> 
>> 1) Are you doing all PHP processing (application initialization, DB
>> retrieval, user preference settings, etc.) before any header, echo, print,
>> printf, output buffer, etc... ?  At which point is the update done?
>> 2) Are you sure the DB update is only called for or included/required once
>> for that particular URL request?
>> 3) Do you any have other page (js - or in page ajax calls, css, php, html,
>> etc) that requests the page (with the update) again, as Peter mentioned?
>> 
>> It will help you if you do an UML or a flow chart of the application flow.
>> 
>> Regards,
>> Tommy
>> 
>> 
> 
> Because you're running the query as a response to a GET call, the browser is 
> allowed to call it multiple times and grab select parts of the output to 
> speed up rendering of the page. I've run into this before, and it's annoying.
> 
> There are basically two ways to prevent this. Have the page called as part of 
> a POST request, which is preferred as GET requests should never change data, 
> hence why browsers are allowed to request them in a slightly different way to 
> speed up the page display times.
> 
> The second way is to also update a timestamp in the DB, and then before you 
> update check to see if it has been updated within a certain time period. 
> Depending on what you're updating this for (stat counter, etc) then this may 
> not work.
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 
> 


--- End Message ---
--- Begin Message ---
PS: PEBKAC I figure :)



On Nov 27, 2010, at 6:49 AM, Ashley Sheridan wrote:

> On Fri, 2010-11-26 at 22:29 -0800, Tommy Pham wrote:
> 
>>> -----Original Message-----
>>> From: Richard West [mailto:p...@cbnisp.com]
>>> Sent: Friday, November 26, 2010 9:40 PM
>>> To: Peter Lind
>>> Cc: Tommy Pham; Tamara Temple; PHP General Mailing List
>>> Subject: Re: [PHP] PHP Add +1 mysql updates by 2?
>>> 
>>> I took that into consideration so I added the update at the very end of
>>> document...
>>> Still the same,
>>> RD
>>> 
>> <snip>
>> 
>> Things to consider as part of your application design/flow:
>> 
>> 1) Are you doing all PHP processing (application initialization, DB
>> retrieval, user preference settings, etc.) before any header, echo, print,
>> printf, output buffer, etc... ?  At which point is the update done?
>> 2) Are you sure the DB update is only called for or included/required once
>> for that particular URL request?
>> 3) Do you any have other page (js - or in page ajax calls, css, php, html,
>> etc) that requests the page (with the update) again, as Peter mentioned?
>> 
>> It will help you if you do an UML or a flow chart of the application flow.
>> 
>> Regards,
>> Tommy
>> 
>> 
> 
> 
> Because you're running the query as a response to a GET call, the
> browser is allowed to call it multiple times and grab select parts of
> the output to speed up rendering of the page. I've run into this before,
> and it's annoying.
> 
> There are basically two ways to prevent this. Have the page called as
> part of a POST request, which is preferred as GET requests should never
> change data, hence why browsers are allowed to request them in a
> slightly different way to speed up the page display times.
> 
> The second way is to also update a timestamp in the DB, and then before
> you update check to see if it has been updated within a certain time
> period. Depending on what you're updating this for (stat counter, etc)
> then this may not work.
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 
> 


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

I am playing around with PHP and BBCodes and have found some regex's 
that should transform my BBCode into correct HTML when rendering. 
However, I have found that if the BBCode is not correct (eg missing 
closing tag), the regex completely eats my input and my page is empty!

The regex I'm using is:
/\[i\]((\s|.)+?)\[\/i\]/

And with an input like:
This is [i]italic.

I get nothing back.

What I would like is that when no closing tag is found, the opening tag 
should just be shown as-is. Anybody have any idea how I can do this?

Thanks!

-- 
Roland Asmann
Senior Software Engineer

adesso Austria GmbH
Floridotower 26. Stock              T +43 1 2198790-27
Floridsdorfer Hauptstr. 1           F +43 1 2198790-927
A-1210 Wien                         M +43 664 88657566
                                    E roland.asm...@adesso.at
                                    W www.adesso.at

-------------------------------------------------------------
             >>> business. people. technology. <<<
-------------------------------------------------------------

--- End Message ---

Reply via email to