473,321 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

PHP, MySQL and BIT field

Please can somebody give me an advice?

my MySQL table contains bit field

Registered BIT(1) NOT NULL DEFAULT 0

I read records using

$result = mysql_query('SELECT * FROM MyUsers');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$registered = $row['Registered'];

Command "echo $registered;" shows nothing or rectangles depending on the
value, it's ok. But I do not know how to use it in IF statements or so.
Whatever I try does not work. How can I work with such values in PHP?

Thank you in advance! Vojta
Sep 18 '06 #1
5 23651

Vojta wrote:
Please can somebody give me an advice?

my MySQL table contains bit field

Registered BIT(1) NOT NULL DEFAULT 0

I read records using

$result = mysql_query('SELECT * FROM MyUsers');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$registered = $row['Registered'];

Command "echo $registered;" shows nothing or rectangles depending on the
value, it's ok. But I do not know how to use it in IF statements or so.
Whatever I try does not work. How can I work with such values in PHP?

Thank you in advance! Vojta
I'm not sure if this works, but have you tryed if
(!is_null($registered)) {} ?

Sep 18 '06 #2
On Mon, 18 Sep 2006 15:42:55 +0200, in comp.lang.php "Vojta"
<ry**@centrum.cz>
<ee***********@ns.felk.cvut.czwrote:
>| Please can somebody give me an advice?
|
| my MySQL table contains bit field
|
| Registered BIT(1) NOT NULL DEFAULT 0
|
| I read records using
|
| $result = mysql_query('SELECT * FROM MyUsers');
| $row = mysql_fetch_array($result, MYSQL_ASSOC);
| $registered = $row['Registered'];
|
| Command "echo $registered;" shows nothing or rectangles depending on the
| value, it's ok. But I do not know how to use it in IF statements or so.
| Whatever I try does not work. How can I work with such values in PHP?
|
| Thank you in advance! Vojta
|
The value is either 0000 or 0001 - not to be confused with ascii(0) or
ascii(1).
---------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
Sep 18 '06 #3
Hello Iulian, thank you for your reply.

!is_null($registered) is allways evaluated as TRUE

Vojta

"iulian.ilea" <iu*********@gmail.compíse v diskusním príspevku
news:11**********************@i3g2000cwc.googlegro ups.com...
>
Vojta wrote:
>Please can somebody give me an advice?

my MySQL table contains bit field

Registered BIT(1) NOT NULL DEFAULT 0

I read records using

$result = mysql_query('SELECT * FROM MyUsers');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$registered = $row['Registered'];

Command "echo $registered;" shows nothing or rectangles depending on the
value, it's ok. But I do not know how to use it in IF statements or so.
Whatever I try does not work. How can I work with such values in PHP?

Thank you in advance! Vojta
I'm not sure if this works, but have you tryed if
(!is_null($registered)) {} ?

Sep 19 '06 #4
Hello Jeff, thank you for reply. I tried following expressions, they are
allways evalueted:

($registered == 1) as false
($registered == '1') as false
($registered == '0001') as false
((boolean)$registered) as true
(!is_null($registered)) as true

(integer)$registered prints allways 0

Please, how exactly should I work with $register variable?

Vojta

"Jeff North" <jn******@yahoo.com.aupíse v diskusním príspevku
news:7h********************************@4ax.com...
On Mon, 18 Sep 2006 15:42:55 +0200, in comp.lang.php "Vojta"
<ry**@centrum.cz>
<ee***********@ns.felk.cvut.czwrote:
>>| Please can somebody give me an advice?
|
| my MySQL table contains bit field
|
| Registered BIT(1) NOT NULL DEFAULT 0
|
| I read records using
|
| $result = mysql_query('SELECT * FROM MyUsers');
| $row = mysql_fetch_array($result, MYSQL_ASSOC);
| $registered = $row['Registered'];
|
| Command "echo $registered;" shows nothing or rectangles depending on the
| value, it's ok. But I do not know how to use it in IF statements or so.
| Whatever I try does not work. How can I work with such values in PHP?
|
| Thank you in advance! Vojta
|

The value is either 0000 or 0001 - not to be confused with ascii(0) or
ascii(1).
---------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------

Sep 19 '06 #5
On Tue, 19 Sep 2006 11:32:08 +0200, in comp.lang.php "Vojta"
<ry**@centrum.cz>
<ee**********@ns.felk.cvut.czwrote:
>| Hello Jeff, thank you for reply. I tried following expressions, they are
| allways evalueted:
|
| ($registered == 1) as false
| ($registered == '1') as false
| ($registered == '0001') as false
Huh??? False = 0 whereas True != 0
>| ((boolean)$registered) as true
| (!is_null($registered)) as true
This would return $registered=0 as true.
>| (integer)$registered prints allways 0
|
| Please, how exactly should I work with $register variable?
|
| Vojta
how about:
if( !is_null($registered) )
{
if( $registered 0 )
//--- do true stuff
else
//--- do false stuff
}
>| "Jeff North" <jn******@yahoo.com.aupíse v diskusním príspevku
| news:7h********************************@4ax.com...
| On Mon, 18 Sep 2006 15:42:55 +0200, in comp.lang.php "Vojta"
| <ry**@centrum.cz>
| <ee***********@ns.felk.cvut.czwrote:
| >
| >>| Please can somebody give me an advice?
| >>|
| >>| my MySQL table contains bit field
| >>|
| >>| Registered BIT(1) NOT NULL DEFAULT 0
| >>|
| >>| I read records using
| >>|
| >>| $result = mysql_query('SELECT * FROM MyUsers');
| >>| $row = mysql_fetch_array($result, MYSQL_ASSOC);
| >>| $registered = $row['Registered'];
| >>|
| >>| Command "echo $registered;" shows nothing or rectangles depending on the
| >>| value, it's ok. But I do not know how to use it in IF statements or so.
| >>| Whatever I try does not work. How can I work with such values in PHP?
| >>|
| >>| Thank you in advance! Vojta
| >>|
| >
| The value is either 0000 or 0001 - not to be confused with ascii(0) or
| ascii(1).
| ---------------------------------------------------------------
| jn******@yourpantsyahoo.com.au : Remove your pants to reply
| ---------------------------------------------------------------
|
---------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
Sep 20 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Yulia Yegenov | last post by:
I have a query that looks like this: (I insert the date created with the php date function) $status = "Active"; //(I cannot use the mysql timestamp function for other reason). $curdate =...
3
by: kingofkolt | last post by:
All, What do you recommend as the best type of field for a timestamp in a MySQL database? I've considered varchar(10) or INT but I'm not sure what is the best, most efficient, and most reliable...
5
by: glakk | last post by:
I have a problem of migrating a database from one host to another. I can't do a dump on the source server. The only access I have is thru queries. So it looks like I'm going to have to query all...
0
by: jnam | last post by:
I am having a problem putting a certain length of text from a textarea form element into a mySQL field. The field is set to LONGTEXT but I get an error. Whne I shorten the text it writes to the DB...
3
by: bobmct | last post by:
In my feeble attempt to keep track of login session timeouts I have the following code in my login section of my program: $sql = "UPDATE subscriber SET _sessexp = 'DATE_ADD(NOW(),INTERVAL 15...
1
by: Roach | last post by:
Hello all ! (my first post) First its safe to assume that I have no idea what I am doing because you would be correct. My problem is, I am working in a simple paypal ipn script and I have...
0
by: markwalsen | last post by:
I've been quite pleased with linking via MySQL Connector / ODBC 3.51 from Access to a remote MySQL database. However, I haven't figured out how to establish the link between a Data Type =...
1
by: aragorn73 | last post by:
I've a database with some fields. I want to add some email addresses that I've into a txt file, separated by comma, into filed "email", appending to existing one. How can I do ?
0
by: ffenton | last post by:
I have a problem with text being inserted into a mysql database containing hidden characters. The text arrives there via multiple stages. Basically it is copied from Ms Word into an Ms Access rich...
2
by: jewellman | last post by:
Hello. I have been reading over some posts that deal with my issue and although I couldn't get my issue to work I did read some very good information. I have created a mySQL table that I will use...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.