limitphp Posted December 11, 2008 Share Posted December 11, 2008 If I'm trying to insert an integer (lets say a 0) for one of the values into a table, do I put quotes around the 0? like this: mysql_query("INSERT INTO user (username, verify) VALUES ('$username', '0') or die (mysql_error()); assuming verify is a type INT(1) Link to comment https://forums.phpfreaks.com/topic/136554-solved-insert-integer/ Share on other sites More sharing options...
Mchl Posted December 11, 2008 Share Posted December 11, 2008 If you put the quotes around it, the query will be a bit slower. Will not matter a lot with small query like that. BTW: INT(1) still takes 4 bytes. For small numbers use TINYINT. Link to comment https://forums.phpfreaks.com/topic/136554-solved-insert-integer/#findComment-712826 Share on other sites More sharing options...
limitphp Posted December 11, 2008 Author Share Posted December 11, 2008 If you put the quotes around it, the query will be a bit slower. Will not matter a lot with small query like that. BTW: INT(1) still takes 4 bytes. For small numbers use TINYINT. Thanks, I'll go back and change my flag columns to tinyints. The value of verify will only be 1 or 0. So, that is technically 1 byte, right? It slows down if you put quotes around INTs or quotes around any values, like the variable names? Link to comment https://forums.phpfreaks.com/topic/136554-solved-insert-integer/#findComment-712858 Share on other sites More sharing options...
Mchl Posted December 11, 2008 Share Posted December 11, 2008 Thanks, I'll go back and change my flag columns to tinyints. The value of verify will only be 1 or 0. So, that is technically 1 byte, right? It slows down if you put quotes around INTs or quotes around any values, like the variable names? Technically it would be one bit, but you can't get that low The least you can get is 8 bits a.k.a. one byte. It slows down, when it gets a string (a value in quotes, nevermind if put directly or from variable) and has to change it to integer. Link to comment https://forums.phpfreaks.com/topic/136554-solved-insert-integer/#findComment-712867 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.