Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.