A section of the documentation for the isSet() function states:
Also note that a NULL byte ("\0") is not equivalent to the PHP NULL
constant.
Where would you encounter a NULL byte? Is a null byte what is returned
from a field in a database?
Josh 9 12054
Joshua Ruppert: A section of the documentation for the isSet() function states:
Also note that a NULL byte ("\0") is not equivalent to the PHP NULL constant.
Where would you encounter a NULL byte? Is a null byte what is returned from a field in a database?
It's typically used in C to mark the end of a string. As you might know the
programmer is responsible for managing memory in C. This means that if you
want to store a string coming from the user using C, you will have to set
aside some buffer space, say 4096B. If the user sends a string of only 67B
the \0 byte is used in this buffer to mark the end of the string.
Luckily it's not anything you really have to worry about in PHP.
André Næss
> It's typically used in C to mark the end of a string. As you might know the programmer is responsible for managing memory in C. This means that if you want to store a string coming from the user using C, you will have to set aside some buffer space, say 4096B. If the user sends a string of only 67B the \0 byte is used in this buffer to mark the end of the string.
Luckily it's not anything you really have to worry about in PHP.
right - in php, the NULL Character is a Character like every other (besindes some functions don't work right with it)
But nothing should give you such a Character (besindes the evil evil user)
--
mfg Christian (Chronial "at" web.de)
--
Composed with Newz Crawler 1.5 http://www.newzcrawler.com/
On Tue, 16 Dec 2003 12:03:31 +0100, "Christian Fersch"
<Fr********@web.de> wrote: It's typically used in C to mark the end of a string. As you might know the programmer is responsible for managing memory in C. This means that if you want to store a string coming from the user using C, you will have to set aside some buffer space, say 4096B. If the user sends a string of only 67B the \0 byte is used in this buffer to mark the end of the string.
Luckily it's not anything you really have to worry about in PHP.
right - in php, the NULL Character is a Character like every other (besindes some functions don't work right with it)
But nothing should give you such a Character (besindes the evil evil user)
If you were to retrieve a BLOB field from a database, it could contain
"null" (\0) characters.
In database terms, "NULL" means "no data". The "null character" *is*
data - a byte with a value of zero.
--
David ( @priz.co.uk )
The Internet Prisoner Database: http://www.priz.co.uk/ipdb/
The Tarbrax Chronicle: http://www.tarbraxchronicle.com/
On Tue, 16 Dec 2003 11:18:55 +0000, David Mackenzie hath writ: ....... The "null character" *is* data - a byte with a value of zero.
More properly: "...a byte with a value of" *nothing* .
Not zero , not alpha , not numeric , not feet , not inches...
At best it is a placeholder -- where _something_ could be -- but,
at the present time, there is *nothing* there.
As a thing meaning *nothing*, in C-like constructs it is usually
used the show the end of *something* .
Jonesy
--
| Marvin L Jones | jonz | W3DHJ | OS/2
| Gunnison, Colorado | @ | Jonesy | linux __
| 7,703' -- 2,345m | config.com | DM68mn SK
On 16 Dec 2003 16:12:12 GMT, Allodoxaphobia <bi********@config.com> wrote: On Tue, 16 Dec 2003 11:18:55 +0000, David Mackenzie hath writ:
....... The "null character" *is* data - a byte with a value of zero. More properly: "...a byte with a value of" *nothing* . Not zero , not alpha , not numeric , not feet , not inches... At best it is a placeholder -- where _something_ could be -- but, at the present time, there is *nothing* there.
Well, a NUL character is CHR(0) and is a one-byte zero, it is very much
something. You seem to be almost describing an SQL database NULL, which
represents 'unknown'.
As a thing meaning *nothing*, in C-like constructs it is usually used the show the end of *something* .
Character strings are terminated in C by a NUL (chr(0)) character. It is
definitely 'something' itself, since you have to allocate space for it. PHP's a
higher-level language so you don't have to worry about NUL terminators. And you
can have NUL bytes in PHP 'string' variables, as they're actually
'binary-safe'.
<pre>
<?php
$x = chr(0).chr(0).chr(0).chr(0).'x';
var_dump($x);
?>
</pre>
string(5) "x"
(Note the length!)
--
Andy Hassall (an**@andyh.co.uk) icq(5747695) ( http://www.andyh.co.uk)
Space: disk usage analysis tool ( http://www.andyhsoftware.co.uk/space)
So would a null byte be basically an empty string as opposed to an
unknown value?
Josh
Andy Hassall wrote: On 16 Dec 2003 16:12:12 GMT, Allodoxaphobia <bi********@config.com> wrote:
On Tue, 16 Dec 2003 11:18:55 +0000, David Mackenzie hath writ:
....... The "null character" *is* data - a byte with a value of zero.
More properly: "...a byte with a value of" *nothing* . Not zero , not alpha , not numeric , not feet , not inches... At best it is a placeholder -- where _something_ could be -- but, at the present time, there is *nothing* there.
Well, a NUL character is CHR(0) and is a one-byte zero, it is very much something. You seem to be almost describing an SQL database NULL, which represents 'unknown'.
As a thing meaning *nothing*, in C-like constructs it is usually used the show the end of *something* .
Character strings are terminated in C by a NUL (chr(0)) character. It is definitely 'something' itself, since you have to allocate space for it. PHP's a higher-level language so you don't have to worry about NUL terminators. And you can have NUL bytes in PHP 'string' variables, as they're actually 'binary-safe'.
<pre> <?php $x = chr(0).chr(0).chr(0).chr(0).'x'; var_dump($x); ?> </pre>
string(5) "x"
(Note the length!)
On Tue, 16 Dec 2003 23:04:36 GMT, Joshua Ruppert
<no************@rochester.rr.com> wrote: So would a null byte be basically an empty string as opposed to an unknown value?
In which language?
C: Yes, a single NUL character is the representation of a zero-length string.
PHP: No, it'd be a 1-character string consisting of a chr(0).
--
Andy Hassall (an**@andyh.co.uk) icq(5747695) ( http://www.andyh.co.uk)
Space: disk usage analysis tool ( http://www.andyhsoftware.co.uk/space)
Another Newbie here...
doing a small order tracking app to learn PHP, MySQL, etc...
With regard to null values, I have a customer entry form in html.Some
fields are optional. I send data to MySQL via a POST method. When I
try to query the database later (via a form as well) and use "IS
NULL", for example:
select c.lname, c.fname
from Customer c
where c.company_name is null
....I get no results. I have to query the db with something like
select c.lname, c.fname
from Customer c
where (c.company_name='')
What am I doing wrong? There do not seem to be any null values in my
db, only empty values ('').
I suspect it has to do with the addslashes() function applied to the
post variables on the customer insert page. Must I NOT addslashes() if
the POST field has been skipped by the user?
Thanks!
On Tue, 16 Dec 2003 23:25:55 +0000, Andy Hassall <an**@andyh.co.uk>
wrote: On Tue, 16 Dec 2003 23:04:36 GMT, Joshua Ruppert <no************@rochester.rr.com> wrote:
So would a null byte be basically an empty string as opposed to an unknown value?
In which language?
C: Yes, a single NUL character is the representation of a zero-length string. PHP: No, it'd be a 1-character string consisting of a chr(0).
Adam M. Johnson <ad***@althealth.org> wrote: With regard to null values, I have a customer entry form in html.Some fields are optional. I send data to MySQL via a POST method. When I try to query the database later (via a form as well) and use "IS NULL", for example:
select c.lname, c.fname from Customer c where c.company_name is null
...I get no results. I have to query the db with something like
select c.lname, c.fname from Customer c where (c.company_name='')
What am I doing wrong? There do not seem to be any null values in my db, only empty values ('').
I suspect it has to do with the addslashes() function applied to the post variables on the customer insert page. Must I NOT addslashes() if the POST field has been skipped by the user?
perhaps you can test your POST variables before inserting them in the
database, i.e.
if (empty($_POST['myvar'])) {
$myvar = 'NULL';
}
else {
// note the surrounding quotes
$myvar = "'".mysql_escape_string(stripslashes($_POST['myvar']))."'";
}
mysql_query("UPDATE table SET field=".$myvar);
(or INSERT, whatever you are using...)
if they are empty, NULL will be inserted in the database; if not,
stripslashes strips \ from the variable the form transmits, and
mysql_escape_string escapes special characters when passing the sql query
statement. This discussion thread is closed Replies have been disabled for this discussion. Similar topics
4 posts
views
Thread by Spark |
last post: by
|
19 posts
views
Thread by John Pifer |
last post: by
|
1 post
views
Thread by Diego Buendia |
last post: by
|
2 posts
views
Thread by Karsten Hilbert |
last post: by
|
1 post
views
Thread by Natalia DeBow |
last post: by
|
7 posts
views
Thread by JJ |
last post: by
|
reply
views
Thread by =?Utf-8?B?Uml6d2Fu?= |
last post: by
|
5 posts
views
Thread by Michael_Burgess |
last post: by
|
6 posts
views
Thread by BD |
last post: by
|
22 posts
views
Thread by Bill Reid |
last post: by
| | | | | | | | | | |