pmzq Posted April 25, 2006 Share Posted April 25, 2006 Hy all,I've got a code like this: $q ="UPDATE planet SET has_politics=$myrow[has_politics] & 0xfe ". "WHERE id='$Planetid'"; $result = mysql_query ($q, $db);IT tells the "has_politics" to become 0xfe but what does this mean is it some sort of haxdecimal code for a certain number ?In a earlier part of the code the "has_politics" is set like the following: $q = "UPDATE planet set has_politics = has_politics | 1 ". "WHERE x='$myrow[x]' AND y='$myrow[y]' AND id!='$Planetid'"; $result = mysql_query ($q, $db);So I think the code above sets the "has_politics" to 1 and 0xfe code sets it to 0 again or something ?Can anyone tell em what that part of code does? thnx again pMzQ, Quote Link to comment https://forums.phpfreaks.com/topic/8344-solvedwhat-are-these-wierd-numbers-and-what-do-they-mean/ Share on other sites More sharing options...
wisewood Posted April 25, 2006 Share Posted April 25, 2006 0xFE is a hexidecimal numeric character code... I thinkSome info on this can be found [a href=\"http://www.delorie.com/gnu/docs/fontutils/fontu_16.html\" target=\"_blank\"]>> HERE <<[/a] and [a href=\"http://www.w3.org/International/questions/qa-escapes\" target=\"_blank\"]>> HERE <<[/a] Quote Link to comment https://forums.phpfreaks.com/topic/8344-solvedwhat-are-these-wierd-numbers-and-what-do-they-mean/#findComment-30439 Share on other sites More sharing options...
zq29 Posted April 25, 2006 Share Posted April 25, 2006 0xFE is hexadecimal for decimal 255 I think. Quote Link to comment https://forums.phpfreaks.com/topic/8344-solvedwhat-are-these-wierd-numbers-and-what-do-they-mean/#findComment-30440 Share on other sites More sharing options...
pmzq Posted April 25, 2006 Author Share Posted April 25, 2006 thnx for these answers so far :)But do you know if I can just replace them with normal numbers isntead of those heximal just put the real number in there so i don't have to look up all the time what it is meaning.. ? Quote Link to comment https://forums.phpfreaks.com/topic/8344-solvedwhat-are-these-wierd-numbers-and-what-do-they-mean/#findComment-30445 Share on other sites More sharing options...
wisewood Posted April 25, 2006 Share Posted April 25, 2006 yeah, just swap it. although you should check to make sure your table contains the right character and not that code... otherwise switching to use a number instead could mess with your query results. Quote Link to comment https://forums.phpfreaks.com/topic/8344-solvedwhat-are-these-wierd-numbers-and-what-do-they-mean/#findComment-30446 Share on other sites More sharing options...
pmzq Posted April 25, 2006 Author Share Posted April 25, 2006 Ok I understand but still I don't know what to replace 0xfe with how do i calculate the decimal for this hexadecimal number ? I can calculate the binary of this which is i think 1111 1110 meaning f and e.But how do i translate this to a real number ?ok i think 0xfe means decimal 254.But then I'm still confused because when I look in my mysql database when this code is run:$q = "UPDATE planet set has_politics = has_politics | 1 "."WHERE x='$myrow[x]' AND y='$myrow[y]' AND id!='$Planetid'";$result = mysql_query ($q, $db);The "has_politics" row shows that it's value = 1 sofar i understand but then after this code is run:$q ="UPDATE planet SET has_politics=$myrow[has_politics] & 0xfe ". "WHERE id='$Planetid'";$result = mysql_query ($q, $db); $myrow["has_politics"] = $myrow["has_politics"] & 0xfe;then the value of "has_politics" is set back to 0 so 0xfe is meaning something like -1 because the value was 1 and after the code is run it is 0. But i just calculated that fe means 254 :| ??????? Quote Link to comment https://forums.phpfreaks.com/topic/8344-solvedwhat-are-these-wierd-numbers-and-what-do-they-mean/#findComment-30450 Share on other sites More sharing options...
wisewood Posted April 25, 2006 Share Posted April 25, 2006 the mysql UPDATE doesnt perform a mathematical calculation, it just changes the value of the field to whatever you specify.If it is resetting the field to 0 when you run the 0xFE code on it, then 0xFE in terms of your script is equal to 0.Ignore the hex code translation of it... 254 is what FE is in hex. This means that if you were to convert the hex color code #FEFEFE from hex to RGB value, it would translate to R:254 G:254 B:254.In otherwords... it would be a very pale grey... almost white.But ignore that... in your case its setting the table entry to 0, so 0xFE=0. Quote Link to comment https://forums.phpfreaks.com/topic/8344-solvedwhat-are-these-wierd-numbers-and-what-do-they-mean/#findComment-30462 Share on other sites More sharing options...
pmzq Posted April 25, 2006 Author Share Posted April 25, 2006 Ok I think I'm getting there,I think because "has_politics" is set to 1 in this code :$q = "UPDATE planet set has_politics = has_politics | 1 "."WHERE x='$myrow[x]' AND y='$myrow[y]' AND id!='$Planetid'";$result = mysql_query ($q, $db);Then the following code stes "has_politics" again :$q ="UPDATE planet SET has_politics=$myrow[has_politics] & 0xfe ". "WHERE id='$Planetid'";$result = mysql_query ($q, $db);$myrow["has_politics"] = $myrow["has_politics"] & 0xfe;0xfe means 254 and I think it adds this to 1 making 255 and then i think 255 is full or something meaning 0 ?Am i right about this ?ok so 0xfe is 0 you sayi;ll try some stuff with the code to figure thigns out :)thnx! Quote Link to comment https://forums.phpfreaks.com/topic/8344-solvedwhat-are-these-wierd-numbers-and-what-do-they-mean/#findComment-30463 Share on other sites More sharing options...
wisewood Posted April 25, 2006 Share Posted April 25, 2006 No. lol, in a word."UPDATE my_table SET my_field1=1"This will set the field in the table to 1."UPDATE my_table SET my_field1=1000"This will now mean that my_field1 is 1000. It will not equal 1001, or 999. It doesnt perform any mathos on what you give it, it just UPDATEs the content of the field you specified with the value you gave it. No addition, no subtraction, it just overwrites what was there with the new data you're giving it. Quote Link to comment https://forums.phpfreaks.com/topic/8344-solvedwhat-are-these-wierd-numbers-and-what-do-they-mean/#findComment-30466 Share on other sites More sharing options...
pmzq Posted April 25, 2006 Author Share Posted April 25, 2006 Ok thnx i'm getting it :)I think i get it now it just putts in a zero i'll try to code things with my code and try if it works!thnx again!! :)pMzQ, Quote Link to comment https://forums.phpfreaks.com/topic/8344-solvedwhat-are-these-wierd-numbers-and-what-do-they-mean/#findComment-30467 Share on other sites More sharing options...
Barand Posted April 25, 2006 Share Posted April 25, 2006 The bitwise operators | and & allow you to manipulate specific bits in a field, so you you can use a single byte column to hold 8 separate settings ( where 0 means NO and 1 means YES)[code]x | 1 (0000 0001)[/code]will set 'bit 0' to 1 and leave the other bits unchanged[code]x & 0xFE (1111 1110)[/code]will set 'bit 0' to 0 and leave the other bits unchangedSimilarly,[code]x | 4 (0000 0100)[/code]will set 'bit 3' to 1 and leave the other bits unchanged[code]x & 0xFB (1111 1011)[/code]will set 'bit 3' to 0 and leave the other bits unchangedHope that helps Quote Link to comment https://forums.phpfreaks.com/topic/8344-solvedwhat-are-these-wierd-numbers-and-what-do-they-mean/#findComment-30484 Share on other sites More sharing options...
pmzq Posted April 25, 2006 Author Share Posted April 25, 2006 that was the explanation I was looking for THNX :DThat is exactly what it does :D now I can continue :) Quote Link to comment https://forums.phpfreaks.com/topic/8344-solvedwhat-are-these-wierd-numbers-and-what-do-they-mean/#findComment-30516 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.