Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Php error

Featured Replies

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

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.

  • 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.

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 ....

  • 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.

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

 

  • 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?

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.