Earlier quoted context omitted.
That's an example of hazardously bad programming practices. You're one mistake away from complete disaster. You should be sure that it takes more than one mistake to expose you to that sort of risk. Casting to int is not a general purpose escaping system, and further, if you miss even one of these your entire application can be trashed. Using mysql_query at all is a sign there's something severely wrong with your app…
There is an opposing viewpoint, i.e. if you actually need an int, casting to int is one of the most reasonable ways of getting it.
If you're inserting a value in a database, you always, always, always use the proper escaping mechanism. No exceptions.
That's why using a library with a reliable, well-defined, easy to use escaping system is absolutely imperative.