Php Error Resource Id 3
Contents |
here 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 site About Us Learn more about Stack Overflow the company Business Learn more about resource id #3 fopen hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges what does resource id 3 mean in php Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. php resource id # Join them; it only takes a minute: Sign up mysql 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
Php Resource Id #4
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 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 php get resource id 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 rednaw 10.6k34158 why do you the var $result and you are printing results ? (with S) –user1200640 Apr 5 '12 at 10:40 just as an example, print_r is a good debugging tool to check what the contents of your vars are. –rednaw Apr 5 '12 at 15:19 add a comment| up vote 0 down vote Your if condition should be like this $result = mysql_fetch_array($res); if (count($result) > 0){ echo 'do something'; } share|improve this answer answered Apr 5 '12 at 10:2
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies resource id #5 php of this site About Us Learn more about Stack Overflow the company Business
Resource(3) Of Type (mysql Result)
Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask
Resource Id Definition
Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign http://stackoverflow.com/questions/10026616/mysql-error-resource-id-3 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.1k65394 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 votes up vote 1 down vote accepted read this mysql_qery() function will return only resource id http://php.net/manual/en/function.mysql-query.php you need to use mysql_fetch_array to retrieve data share|improve this answer answered Mar 11 '11 at 12:33 Gowri 7,1752069130 foreach($_POST['search'] as $search){ $where[]= "model = '".mysql_real_escape_string($sevisit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the http://www.webdeveloper.com/forum/showthread.php?82722-mysql-Resource-id-3 register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 8 of 8 Thread: mysql Resource id #3? Tweet Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 10-20-2005,09:44 AM #1 conputerguy99 resource id View Profile View Forum Posts Registered User Join Date Jul 2005 Posts 50 mysql Resource id #3? When I run this query in my GUI database manager, this code gives me ShaRon, but with my php page, it returns Resource id #3. Does anyone know what this means? Code: SELECT pass FROM customers WHERE name = '$name' Also, when I quote resource id # any of the things other than $name, then it throws me an error saying it's improper sql syntax. Reply With Quote 10-20-2005,10:46 AM #2 tirebiter View Profile View Forum Posts Registered User Join Date Oct 2005 Posts 6 Are you using mysql_fetch_array() to get the data from the query? Code: $query=mysql_query("SELECT pass FROM customers WHERE name = '$name'"); $query_row=mysql_fetch_array($query); echo($query_row[pass]); Reply With Quote 10-20-2005,12:44 PM #3 NogDog View Profile View Forum Posts Visit Homepage Moderator, take two Join Date Aug 2004 Location Ankh-Morpork Posts 21,358 As tirebiter alludes to, mysql_query() returns a resource ID which it uses internally to point to the query results. You then need to use one of the mysql_fetch_*() functions to access those results. See http://www.php.net/mysql_query , particularly Example 2, for an illustration of this process. "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading) My Blog cwrBlog: simple, no-database PHP blogging framework Reply With Quote 09-27-2007,01:01 PM #4 Smiley82 View Profile View Forum Posts Registered User J