Php Mysql 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 about Stack Overflow the company Business
What Is Resource Id In Php
Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation resource id #5 php Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just resource id #3 php 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 I got a Resource
Php Get Resource Id
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 down vote This is not an
What Is A Resource Id
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 Password Post as a guest Name Email Post as a guest Name Email disca
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 php resource id #4 more about Stack Overflow the company Business Learn more about hiring developers or posting
Resource Id Definition
ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack resource id #2 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 I am getting a Resource ID #5 error http://stackoverflow.com/questions/17417308/getting-resource-id-3-error-in-mysql 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 of Resource ID outputs/errors while working with Databases. Can someone correct http://stackoverflow.com/questions/9754320/figuring-out-why-i-am-getting-a-resource-id-5-error 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 supposed to contain a resource. I guess what you intend to do is this: $result = mysql_query("SELECT id FROM users WHERE firstname='$submittedfirstname' AND las
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/9618604/resource-id-6-error-in-php-with-mysql About Us Learn more about Stack Overflow the company Business Learn more about http://stackoverflow.com/questions/10026616/mysql-error-resource-id-3 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 Resource id #6 error resource id in PHP with MySQL up vote 0 down vote favorite I am this is for a polling system I am making, this code shows the user a list of questions they can pick from:
Select Your Question