Lodius2000 Posted June 13, 2008 Share Posted June 13, 2008 just a theory discussion here, maybe a question on the end if a mysql field is set to INT, call it id, and $id contains the integer 200 if i were to use this sql mysql_query("SELECT field FROM table WHERE id = '$id'"); in the above example because of the single quotes $id is equal to a string with the value of 2next_to0next_to0 or 200, not an integer with a value of 200 above 0, right so my question is, if that is true (if not tell me to shut up...heh) how do I ensure that $id is an integer and not a string, because if you pass a mysql INT field a string it doesnt know how to handle it right, even if the string only contains numbers thanks, happy discussing Link to comment https://forums.phpfreaks.com/topic/109994-solved-mysql-and-strings-vs-integers/ Share on other sites More sharing options...
R0bb0b Posted June 13, 2008 Share Posted June 13, 2008 in the database, the id field is an int. The database knows what to do with it. Link to comment https://forums.phpfreaks.com/topic/109994-solved-mysql-and-strings-vs-integers/#findComment-564426 Share on other sites More sharing options...
R0bb0b Posted June 13, 2008 Share Posted June 13, 2008 Its nice that way so you can put pretty much anything in single quotes, makes it easier for loops and such. Come to think of it I don't think I've had any problem putting anything into single quotes including int, string, dates etc... Link to comment https://forums.phpfreaks.com/topic/109994-solved-mysql-and-strings-vs-integers/#findComment-564428 Share on other sites More sharing options...
bluejay002 Posted June 13, 2008 Share Posted June 13, 2008 Its nice that way so you can put pretty much anything in single quotes, makes it easier for loops and such. Come to think of it I don't think I've had any problem putting anything into single quotes including int, string, dates etc... yeah, that's the beauty of MySQL... MySQL do it for you so you do not need to worry if your int parameter is enclosed with single quote or not. Link to comment https://forums.phpfreaks.com/topic/109994-solved-mysql-and-strings-vs-integers/#findComment-564431 Share on other sites More sharing options...
Lodius2000 Posted June 13, 2008 Author Share Posted June 13, 2008 thanks guys, that clears things up SOLVED Link to comment https://forums.phpfreaks.com/topic/109994-solved-mysql-and-strings-vs-integers/#findComment-564436 Share on other sites More sharing options...
bluejay002 Posted June 13, 2008 Share Posted June 13, 2008 ... Link to comment https://forums.phpfreaks.com/topic/109994-solved-mysql-and-strings-vs-integers/#findComment-564456 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.