Error Resource Id # Php
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
Resource Id #4 Error In Php
site About Us Learn more about Stack Overflow the company Business Learn resource id php mysql more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x resource id #5 php mysql 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 Getting
Php Resource Id #3
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 Jul 2 '13 at
Resource Id 8 Php Mysql
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.4k93973 answered Jul 2 '13 at 4:20 alwaysLearn 4,03421548 +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. Not
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 resource id sql site About Us Learn more about Stack Overflow the company Business Learn more
Resource Id #5 Php
about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x what is resource id in php 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 Figuring out http://stackoverflow.com/questions/17417308/getting-resource-id-3-error-in-mysql why 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 http://stackoverflow.com/questions/9754320/figuring-out-why-i-am-getting-a-resource-id-5-error seeing lot 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 variabl
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 hiring developers or http://stackoverflow.com/questions/19142711/mysql-query-returning-resource-id-5 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 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up mySQL query returning Resource id #5 up vote 0 down vote favorite I've searched about possible solutions to this. and I've tried looping as well as trying the variants of mysql_fetch_assoc and mysql_fetch_array but I'm resource id still getting the Resource id #5: 0: error. Here's my code which I think generates the error. \n$sql"); $row = mysql_fetch_assoc($res); ?> php mysql facebook facebook-graph-api facebook-fql share|improve this question asked Oct 2 '13 at 17:08 Pau 28137 2 Firstly, why is this tagged with Facebook tags? Secondly, there's no code here that resource id # prints anything out - what is the value of $res? What are you doing with $row? –andrewsi Oct 2 '13 at 17:10 add a comment| 3 Answers 3 active oldest votes up vote 1 down vote accepted "Resource id #5: 0" is not an error. It means that you tried to echo $res instead of trying to use the $row variable, such as $row[column] for fetch_assoc, $row[0] for fetch_row, either/both for fetch_array. The other answers explain the use of mysql_fetch_* Also, mysql_* is deprecated. You should use mysqli_* or PDO functions instead. share|improve this answer answered Oct 2 '13 at 17:43 Jacob S 1,19559 add a comment| up vote 1 down vote Please use this one : while($row = mysql_fetch_object($res)){ //do somthing echo $row->name; } I am already use this one in our code share|improve this answer edited Oct 2 '13 at 17:24 Ankush Choudhary 17 answered Oct 2 '13 at 17:19 kuldeep raj 326420 add a comment| up vote 0 down vote you need to use mysql_fetch_row share|improve this answer answered Dec 7 '15 at 8:27 David Hackro 1,10411021 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using G