Php Resource Id Error
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
Resource Id #5 Php
about Stack Overflow the company Business Learn more about hiring developers or posting ads resource id #3 php with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow
Resource Id #4 Error In Php
is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up PHP Resource ID error up vote 3 down vote favorite I want php get resource id to retrieve or output data in the database but I kept on getting the error called "Resource ID". Here is my code: '.$name.' We hope that you\'ll Enjoy your stay '; $sql="SELECT Name FROM `people` WHERE what is resource id id =2 && Name = 'Kyel'"; $rs=mysql_query($sql); echo "$rs"; ?> If I need improvement regarding my code kindly tell me. php mysql data-retrieval share|improve this question edited Dec 26 '15 at 12:46 Brian Tompsett - 汤莱恩 3,101132775 asked Aug 22 '11 at 3:00 user759630 3341510 add a comment| 2 Answers 2 active oldest votes up vote 4 down vote mysql_query() returns a resource. The to string (implicitly triggered by using echo to output it) of that is Resource ID # followed by the id. A resource in PHP is only supposed to be used with other PHP functions. This includes but is not limited to file, curl, ftp handles, etc. I could tell you to.. (a) use mysql_fetch_array() (or similar) or (b) use PDO. The latter is by far much better advice. share|improve this answer answered Aug 22 '11 at 3:02 alex 267k129653807 add a comment| up vote 0 down vote Try this instead of the echo statement: $array = mysql_fetch_assoc($rs); var_dump ($array); share|improve this answer answered Aug 22 '11 at 3:06 Len 413410 it gives me an array, I only want the data itself so that I could compare it with the userinput . I'll get data from the database and then Com
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 Definition
of this site About Us Learn more about Stack Overflow the company Business resource id #6 in php Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges
Resource Id Android
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. Join them; it only takes a minute: http://stackoverflow.com/questions/7142775/php-resource-id-error Sign up Getting Resource id #3 Error in MySql up vote 3 down vote favorite 1 I ran this code and I got a Resource id #3 error where it should have showed the full movies table. mysql_connect("localhost", "root", "password") or die(mysql_error()); mysql_select_db("treehouse_movie_db") or die(mysql_error()); $data = mysql_query("SELECT * FROM movies") or die(mysql_error()); echo $data; php mysql database echo share|improve this question asked http://stackoverflow.com/questions/17417308/getting-resource-id-3-error-in-mysql Jul 2 '13 at 4:16 user2533901 16112 Possible duplicate: stackoverflow.com/questions/17385404 –Thomas Kelley Jul 2 '13 at 4:19 add a comment| 2 Answers 2 active oldest votes up vote 8 down vote This is not an error Your query is getting executed and you are getting appropriate resource from mysql_query() as it should be returned. To get the response you have to use mysql_fetch_array() or mysql_fetch_assoc() mysql_connect("localhost", "root", "password") or die(mysql_error()); mysql_select_db("treehouse_movie_db") or die(mysql_error()); $data = mysql_query("SELECT * FROM movies") or die(mysql_error()); while($row = mysql_fetch_assoc($data)) { print_r($row); } SUGGESTION: mysql_* are no longer maintained .Try switching to mysqli_* or PDO share|improve this answer edited May 8 '15 at 16:13 Fred -ii- 69.6k93973 answered Jul 2 '13 at 4:20 alwaysLearn 4,03421748 +1 to you for a compelete and clear answer. –ncm Jul 2 '13 at 4:28 add a comment| up vote 0 down vote You're not getting an error, the MySQL API is just doing what you're asking it to: echoing the contents of $data, which is a MySQL query resource at this point. Extend the code to actually retrieve the results: whi
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 http://stackoverflow.com/questions/10026616/mysql-error-resource-id-3 Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads 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 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up mysql error Resource id #3? up resource id 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 WHERE page='$num';"; $res = mysql_query($query); if (mysql_num_rows($res) php resource id > 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 rednaw 10.6k34158 why do you the var $result and you are printing resul