473,385 Members | 2,069 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,385 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 23656

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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
jinu1996
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 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.