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 12189
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 thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Spark |
last post by:
Hi,
Situation:
Need a query to return number of ticket records by month of open in a
log table where the ticket open record is older than 24 hours then the
ticket pending or ticket closed...
|
by: John Pifer |
last post by:
I am not good at SQL - hence here goes
Consider this scenario of 2 tables X and Y with a many to many
relationship
Table X (name,weightage)
X1 2
X2 1
X3 5
X4 1
|
by: Diego Buendia |
last post by:
I'm facing the next problem:
I have a table with two columns (among others) modeling category and
subcategory data for each row. I need to summarize info on this two
columns, but with the next...
|
by: Karsten Hilbert |
last post by:
Dear all,
for some reason I just cannot get my brain wrapped around the
required syntax for the following. I think I need to either
use a join or subselect(s):
Situation:
----------
I have...
|
by: Natalia DeBow |
last post by:
Hi,
I am working on a Windows-based client-server application. I am involved in
the development of the remote client modules. I am using asynchronous
delegates to obtain information from...
| |
by: JJ |
last post by:
How do I set one field to have the updated timestamp, and another to have
the created timestamp?
I want to do this directly from code generated from DB Designer if
possible?!
JJ
|
by: =?Utf-8?B?Uml6d2Fu?= |
last post by:
I have these tables:
create table cd_language_saaa
(
saaapk int not null PRIMARY KEY,
code varchar(50) not null
)
create table cd_calendar_saaj
(
|
by: Michael_Burgess |
last post by:
Hi there,
I'm fairly new to database design, having only really worked with
existing tables etc in the past.
Simple question this really...........
In a users table, is it wise to have a...
|
by: BD |
last post by:
Hi, all.
I'm trying to understand a certain RI question.
I have 3 tables.
TABLE_A has a PK of A_1.
TABLE_B has a PK of B_1,A_1 (it's a composite key, with the second
field being a FK to...
|
by: Bill Reid |
last post by:
I just noticed that my "improved" version of sscanf() doesn't assign
floating point numbers properly if the variable assigned to is declared
as a "float" rather than a "double". (This never...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |