Error Resource Id 6
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 resource id #8 error Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation
Resource Id #4 Error In Php
Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like minecraft resource id you, helping each other. Join them; it only takes a minute: Sign up How do i “echo” a “Resource id #6” from a MySql response in PHP? up vote 5 down vote favorite 1 very simple question, resource id #3 i have this: $datos1=mysql_query("SELECT TIMEDIFF(NOW(), '" . $row['fecha'] . "');"); echo($datos1); But the result is: Resource id #6 How can i print the result in the way is meant to be? Thanks! php mysql share|improve this question asked Nov 27 '10 at 4:19 DomingoSL 4,4171163124 1 There is quite a number of duplicates asking essentially the same question. I've voted to close a few of them as duplicates of this one here, as this is
Resource Id #5
among the oldes ones, and phrased in a sufficiently clear and concise fashion to serve as the canonical version. –MvG Nov 7 '12 at 13:50 add a comment| 1 Answer 1 active oldest votes up vote 8 down vote accepted You need to use a fetch function. for example: $result = mysql_query(sprintf("SELECT TIMEDIFF(NOW(), '%s') as time_delta", $row['fecha'])); if($result){ $data = mysql_fetch_assoc($result); echo $data['time_delta']; } However, i wouldnt use the mysql functions unless absolutely necessary. the mysql extension is NOT recommended for use in new projects. Instead you should use PDO with PDO_mysql or mysqli. share|improve this answer edited Nov 27 '10 at 4:37 answered Nov 27 '10 at 4:27 prodigitalson 47.7k36485 1 +1 PDO, not mysqli. Only use mysqli if you are really, really sure that you're going to want to torture yourself with mysql forever and never switch to something else. –El Yobo Nov 27 '10 at 9:26 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 discard By posting your answer, you agree to the privacy policy and terms of service. Not the answer you're looking for? Browse other questions tagged php mysql or ask your own question. ask
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta resource id #2 Discuss the workings and policies of this site About Us Learn resource id #9 more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack
Mysql Resource Id
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, http://stackoverflow.com/questions/4290108/how-do-i-echo-a-resource-id-6-from-a-mysql-response-in-php helping each other. Join them; it only takes a minute: Sign up Resource id #6 error, Not sure how to fix it up vote -3 down vote favorite I keep getting a 'Resource id # 6' failure when submitting a script on my website. The code I'm using is the same type of code I use for http://stackoverflow.com/questions/29099252/resource-id-6-error-not-sure-how-to-fix-it registering for the website and that works but this script doesn't work at all. What my code does is send a booking request with the fields as shown to the database. I keep getting a Resource id#6 error , and I've googled what that is but I can't seem to figure out whats wrong. I am a beginner at php , so any tips on whats to look for to avoid a resource id # 6 error would be a lot of help
$sum; now this gives output Resource id #6 https://www.sitepoint.com/community/t/resource-id-6-what-is-this-headache/2046 what on earth does that mean please help people...i am new and learning and i wanna solve this ...how do i do with the script?? GoldFire 2005-05-14 06:35:16 UTC #2 Change your code to the following: $sum = mysql_fetch_array(mysql_query("SELECT SUM(score) FROM username WHERE optionno = correct")); echo $sum[0]; resource id ranjitcool 2005-05-14 06:44:01 UTC #3 BUT WHY DOES that give that error is that an error? bigduke 2005-05-14 07:02:11 UTC #4 thats not an error it simply tells you what the variable holds, in this case its a resource id, much like a handle. also, your query should error resource id put strings in quotes: $sum = mysql_fetch_array(mysql_query("SELECT SUM(score) FROM username WHERE optionno = 'correct'")); echo $sum[0]; GoldFire 2005-05-14 15:48:43 UTC #5 bigduke said: also, your query should put strings in quotes: No, the way I posted it is correct because that is not a string it is a field in the table. Luke_Redpath 2005-05-15 00:14:57 UTC #6 No, he is correct. This part: WHERE optionno = 'correct'" Does need the quotes as you are testing for the string 'correct'. GoldFire 2005-05-15 00:50:25 UTC #7 I already talked to ranjitcool over PM and he told me that correct was a field in his table. Luke_Redpath 2005-05-15 03:46:00 UTC #8 Mmm, perhaps a better naming convention is in order! system 2014-10-08 00:32:36 UTC #9 Home Categories FAQ/Guidelines Terms of Service Privacy Policy Powered by Discourse, best viewed with JavaScript enabled Shop Versioning Reference Articles Premium