Jump to content

mysql Bit and php


adam291086

Recommended Posts

As long as your mysql table is setup that way:

 

$result = mysql_query("SELECT `colname` FROM `tablename` WHERE `somecol` = 'someval' LIMIT 1");
$val = mysql_result($result, 0);
echo "Value returned $val";

 

If you plan on returning more than one row, look into mysql_fetch_assoc or mysql_fetch_row. They have examples.

Link to comment
https://forums.phpfreaks.com/topic/148842-mysql-bit-and-php/#findComment-781649
Share on other sites

problem is i am using ez_sql.php class and when i look at the array the female section doesnt contain anything even though it is set to be 1 in the database. What should the bit(1) = if the answer is yes i am female

Array

(

    [idUser] => 1

    [username] => Adam

    [password] => plowman

    [title] => Mr

    [forename1] => Adam

    [forename2] =>

    [surname] => Plowman

    [addressLine1] =>

    [addressLine2] =>

    [town] =>

    [postcode] =>

    [secondEmail] =>

    [personalUrl] =>

    [photo] =>

    [female] =>

    [postcodeStart] =>

    [authorityToWorkStatement] =>

    [contactPreference] =>

    [EducationLevels_idEducationLevel] =>

    [noOfGcses] => 0

    [gcseEnglishGrade] =>

    [gcseMathsGrade] =>

    [fiveOrMoreGcses] =>

    [noOfAlevels] => 0

    [ucasPoints] => 0

    [studentStatus] =>

    [mobile] =>

    [landline] =>

    [dob] =>

    [penaltyPoints] =>

)

 

Link to comment
https://forums.phpfreaks.com/topic/148842-mysql-bit-and-php/#findComment-781884
Share on other sites

If you have the field as being "female" why not see if it is null, if it is null then they are male, if it has a value (not null) they are male....?

 

As far as the answer what to check against...I have no clue. I have never used bit, instead I would do a TINYINT(1) that way it can be a 1 or a 0 and boom, problem is solved.

 

I believe bit is binary, and I have never really worked closely with binary information.

Link to comment
https://forums.phpfreaks.com/topic/148842-mysql-bit-and-php/#findComment-782176
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.