visitor Posted September 13, 2010 Share Posted September 13, 2010 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 https://forums.phpfreaks.com/topic/213324-cant-log-in-anymore/ Share on other sites More sharing options...
Philip Posted September 13, 2010 Share Posted September 13, 2010 That means your query failed, since it isn't passing a MySQL resource. Adding in error handling will show you this, and simple bugging such as echo mysql_error(); will also show you this. Link to comment https://forums.phpfreaks.com/topic/213324-cant-log-in-anymore/#findComment-1110739 Share on other sites More sharing options...
Psycho Posted September 13, 2010 Share Posted September 13, 2010 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 https://forums.phpfreaks.com/topic/213324-cant-log-in-anymore/#findComment-1110740 Share on other sites More sharing options...
visitor Posted September 13, 2010 Author Share Posted September 13, 2010 Great! Thank you I'll try... Link to comment https://forums.phpfreaks.com/topic/213324-cant-log-in-anymore/#findComment-1110742 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.