Hi Everyone, I'm trying to figure out the correct syntax when trying to validate this line of code using intval (). $id = ereg_replace("[^0-9]", "", $_GET['id']); // filter everything but numbers for securityif ($id == "") { echo "Missing Data to Run"; exit();} PHP: Below is what I think is the correct syntax but I''m getting an error message and I'm not sure what I'm doing wrong. http://whatsmyowncarworth.com/more-practice/member_profile.php?id=10 Error message "Missing Data to Run" (I think this is the correct way but my syntax is wrong. What's the correct syntax?) $id = $_GET['id'] = 1;if (filter_var($id, FILTER_VALIDATE_INT) !== false){ echo "Missing Data to Run"; exit();} PHP: Any help would be appreciated! Thanks everyone!
try to use ctype_digit - Check for numeric character(s). Returns TRUE if every character in the string text is a decimal digit, FALSE otherwise.
I think that PHP have an is_numeric function. Returns TRUE if var is a number or a numeric string, FALSE otherwise.