php-general Digest 6 Jul 2013 06:58:22 -0000 Issue 8286

Topics (messages 321545 through 321558):

Re: strlen ?
        321545 by: John Meyer
        321546 by: shiplu
        321547 by: Jim Giner
        321548 by: Matijn Woudt
        321549 by: Matijn Woudt
        321550 by: Jim Giner
        321551 by: Stephen
        321552 by: Jim Giner
        321554 by: John Meyer
        321557 by: Ashley Sheridan
        321558 by: Lester Caine

Guaranteed Way to Get Error Message Wanted
        321553 by: Brian Smither
        321556 by: Ken Robinson

Find a list of function that clashes?
        321555 by: Daniel

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 ---
Jim Giner wrote:
Trying to manage line breaks in some output I'm generating and using strlen to measure the lengths of the strings I'm printing. Discovered something strange (to me!) in that strlen is returning +1 more than it should.

The strings are from a query of my database - simple name fields. But everyone of them is coming back with a length that is one more than I see.

Ex.

Mike Hall  comes back as 10, not 9
F.B. comes back as 5, not 4.

I've looked at my data and counted the chars - there is no extra space at the beginning or end in my table.

Anyone have an explanation?

Does strlen count the line feed?

--- End Message ---
--- Begin Message ---
On Fri, Jul 5, 2013 at 11:10 PM, Jim Giner <jim.gi...@albanyhandball.com>wrote:

> Mike Hall  comes back as 10, not 9
> F.B. comes back as 5, not 4.
>

Doesn't work for me.

php > var_dump("Mike Hall", strlen("Mike Hall"));
string(9) "Mike Hall"
int(9)

Try trimming it first and then apply strlen.


-- 
Shiplu.Mokadd.im
ImgSign.com | A dynamic signature machine
Innovation distinguishes between follower and leader

--- End Message ---
--- Begin Message ---
On 7/5/2013 1:32 PM, shiplu wrote:
On Fri, Jul 5, 2013 at 11:10 PM, Jim Giner <jim.gi...@albanyhandball.com>wrote:

Mike Hall  comes back as 10, not 9
F.B. comes back as 5, not 4.


Doesn't work for me.

php > var_dump("Mike Hall", strlen("Mike Hall"));
string(9) "Mike Hall"
int(9)

Try trimming it first and then apply strlen.


Why would I need to trim something that I can already see doesn't have any trailing or leading characters?
--- End Message ---
--- Begin Message ---
On Fri, Jul 5, 2013 at 8:33 PM, Jim Giner <jim.gi...@albanyhandball.com>wrote:

> On 7/5/2013 1:32 PM, shiplu wrote:
>
>> On Fri, Jul 5, 2013 at 11:10 PM, Jim Giner <jim.gi...@albanyhandball.com>
>> **wrote:
>>
>>  Mike Hall  comes back as 10, not 9
>>> F.B. comes back as 5, not 4.
>>>
>>>
>> Doesn't work for me.
>>
>> php > var_dump("Mike Hall", strlen("Mike Hall"));
>> string(9) "Mike Hall"
>> int(9)
>>
>> Try trimming it first and then apply strlen.
>>
>>
>>  Why would I need to trim something that I can already see doesn't have
> any trailing or leading characters?
>
>
Because there are characters you can't see?

--- End Message ---
--- Begin Message ---
On Fri, Jul 5, 2013 at 8:39 PM, Jim Giner <jim.gi...@albanyhandball.com>wrote:

>  I checked them in the db manually.  Clicked on the name, selected it, no
> extra space highlighted.  Cursored through the length of the value - no
> extra movements.
>

That does still not guarantee there are no extra characters. Some
characters are just not visible (NUL, CR, LF, ..)


>
> On 7/5/2013 2:36 PM, Matijn Woudt wrote:
>
>
>
>
> On Fri, Jul 5, 2013 at 8:33 PM, Jim Giner <jim.gi...@albanyhandball.com>wrote:
>
>> On 7/5/2013 1:32 PM, shiplu wrote:
>>
>>> On Fri, Jul 5, 2013 at 11:10 PM, Jim Giner <jim.gi...@albanyhandball.com
>>> >wrote:
>>>
>>>  Mike Hall  comes back as 10, not 9
>>>> F.B. comes back as 5, not 4.
>>>>
>>>>
>>> Doesn't work for me.
>>>
>>> php > var_dump("Mike Hall", strlen("Mike Hall"));
>>> string(9) "Mike Hall"
>>> int(9)
>>>
>>> Try trimming it first and then apply strlen.
>>>
>>>
>>>  Why would I need to trim something that I can already see doesn't have
>> any trailing or leading characters?
>>
>>
>  Because there are characters you can't see?
>
>
>

--- End Message ---
--- Begin Message ---
On 7/5/2013 2:42 PM, Matijn Woudt wrote:
On Fri, Jul 5, 2013 at 8:39 PM, Jim Giner <jim.gi...@albanyhandball.com>wrote:

  I checked them in the db manually.  Clicked on the name, selected it, no
extra space highlighted.  Cursored through the length of the value - no
extra movements.


That does still not guarantee there are no extra characters. Some
characters are just not visible (NUL, CR, LF, ..)



On 7/5/2013 2:36 PM, Matijn Woudt wrote:




On Fri, Jul 5, 2013 at 8:33 PM, Jim Giner <jim.gi...@albanyhandball.com>wrote:

On 7/5/2013 1:32 PM, shiplu wrote:

On Fri, Jul 5, 2013 at 11:10 PM, Jim Giner <jim.gi...@albanyhandball.com
wrote:

  Mike Hall  comes back as 10, not 9
F.B. comes back as 5, not 4.


Doesn't work for me.

php > var_dump("Mike Hall", strlen("Mike Hall"));
string(9) "Mike Hall"
int(9)

Try trimming it first and then apply strlen.


  Why would I need to trim something that I can already see doesn't have
any trailing or leading characters?


  Because there are characters you can't see?




And the answer is - yes, there is a LF char at the end of my data in my whole table.

Now the question is - how the heck did I put that in there? Certainly not intentionally. The data is captured from a d/e screen I wrote and it simply grabs the post value and inserts a new record with that value along with some other values. And I don't see anything concatenating a LF to my string.
--- End Message ---
--- Begin Message ---
On 13-07-05 02:50 PM, Jim Giner wrote:

Now the question is - how the heck did I put that in there? Certainly not intentionally. The data is captured from a d/e screen I wrote and it simply grabs the post value and inserts a new record with that value along with some other values. And I don't see anything concatenating a LF to my string.

Is this a browser being used for input? Never assume what a browser will do.

It is good practice to validate and condition data before inserting into a database.

Consider trimming the data before doing the INSERT.

--
Stephen


--- End Message ---
--- Begin Message ---
On 7/5/2013 3:02 PM, Stephen wrote:
On 13-07-05 02:50 PM, Jim Giner wrote:

Now the question is - how the heck did I put that in there? Certainly
not intentionally.  The data is captured from a d/e screen I wrote and
it simply grabs the post value and inserts a new record with that
value along with some other values.  And I don't see anything
concatenating a LF to my string.

Is this a browser being used for input? Never assume what a browser will
do.

It is good practice to validate and condition data before inserting into
a database.

Consider trimming the data before doing the INSERT.

I do validate my data by quoting it but I never expected to have to do a trim to remove a LF. Especially on an iphone for input, since it's not easy to enter a LF.
--- End Message ---
--- Begin Message ---
MOTS:  never take any input on faith.


Jim Giner wrote:
On 7/5/2013 3:02 PM, Stephen wrote:
On 13-07-05 02:50 PM, Jim Giner wrote:

Now the question is - how the heck did I put that in there? Certainly
not intentionally.  The data is captured from a d/e screen I wrote and
it simply grabs the post value and inserts a new record with that
value along with some other values.  And I don't see anything
concatenating a LF to my string.

Is this a browser being used for input? Never assume what a browser will
do.

It is good practice to validate and condition data before inserting into
a database.

Consider trimming the data before doing the INSERT.

I do validate my data by quoting it but I never expected to have to do a trim to remove a LF. Especially on an iphone for input, since it's not easy to enter a LF.



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

Jim Giner <jim.gi...@albanyhandball.com> wrote:

>On 7/5/2013 3:02 PM, Stephen wrote:
>> On 13-07-05 02:50 PM, Jim Giner wrote:
>>>
>>> Now the question is - how the heck did I put that in there?
>Certainly
>>> not intentionally.  The data is captured from a d/e screen I wrote
>and
>>> it simply grabs the post value and inserts a new record with that
>>> value along with some other values.  And I don't see anything
>>> concatenating a LF to my string.
>>>
>> Is this a browser being used for input? Never assume what a browser
>will
>> do.
>>
>> It is good practice to validate and condition data before inserting
>into
>> a database.
>>
>> Consider trimming the data before doing the INSERT.
>>
>I do validate my data by quoting it but I never expected to have to do
>a 
>trim to remove a LF.  Especially on an iphone for input, since it's not
>
>easy to enter a LF.

Quoting the data is not the same thing as validating it.

Thanks,
Ash

--- End Message ---
--- Begin Message ---
Jim Giner wrote:
And the answer is - yes, there is a LF char at the end of my data in my whole
table.

Now the question is - how the heck did I put that in there?  Certainly not
intentionally.  The data is captured from a d/e screen I wrote and it simply
grabs the post value and inserts a new record with that value along with some
other values.  And I don't see anything concatenating a LF to my string.

The obvious question that comes to mind is 'What OS'? Having seen this sort of niggle many times I tend to find it relates to something working 'cross-os' a bit like windows ignoring case in file name and linux then complaining it can't find a file.

It's probably worth checking the sting length back through your code just to confirm what added it?

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

--- End Message ---
--- Begin Message ---
I have an application running under PHP-5.4.17-TS-VC9 (and .14 as of yesterday) 
with Aprelium's Abyss X1 v2.8 web server in FastCGI mode on WinXPSP3.

An earlier version of this application works. The current version causes a 500 
Internal Server Error. There is no entry in PHP's (fully active) error log. I 
cannot decipher Abyss's logging, so I cannot determine if a clue was reported 
by Abyss or not.

The current version works on a different system (Server 2003, PHP 5.3.5-TS-VC6 
(Apache module), Apache 2.2).

What I would like to have is a method of getting PHP to report in some 
undeniable manner, short of total system failure, what it doesn't like about 
whatever killed it.




--- End Message ---
--- Begin Message --- Check the permissions on the files/directories involved. I get this on Linux when the files/directories are too open.

Ken

At 05:38 PM 7/5/2013, Brian Smither wrote:
I have an application running under PHP-5.4.17-TS-VC9 (and .14 as of yesterday) with Aprelium's Abyss X1 v2.8 web server in FastCGI mode on WinXPSP3.

An earlier version of this application works. The current version causes a 500 Internal Server Error. There is no entry in PHP's (fully active) error log. I cannot decipher Abyss's logging, so I cannot determine if a clue was reported by Abyss or not.

The current version works on a different system (Server 2003, PHP 5.3.5-TS-VC6 (Apache module), Apache 2.2).

What I would like to have is a method of getting PHP to report in some undeniable manner, short of total system failure, what it doesn't like about whatever killed it.




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--- End Message ---
--- Begin Message ---
Hello all,

I'm just wondering if there is a way of getting a list of functions
that will clash across 2 folders.

I'm trying to update wp-united so that I can use it with WordPress
multisite. I know that some of the functions are the same in both
phpbb and WordPress. Is there any way of generating a list of all the
functions that are the same across both phpbb and WordPress?

Regards

--- End Message ---

Reply via email to