RE: [PHP-WIN] Required to Trim Variables with MSSQL Module
| From: | Flint Doungchak | Date: | Thu, 03 May 2001 15:53:30 +0000 |
| Subject: | RE: [PHP-WIN] Required to Trim Variables with MSSQL Module | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-7263@lists.php.net to get a copy of this message | ||
Frank,
Let's try that again... Don't know what happened...
$row = mssql_fetch_row($result);
$questionid=$row[0];
echo "$questionid<br>";
$length = strlen($questionid);
echo "length: $length";
$row[0] is defined as an interger.
- With compatibility mode on and off the length of the string is 20.
- If I add trim($row[0]) I get the length of 4 (which is what i want).
Any thoughts?
-Flint
-----Original Message-----
From: Frank M. Kromann [mailto:frank@frontbase.com]
Sent: Wednesday, May 02, 2001 9:56 PM
To: Flint Doungchak
Cc: php-windows@lists.php.net
Subject: Re: [PHP-WIN] Required to Trim Variables with MSSQL Module
Hi Flint,
Unless we have a bug in the MSSQL extension it is supposed to function in
one of two ways depending on the setting of mssql.compatability_mode in
php.ini:
mssql.compatability_mode = off
Columns are returned according to the type defined in the database. integers
of anty size becomes a LONG, char, varchar and text becomes a STRING etc.
mssql.compatability_mode = on
All column are returned as strings no matter how they are defined in the
database.
No matter what mode you are using trailing spaces will be removed from any
STRING values. Leading spaces will not be removed !
- Frank
> Hi all,
>
> I've got a rather iritating problem. I recently moved a site from PHP
3.0.11
> to 4.0.5 RC1. It seems, and I have noticed this for a while in other
> scripts, that variables returned from MSSQL sometimes need to be trimmed
> with trim() in order to function correctly.
>
> Sometimes they won't evaluate as integers (i.e. they don't add right),
other
> times they don't evaluate right as strings (i.e. with if (!$row[crap]),
and
> other times if I have a header redirect (i.e. Header("Location:
> ./index.php?crap=$row[crap]") ) I get the infamous CGI header problem.
>
> I generally retrieve with $row = mssql_fetch_array($result);
>
> In all cases adding trim will fix the problem. Anyone had similar
problems.
> Am I missing something. This seems to be odd behavior. I really don't want
> to go through all my scripts and trip stuff.
>
> Thanks,
>
> -Flint
>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net
> For additional commands, e-mail: php-windows-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>
>