Discuss Resource id # 366 error I am getting in the PHP Development forum on Dev Shed. Resource id # 366 error I am getting PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
Posts: 4
Time spent in forums: 1 h 1 m 37 sec
Reputation Power: 0
Wordpress - Resource id # 366 error I am getting
Hello every one,
I am using PHP script in Wordpress for displaying logged in user details in the site home page. I can successfully get username,email,display name etc., from current_user global function. Now, with in the same page php code I am trying to get custom table information based on logged in user email primary key. But I am getting the error as result= Resource id #366.
Please support this issue.
I have a custom table "memberlevel" have primary key column as user_email I have written sql query for memberlevel table and wp_users default wordpress table like this
$presentlevelsql= ("SELECT level FROM $db_table WHERE user_email='$current_user->user_email'");
Thank you so much in advance for your valuable time spending for me.
Posts: 1,875
Time spent in forums: 1 Month 2 Weeks 2 Days 3 h 47 m 17 sec
Reputation Power: 813
Hi,
What exactly does the error message say? What happens when you output the query and execute it in phpmyadmin?
Also you should be much more careful with inserting variables in queries. If you don't escape them, your code will be vulnerable to SQL injections (that is, an attacker can manipulate your query and try to steal information).
"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin
"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002
Posts: 4
Time spent in forums: 1 h 1 m 37 sec
Reputation Power: 0
I want to display current logged in user details from a database in wordpress sitepag
Hello,
Thank you so much for your valuable replies. Actually I have build a site in wordpress with buddypress. I have created a table in the database for any user logged in and attend a test in the site that table have been updated. Now, my requirement is I have created one menu for logged in user knowing his test result. When any logged in user click on that menu I want to show his details from that previous table. I have pasted my code below please support me for this issue. Thank you so much for your valuable support.
Posts: 16
Time spent in forums: 2 h 35 m 46 sec
Reputation Power: 0
At which point are you getting the error. I ran the code on my local db but commented out the global $current_user; TO $loggedemail lines because I don't have that code. If you comment out those lines does it work for you? If it is choking on those linnes can you provide the code for those functions?
Posts: 4
Time spent in forums: 1 h 1 m 37 sec
Reputation Power: 0
Hello danramosd,
Thank you so much for your valuable reply. In my wordpress site database I have default database table wp_users with in this I have user_email column. And I have custom table for users test competition details updation in this table also I have created email column. Now I am trying to use where clause in mysql for email for showing current logged in user details.
Now, I am trying to display current logged in user details from custom table by using mysql command like this
*************
<?php
/* Change next two lines if using online*/
I have commented that global $current_user function code lines because wordpress phpexec plugin didnit support like that error I have got. So, please support this issue. I have tried so many cases.
Thanks in advance for your valuable time for me,
Mahesh,
Posts: 9,811
Time spent in forums: 2 Months 3 Weeks 18 h 20 m 12 sec
Reputation Power: 6112
Read the new user guide and at least attempt to answer the questions you are asked. He asked you a direct question, you ignored it. Pasting your code over and over again is not the solution, especially since you continue to paste your code incorrectly, unformatted, and uncolored.
Posts: 16
Time spent in forums: 2 h 35 m 46 sec
Reputation Power: 0
A couple things:
I have to comment the same lines again because I don't have access to the source code of your global $current_user variable along with get_currentuserinfo() function. This puts me back to square 1 because when I comment out the same lines it works for me.
With that being said your sql commands seem to work fine when I run it on a test DB locally. I would recommend you comment out all of the DB related queries and make sure the $current_user variable is giving you all the data you expected. Instead of using variables try hard coding in the values you expect the variables to be. For example instead of:
PHP Code:
$loggedemail = $current_user->user_email;
Try
PHP Code:
$loggedemail = 'foo@bar.com';
This wil allow you to start narrowing down your issues.
If you're still running into issues please provide a MySQL dump of your database table(s).
Finally, assuming you're running PHP5 i highly recommend using mysqli VS mysql for all your queries, or possibly even looking into other methods. Google around mysqli vs mysql to read why (i would post a link but apparently news users aren't allow)