note 99345 added to function.intval

From: Date: Thu, 12 Aug 2010 02:41:51 +0000
Subject: note 99345 added to function.intval
Groups: php.notes 
Request: Send a blank email to php-notes+get-171592@lists.php.net to get a copy of this message
When retrieving numbers or integers from a MySQL DB, it's best to use intval(), or it will continue to be a string. <?php while($row = mysql_fetch_array($check) { $_SESSION['id'] = inval($row['id']); $user_id = intval($_SESSION['id']); // Not sure if you need to do it again, but doesn't hurt. } is_int($_SESSION['id']) is_int($user_id) is_string($_SESSION['id']) is_string($user_id) // Output true true false false ?> ---- Server IP: 208.69.120.55 Probable Submitter: 68.225.142.108 ---- Manual Page -- http://www.php.net/manual/en/function.intval.php Edit -- https://master.php.net/note/edit/99345 Del: integrated -- https://master.php.net/note/delete/99345/integrated Del: useless -- https://master.php.net/note/delete/99345/useless Del: bad code -- https://master.php.net/note/delete/99345/bad+code Del: spam -- https://master.php.net/note/delete/99345/spam Del: non-english -- https://master.php.net/note/delete/99345/non-english Del: in docs -- https://master.php.net/note/delete/99345/in+docs Del: other reasons-- https://master.php.net/note/delete/99345 Reject -- https://master.php.net/note/reject/99345 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#171592) next »