Forum Moderators: coopster
Is my preferred method of doing it: I've yet to find an instance where that doesn't display correctly.$sql = 'SELECT column FROM table WHERE column2 = "something" LIMIT 1';
$result = mysql_query($sql);
if($res = mysql_fetch_assoc($result)) {
echo htmlentities(stripslashes($res['column']), ENT_QUOTES);
}
if(isset($_POST['c']) && is_numeric($_POST['c'])){
//the value of $_POST['c'] is numerical & contains no chars :)
}else{
//the value of $_POST['c'] contains chars and not ints :)
}
if(isset($_POST['c']) && is_numeric($_POST['c'])){
//the value of $_POST['c'] is numerical & contains no chars
}else{
//the value of $_POST['c'] contains chars and not ints
}
if(isset($_POST['c']) && preg_match('/^[\d]+$/', $_POST['c'])) {
// $_POST['c'] is set and is an integer
} else {
// $_POST is either not set, or contains characters other than numbers
}
if(isset($_POST['c']) && is_int($_POST['c'])){
//the value of $_POST['c'] is numerical & contains no chars :)
}else{
//the value of $_POST['c'] contains chars and not ints :)
}
if(isset($_POST['c']) && (int)$_POST['c']){//admittedly loose but does *kinda work*
//the value of $_POST['c'] is numerical & contains no chars :)
}else{
//the value of $_POST['c'] contains chars and not ints :)
}
if(isset($_POST['c']) && ctype_digit($_POST['c'])){
//the value of $_POST['c'] is numerical & contains no chars :)
}else{
//the value of $_POST['c'] contains chars and not ints :)
}
[edited by: Matthew1980 at 9:58 pm (utc) on Jul 14, 2010]
>>condescending hole poking
Isn't that *technically* the other half's job ;) Lol!
if(isset($_POST['c']) && is_int($_POST['c'])){