Error Resource Id 3
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might
Resource Id #8 Error
have Meta Discuss the workings and policies of this site About php resource id 3 Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads
Minecraft Resource Id
with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million resource id #4 programmers, just like you, helping each other. Join them; it only takes a minute: Sign up getting resource #id 3 error up vote 0 down vote favorite When I run this am getting resource #id 3 result. Please look into my code and help me solving this... Please
search.php $host="localhost"; // Host name $username="user"; // Mysql username $password="password"; // Mysql password $db_name="mydb"; // Database name $tbl_name="mobile_search"; // Table name mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); foreach($_POST['search'] as $search){ $where[]= "model = '".mysql_real_escape_string($search)."'"; } $query = "Select model from $tbl_name where ".implode(' OR ',$where); $result = mysql_query($query); echo $result; ?> php share|improve this question edited Mar 11 '11 at 12:38 Jakub Hampl 26.1k65194 asked Mar 11 '11 at 12:28 mythri 20238 hahahah My dear this is not the error.. This means that your query has been executed. Now grab the data from table –Awais Qarni Mar 11 '11 at 12:33 add a comment| 2 Answers 2 active oldest voteshere for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this
Resource Id #2
site About Us Learn more about Stack Overflow the company Business Learn resource id #6 more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question
Resource Id #9
x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up mysql http://stackoverflow.com/questions/5272876/getting-resource-id-3-error error Resource id #3? up vote -3 down vote favorite I am getting the Resource id #3 error when I am trying to echo out the value of the column counter from the database. I want to get a single value only. Any ideas how can I do that ? $Page = $_SERVER['PHP_SELF']; $num = preg_replace("/[^0-9]/", '', $Page); $query = "SELECT * FROM hitscounter http://stackoverflow.com/questions/10026616/mysql-error-resource-id-3 WHERE page='$num';"; $res = mysql_query($query); if (mysql_num_rows($res) > 0) { mysql_query("UPDATE hitscounter SET counter=counter+1 Where page='$num'"); $views = mysql_query("SELECT counter FROM hitscounter WHERE page=555"); mysql_fetch_array($views, MYSQL_NUM); mysql_free_result($views); echo $views; } php mysql share|improve this question asked Apr 5 '12 at 10:09 user1200640 961513 1 Of course you are. You used mysql_fetch_array wrong. Therefore you're not echoing the result of the query since your $views is actually mysql_query call. Try to work out errors on your own, these are really trivial and answered thousands of times. php.net tells you the order of function arguments, check it out. –N.B. Apr 5 '12 at 10:11 You are not storing the result of mysql_fetch_array()... it's not an error, $views is in fact a mysql resource because it's returned as a query result. –Paolo Stefan Apr 5 '12 at 10:13 add a comment| 2 Answers 2 active oldest votes up vote 1 down vote accepted you should use the result you get back from mysql_fetch_array, just like this: $result = mysql_fetch_array($views, MYSQL_NUM); print_r($result); share|improve this answer edited Nov 8 '14 at 13:06 Jerry1 154214 answered Apr 5 '12 at 10:12 redna
Hi, This is more a question of how to use php, so perhaps this page may be of more use http://us2.php.net/manual/en/function.mysql-query.php It gives a good explanation there of how the SELECT statement will return the resource number on success, if you http://lists.mysql.com/mysql/195677 wish to access the data returned, you need to use one of several other functions eg. mysql_fetch_array etc. In other words, your query worked fine, you just haven't accessed the data returned yet. http://www.php.net is a valuable resource on how to use this fine language. Regards --------------------------------------------------------------- ********** _/ ********** David Logan ******* _/ ******* ITO Delivery Specialist - Database ***** _/ ***** Hewlett-Packard Australia Ltd **** resource id _/_/_/ _/_/_/ **** E-Mail: david.logan@stripped **** _/ _/ _/ _/ **** Desk: +618 8408 4273 **** _/ _/ _/_/_/ **** Mobile: 0417 268 665 ***** _/ ****** ****** _/ ******** Postal: 148 Frome Street, ******** _/ ********** Adelaide SA 5001 Australia i n v e n t --------------------------------------------------------------- -----Original Message----- From: Pat Adams [mailto:pat@stripped] Sent: Sunday, 12 March 2006 4:45 PM To: Mysql Subject: Re: mysql_query gives resource id 3 Resource id #3 error On Sat, 2006-03-11 at 12:53 -0500, fbsd_user wrote: > $sql = "SELECT logon_id > FROM members > WHERE logon_id = '$logonid' AND logon_pw = > '$logonpw'"; > > $result = mysql_query($sql) or die('Query failed. ' . > mysql_error()); > > print "$result"; shows Resource id #3 > > Where can I find meaning for what this means? > > And why does mysql_error() not contain the description of this > error? > > And why was the 'or die' condition not taken? Try print($result[0]) or print($result['logon_id']); $result is a handle to the result set, not something you can print. It's the same thing as if you tried to print out the return value of mysql_connect, which should return a resource id. There wasn't an error with the query, so the or die shouldn't execute, and mysql_error should return null. -- Pat Adams Digital Darkness Promotions Check out the Dallas Music Wiki http://digitaldarkness.com/tiki Thread• mysql_query gives Resource id #3 errorfbsd_user11Mar • Re: mysql_query gives Resource id #3 errorPatAdams12Mar • RE: mysql_query gives Resource id #3 errorSST-Adelaide)12Mar © 1995, 2016, Oracle Corporation and/or its affiliates Legal Policies Your Privacy Rights Terms of Use Contact Us Page gene