[MYSQL] Problem retrieving query result

 
Post new topic   Reply to topic    PHP User Group Malta Forum Index // The Database Section
View previous topic :: View next topic  
Author Message
mewt



Joined: 04 Aug 2008
Posts: 1

PostPosted: Tue Aug 05, 2008 8:48 am    Post subject: [MYSQL] Problem retrieving query result Reply with quote
Hi,

Im trying to retrieve data from a database with teh following code:

Code:
$username=mysql_real_escape_string($_POST['username']);
    $password=mysql_real_escape_string($_POST['password']);
    $qry="SELECT User_ID FROM users WHERE user_nick='$username' AND user_pass='".md5($password)."'";
    print($qry);
    $result=mysql_query($qry);
    print($result);


print($qry); prints a well formed sql statement on the lines of SELECT User_ID FROM users WHERE user_nick='mewt' AND user_pass='098f6bcd4621d373cade4e832627b4f6', however print($result) does not print anything. Running the query in query browser, returns a row np...


any pointers ?

M
Back to top
View user's profile Send private message
chaosweapon



Joined: 11 Jan 2008
Posts: 5

PostPosted: Wed Aug 20, 2008 6:53 pm    Post subject: Reply with quote
Place

Code:

echo($username);
echo($password);


in your script and post your results.

----

Try this fix:
Code:

$qry="SELECT User_ID FROM users WHERE user_nick='".$username."' AND user_pass='".md5($password)."'";


----

BTW use print_r() for arrays.
Back to top
View user's profile Send private message Visit poster's website
yancho
Site Admin


Joined: 13 Nov 2007
Posts: 51
Location: Iklin

PostPosted: Thu Aug 28, 2008 9:17 am    Post subject: Reply with quote

 I would do like this:

php:

$password
=mysql_real_escape_string($_POST['password']); 
$pass md5($password);
echo 
$pass;

$qry="SELECT User_ID FROM users WHERE user_nick='".$username."' AND user_pass='".$pass."'"

echo 
"QUERY IS ".$qry;

$result=mysql_query($qry);

print_r($result);

 


_________________
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
Post new topic   Reply to topic    PHP User Group Malta Forum Index // The Database Section All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

alexisRed v1.2 // Theme Created By: Andrew Charron and Web Hosting Bluebook // Icons in Part By: Travis Carden
Boards optimised using the phpBB-SEO mod found at phpbb-seo.com
Boards hosted courtesy of solutions-lab.net
Link Backs : PHPClasses.org - MT Page :: PHPUsergroups.org - MT Page



Powered by phpBB © 2001, 2002 phpBB Group