943,169 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 94
  • PHP RSS
Sep 3rd, 2010
0

PHP Select but not showing the result

Expand Post »
This is the part which searches and add the result to the 'pass' variable. At one stage I was getting a resource id number and found to get around that, but when I do this I get nothing on the pass variable

PHP Syntax (Toggle Plain Text)
  1. $result = mysql_query("SELECT `Pass` FROM `wiki` WHERE `User` ='" . $user ."'");
  2. if ($result) {
  3. $row = mysql_fetch_assoc($result);
  4. $pass = $row['Pass'];
  5. mysql_free_result($result);
  6. }
  7. mysql_close($con);

Can anyone help me please?
Thanks
Reputation Points: 10
Solved Threads: 0
Newbie Poster
lulemurfan is offline Offline
9 posts
since Sep 2010
Sep 5th, 2010
0
Re: PHP Select but not showing the result
Click to Expand / Collapse  Quote originally posted by lulemurfan ...
This is the part which searches and add the result to the 'pass' variable. At one stage I was getting a resource id number and found to get around that, but when I do this I get nothing on the pass variable

PHP Syntax (Toggle Plain Text)
  1. $result = mysql_query("SELECT `Pass` FROM `wiki` WHERE `User` ='" . $user ."'");
  2. if ($result) {
  3. $row = mysql_fetch_assoc($result);
  4. $pass = $row['Pass'];
  5. mysql_free_result($result);
  6. }
  7. mysql_close($con);

Can anyone help me please?
Thanks
hey there lulemurfan!

i hope this helps :
PHP Syntax (Toggle Plain Text)
  1. //$result = mysql_query("SELECT Pass FROM wikiWHERE `User` ='" . $user ."'"); // maybe it's from here
  2.  
  3. $result = mysql_query("SELECT Pass FROM wiki WHERE User like '$user'"); // try this instead
  4.  
  5. if ($result) {
  6. $row = mysql_fetch_assoc($result);
  7. $pass = $row['Pass'];
  8. mysql_free_result($result);
  9. }
  10. mysql_close($con);

you may also try to check first the query if it's getting the right value by echoing it first:
echo "your query : ".$result;

happy day ahead! ~_^
Last edited by ﻼim; Sep 5th, 2010 at 10:21 pm. Reason: additional. Ϋ
Reputation Points: 10
Solved Threads: 13
Junior Poster
ﻼim is offline Offline
171 posts
since Aug 2010
Sep 6th, 2010
0
Re: PHP Select but not showing the result
To add to ﻼim's answer you might want to also add on a die() or error reporting system for the query:
php Syntax (Toggle Plain Text)
  1. $result = mysql_query("SELECT Pass FROM wiki WHERE User like '$user'") or die(mysql_error());

That way if it does error, it'll stop loading the page and display what error happened so you know where to look or what actually happened. Note though that this will only fire if the error occurs inside the query itself.
Reputation Points: 23
Solved Threads: 21
Junior Poster in Training
Nyight is offline Offline
99 posts
since Aug 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Retrieving unique user data
Next Thread in PHP Forum Timeline: integrating fckeditor filemanager in ckeditor





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC