Hi,
I'm getting an error message and I don't understand what the problem is. I've read the manual but I still see the problem 🙁
Can anyone help me out?
The error message is below:
Warning: Unable to jump to row 0 on MySQL result index 4 in g:\foxserv\www\test\userclass\class.php on line 34
The whole thing is inside a class. See the comments inside de code for the line that generates the error..
Below is my code:
<?php
class User {
var $userID,
$userName,
$userPassword,
$dbHost,
$dbUser,
$dbName,
$dbPass,
$dbUserTable;
function User() {
$this->dbHost = 'localhost';
$this->dbUser = '****';
$this->dbName = '****';
$this->dbPass = '****';
$this->dbUserTable = 'usersexample';
}
function DoLogin(){
$dbLink = mysql_connect($this->dbHost, $this->dbUser, this->dbPass);
if (!$dbLink) die ("Could not connect to database. " . mysql_error() );
mysql_select_db($this->dbName);
$query = "SELECT * FROM $this->dbUserTable WHERE userName=\"$this->userName\"";
$result = mysql_query($query);
if (!$result) die ("didn't work out ". mysql_error() );
$hits = mysql_result($result,0); // THIS LINE GENERATES THE ERROR!!
$hits = hits+1;
$lastseen = date("Y-m-t");
$query = "UPDATE $this->dbUserTable SET lastseen=\"$lastseen\", hits=\"$hits\" WHERE userName=\"$this->userName\"";
$result = mysql_query($query);
if (!$result) die ("didn't work out ". mysql_error() );
mysql_close($dbLink);
}
Class continues but the rest is irrelevant.
mysql is getting a result, the userName in the sql statement after WHERE does exist in the database.