PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 2nd, 2012, 01:35 AM
mahesh_k mahesh_k is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 4 mahesh_k Negative: is most likely a SPAMMER and a traitor to the cause. 
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.

Reply With Quote
  #2  
Old October 2nd, 2012, 03:06 AM
Jacques1's Avatar
Jacques1 Jacques1 is online now
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,875 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
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).

Reply With Quote
  #3  
Old October 2nd, 2012, 08:09 AM
ManiacDan's Avatar
ManiacDan ManiacDan is offline
Likely to be eaten by a grue.
Dev Shed God 10th Plane (9500 - 9999 posts)
 
Join Date: Oct 2006
Location: Pennsylvania, USA
Posts: 9,811 ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)  Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Months 3 Weeks 18 h 20 m 12 sec
Reputation Power: 6112
That's not an error, you're forgetting a step in your code.

The resource ID error is in the new user guide.

v----------- Right Here ------------v
__________________
HEY! YOU! Read the New User Guide and Forum Rules

"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

Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

Reply With Quote
  #4  
Old October 2nd, 2012, 11:49 PM
mahesh_k mahesh_k is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 4 mahesh_k Negative: is most likely a SPAMMER and a traitor to the cause. 
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.

************

<?php
$hostname = "localhost";
$db_user = "xxxxxxxxx";
$db_password = "xxxxxxxx";
$database = "xxxxxxxxxx";

$db_table = "dailychecklist";



$db = mysql_connect($hostname, $db_user, $db_password);




if (! $db) die(mysql_error());

mysql_select_db($database,$db);


global $current_user;
get_currentuserinfo();
echo 'email: ' . $current_user->user_email . "\n";
$loggedemail = $current_user->user_email;



$result = mysql_query( "SELECT * FROM $db_table where email='$loggedemail'" )
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "There are $num_rows records.<br>";

print "<table width=600 border=1>\n";
while ($get_info = mysql_fetch_row($result)){
print "<tr>\n";
foreach ($get_info as $field)
print "\t<td>$field</td>\n";
print "</tr>\n";
}
print "</table>\n";
mysql_close($db);
?>


Thanks in advance for your valuable support,
Mahesh.

Reply With Quote
  #5  
Old October 3rd, 2012, 08:40 AM
danramosd danramosd is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Location: Jersey
Posts: 16 danramosd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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?

Reply With Quote
  #6  
Old October 3rd, 2012, 09:05 AM
mahesh_k mahesh_k is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 4 mahesh_k Negative: is most likely a SPAMMER and a traitor to the cause. 
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*/


//global $current_user;
//get_currentuserinfo();

//echo 'Welcome to: ' . $current_user->user_login . "\n";
//echo 'email: ' . $current_user->user_email . "\n";
//echo 'Member from: ' . $current_user->user_registered . "\n";

//$logged = $current_user->user_login;
//$loggedemail = $current_user->user_email;





$hostname = "localhost";
$db_user = "harvamin_harvam";
$db_password = "H@r1vam2";
$database = "harvamin_om";
//$db_table = "custtable";
//$order_table = "order";

$db_table = "dailychecklist";



$db = mysql_connect($hostname, $db_user, $db_password);



//$db="newdb";
//$link = mysql_connect('localhost', 'root', '');

if (! $db) die(mysql_error());
//mysql_select_db($db , $link) or die("Couldn't open $db: ".mysql_error());
mysql_select_db($database,$db);

$result = mysql_query( "SELECT * FROM $db_table where email='admin@infratran.com'" )
or die("SELECT Error: ".mysql_error());


//$result = mysql_query( "SELECT * FROM $db_table where dailychecklist.email=$current_user->user_email" )
//or die("SELECT Error: ".mysql_error());

//$loggedemail = $current_user->user_email;


$num_rows = mysql_num_rows($result);
print "There are $num_rows records.<br>";

print "<table width=600 border=1>\n";
while ($get_info = mysql_fetch_row($result)){
print "<tr>\n";
foreach ($get_info as $field)
print "\t<td>$field</td>\n";
print "</tr>\n";
}
print "</table>\n";
mysql_close($db);
?>


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,
Comments on this post
ManiacDan disagrees: Answer the questions that are asked of you.

Reply With Quote
  #7  
Old October 3rd, 2012, 09:10 AM
ManiacDan's Avatar
ManiacDan ManiacDan is offline
Likely to be eaten by a grue.
Dev Shed God 10th Plane (9500 - 9999 posts)
 
Join Date: Oct 2006
Location: Pennsylvania, USA
Posts: 9,811 ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)  Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1
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.

Reply With Quote
  #8  
Old October 3rd, 2012, 09:28 AM
danramosd danramosd is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Location: Jersey
Posts: 16 danramosd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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)

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Wordpress - Resource id # 366 error I am getting

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap