February 2, 201016 yr Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in (filelocation) on line 68 $data = mysql_query("SELECT * FROM users WHERE username = '($this->username)' AND password = '($this->password)'"); if(mysql_num_rows($data) > 0) { $row = mysql_fetch_array($data); //line 68 $this->id = $row['id']; return true; } else { return false; } Cant for the life figure out what this means, having a browse over google, but nothing seems to be helping me at the moment, was wondering if anyone here knows the answer? Many Thanks Ben
February 3, 201016 yr Hi I tried out your code. I got the message you reported when I used an incorrect field name in the where clause. ie username instead of user_name. Just a thought.
February 3, 201016 yr Author Hi I tried out your code. I got the message you reported when I used an incorrect field name in the where clause. ie username instead of user_name. Just a thought. I've double checked the SQL statement, was was pointing the the wrong table,(fixed now) and changed username to email which is what it should have been, but im still receiving the errors.
February 3, 201016 yr Hmmm, I'm not familiar with the $this->id code I usually just use $id = .... However when stumped strip out all the code and start off with the very simple that works. Then add bits slowly until you identify what is causing the error. You can display what is in your vaiables using eg. echo $id; Very often I find that this is the only way to identify where the problem is. Often you will find the problem isn't what you think. Good luck ....
February 3, 201016 yr Author Hmmm, I'm not familiar with the $this->id code I usually just use $id = .... However when stumped strip out all the code and start off with the very simple that works. Then add bits slowly until you identify what is causing the error. You can display what is in your vaiables using eg. echo $id; Very often I find that this is the only way to identify where the problem is. Often you will find the problem isn't what you think. Good luck .... Its OOP php, thats why its using the $this->id method, if it was procedural php it would be as you said. Im just about to echo the IDs so ill see what comes up if not, ill copy some script from other work and see if it works. Thanks for help so far mate.
February 3, 201016 yr Ben, can you confirm: 1. You have opened a connection to MySQL. 2. You have selected the DB. Try: $linkname = //mysql connect $data = mysql_query("SELECT * FROM users WHERE username = '($this->username)' AND password = '($this->password)'", $linkname); if(mysql_num_rows($data) > 0) { $row = mysql_fetch_array($data); //line 68 $this->id = $row['id']; return true; } else { return false; } Another idea would be to use MySQLi or even PDO. Kyle
February 3, 201016 yr Author Ben, can you confirm: 1. You have opened a connection to MySQL. 2. You have selected the DB. Try: $linkname = //mysql connect $data = mysql_query("SELECT * FROM users WHERE username = '($this->username)' AND password = '($this->password)'", $linkname); if(mysql_num_rows($data) > 0) { $row = mysql_fetch_array($data); //line 68 $this->id = $row['id']; return true; } else { return false; } Another idea would be to use MySQLi or even PDO. Kyle I have connected to the database. the code is just above it, didnt include it but cant if you want, and im going to try msqli later, too tired now, and what is PDO?
February 3, 201016 yr You could try asking on stackoverflow. The community there is very tech oriented and surely could help you get this right.
Create an account or sign in to comment