Results 1 to 2 of 2

Thread: query trouble

  1. #1
    Join Date
    Jun 2010
    Posts
    243

    query trouble

    I am having issues with this code. i type in random credentials, and nothing shows up after this code. if i type in a valid username like admin that is in the database, the page works fine. why won't it run properly?

    Code:
    $uname = mysql_real_escape_string($_POST['uname']);
    	$pword = mysql_real_escape_string($_POST['pword']);
    	$query = mysql_query("SELECT uname, pword, admin, active FROM members WHERE uname='admin'");
    	$row = mysql_fetch_array($query) or die(mysql_error());
    this code will work. but instead of 'admin', i will put $uname.

  2. #2
    Join Date
    Jun 2010
    Posts
    243
    nevermind... fixed by doing this...

    Code:
    if(mysql_num_rows($query) != 0)
    	{
    		$row = mysql_fetch_array($query) or die(mysql_error());
    i guess it was getting hung up on retrieving records that were not in the db?

Similar Threads

  1. Form Query
    By mitchrenton in forum General Questions
    Replies: 1
    Last Post: 11 Jan 2008, 09:01 PM
  2. UK Copyright query
    By richard_ray in forum Freelancing
    Replies: 1
    Last Post: 25 Apr 2006, 09:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •