Php Error Resource Id #1
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 resource id #5 php Us Learn more about Stack Overflow the company Business Learn more about hiring
Resource Id #3 Php
developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the what is resource id in php 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 Resource id#1 Error in PHP up
What Is A Resource Id
vote 0 down vote favorite
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
Resource Id #4 Php Error
company Business Learn more about hiring developers or posting ads with us Stack Overflow
Resource Id Definition
Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 resource id #4 curl million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Getting Resource id #3 Error in MySql up vote 3 down vote favorite 1 I ran this code and http://stackoverflow.com/questions/8768048/resource-id1-error-in-php 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 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 http://stackoverflow.com/questions/17417308/getting-resource-id-3-error-in-mysql 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: while($row = mysql_fetch_object($data)) var_dump($row); And you'll see the output. Note that the mysql_* API is deprecated since PHP 5.5 by the way. share|improve this answer answered Jul 2 '13 at 4:18 Niels Keurentjes 27k53987 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Pass
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 http://stackoverflow.com/questions/9754320/figuring-out-why-i-am-getting-a-resource-id-5-error About 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 Figuring out why resource id I am getting a Resource ID #5 error up vote 1 down vote favorite This is a part of my code, and the echo is to test the value and it gives me Resource ID #5 $id = mysql_query("SELECT id FROM users WHERE firstname='$submittedfirstname' AND lastname='$submittedlastname' AND email='$submittedemail'") or die(mysql_error()); $counter = mysql_num_rows($id); echo $id; I am just getting into programming, and lately seeing lot resource id #4 of Resource ID outputs/errors while working with Databases. Can someone correct the error in my code? And explain me why it isnt giving me the required output? php share|improve this question asked Mar 17 '12 at 22:26 Kishor 1,25221019 1 If you're just getting into programming, you shouldn't learn the mysql_* functions. Learn PDO or mysqli instead. –Maerlyn Mar 18 '12 at 13:10 I had this but it was because I had an old print_r($my->adapter) in my code. I commented it out. –johnny Nov 17 '15 at 18:55 add a comment| 4 Answers 4 active oldest votes up vote 4 down vote accepted This is not an error. This is similar to when you try to print an array without specifying an index, and only the string "Array" is printed. You can access the actual data contained within that resources (which you can think of as a collection of data) using functions like mysql_fetch_array(). In fact, if there were an error here, the value of $id would not be a resource. I usually use the is_resource() function to verify that everything is alright before using variables which are sup