Jump to content

can't log-in anymore...


visitor

Recommended Posts

Hi,

 

somehow I can't log-in on my testsite anymore... (username: user / pw: pass)

 

I receive the following error message... Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/web1244/public_html/functions.php on line

 

the code is as follows...

 

<?php

function get_fund($ISIN)
{
        $ISIN = mysql_real_escape_string($ISIN);
	$qr = mysql_query("SELECT * FROM fund WHERE ISIN='".$ISIN."' ");
if ( mysql_error() ) echo mysql_error();
if ( mysql_num_rows($qr) == 0 ) return NULL;
return mysql_fetch_object($qr);
}

function show($var) 
{
  if(trim($_POST[$var])) return 'value="'.trim($_POST[$var]).'"';
  return '';;
}


function checkForError($text, $result, $output)
{
  if (in_array(($text), $result))
    echo "<span style='color:#FF0000'>$output</span>";
  else
    echo "$output";
}

function exist($var) 
{
  if(isset($var))
  if(trim($var) !== '')
    return TRUE;
  return FALSE;
}
function logged() 
{
  if(exist($_SESSION['login']))
    return TRUE;
  return FALSE;
}
function loggedAdmin() 
{
  if(exist($_SESSION['admin']))
  if($_SESSION['admin'] == aPass)
    return TRUE;
  return FALSE;
}

function loginAdmin() 
{
  if(exist($_POST['username']))
  if(exist($_POST['password']))
  if(exist($_POST['button']))
  if(trim($_POST['username']) == aLogin)
  if(trim($_POST['password']) == aPass)
    $_SESSION['admin'] = aPass;
}

function login() 
{
  if(exist($_POST['username']))
  if(exist($_POST['password']))
  if(exist($_POST['button']))
  if(mysql_ping())
  {
    $query = "SELECT * FROM user WHERE login ='".mysql_real_escape_string($_POST['username'])."' AND password='".mysql_real_escape_string($_POST['password'])."'";
    $res = mysql_query($query);
    if(mysql_num_rows($res))
    {
      $resx=mysql_fetch_assoc($res);
      $_SESSION['login'] = $resx['id'];
    }

  }
}

function getAccounts($id = false) 
{
  $accounts= array();
  $query = $id? " SELECT id, name FROM custody_ac WHERE id_client = '$id'" :"SELECT id, name FROM custody_ac WHERE id_client = '".$_SESSION['login']."'";
  $qres=mysql_query($query);
  while($row = mysql_fetch_assoc($qres))
    $accounts[] = $row;
  return($accounts);
}
?>

 

is there probably anyone who could tell me what I've done wrong, please?

 

Thanks

 

ozzo

Link to comment
Share on other sites

Your query is failing. I've never seen that method of checking for a db error. Plus, even if there is one, the code continues on to the next step that would produce the error. Try this:

 

function get_fund($ISIN)
{
    $ISIN = mysql_real_escape_string($ISIN);
    $query = "SELECT * FROM fund WHERE ISIN='{$ISIN}'";
    $result= mysql_query($query);
    if (!$result)
    {
        echo "Error:<br />" . mysql_error() . "<br />Query: {$query}";
        return false;
    }
    if ( mysql_num_rows($result) == 0 ) { return NULL; }
    return mysql_fetch_object($result);
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.