It seems that you might be using incorrect table name or field names in your query. Make sure that the there is table contains fields named item and howmany. I've reproduced this error in my local PC when I mentioned the table names or field names incorrectly in my SQL query.
You can have a look at the code I've used
PHP Code:
<?php
class database
{
private $db_handle;
private $user_name;
private $password;
private $data_base;
private $host_name;
private $sql;
private $results;
function __construct($host="localhost",$user,$passwd)
{
$this->db_handle = mysql_connect($host,$user,$passwd);
}
function dbSelect($db)
{
$this->data_base = $db;
if(!mysql_select_db($this->data_base, $this->db_handle))
{
error_log(mysql_error(), 3, "/phplog.err");
die("Error connecting to Database");
}
}
function executeSql($sql_stmt)
{
$this->sql = $sql_stmt;
$this->result = mysql_query($this->sql);
}
function returnResults()
{
return $this->result;
}
}
$user = "root";
$passwd = "";
$db = "testdb";
$sql = "SELECT * FROM users WHERE screenname = 'codeexploiter' AND password = '12345'";
$dbObject = new database($host,$user,$passwd);
$dbObject->dbSelect($db);
$dbObject->executeSql($sql);
$res = $dbObject->returnResults();
while($record = mysql_fetch_array($res))
{
echo "Screen Name: " . $record["ScreenName"] ." Password : " . $record["Password"] ."<br/>";
}
?>
Bookmarks