bravo14 Posted February 17, 2010 Share Posted February 17, 2010 Hi Guys I have the following code <?php error_reporting(E_ALL); ini_set('display_errors', 1); include('includes/connect.php'); $sql=("SELECT * FROM `tbl_pages` WHERE `page_address_identifier` = '" . mysql_real_escape_string(intval($_GET['page_id'])) . "' LIMIT 1"); echo $sql; $result=mysql_query($sql); if(mysql_num_rows($result)==0) { die("No record found"); } $row = mysql_fetch_array($result); ?> from the following url http://79.170.44.125/platinumbrides.co.uk/page.php?page_id=events The following query is then perfromed, SELECT * FROM `tbl_pages` WHERE `page_address_identifier` = '0' LIMIT 1 b I cannot see where the 0 is coming from Any ideas what I have done wrong? Link to comment https://forums.phpfreaks.com/topic/192438-query-based-on-url/ Share on other sites More sharing options...
LeadingWebDev Posted February 17, 2010 Share Posted February 17, 2010 http://79.170.44.125/platinumbrides.co.uk/page.php?page_id=events u r validating page id as INT, and it is a stirng. Link to comment https://forums.phpfreaks.com/topic/192438-query-based-on-url/#findComment-1013976 Share on other sites More sharing options...
sader Posted February 17, 2010 Share Posted February 17, 2010 0 comes from intval() this function return integer if passed variable can be converted into integer number or 0 on failure. Your $_GET['page_id'] is not a number is a string "events" so somewhere in your code instead some id u printing "events" as url parameter Link to comment https://forums.phpfreaks.com/topic/192438-query-based-on-url/#findComment-1013978 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.