Im retrieving this error.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\cvc\classLibrary\UserLogin.php on line 14
When I place the while loop into the runQuery() method it works as planned so I know it is connecting to the database properly. Any suggestions?
Thanks!
<?php
class mysqlConnect
{
private $host;
private $conn_user;
private $conn_pass;
private $database;
function connect()
{
require_once('************');
$connection = mysql_connect($this->host, $this->conn_user, $this->conn_pass);
$dbSelect = mysql_select_db("cvc", $connection);
if (!$connection)
{
die('Could not connect: ' . mysql_error());
}
if (!$dbSelect)
{
die ('Can\'t use selected database : ' . mysql_error());
}
}
function runQuery($query)
{
$result = mysql_query($query);
}
}
?>
<?php
class userLogin
{
function __construct($username, $password)
{
require('classLibrary/MysqlConnect.php');
$mysqlConnect = new mysqlConnect;
$conn = $mysqlConnect->connect();
$result = $mysqlConnect->runQuery("SELECT username, password, level FROM employees WHERE username='$username'");
while ($row = mysql_fetch_array($result))
{
echo $row[0] . $row[1];
}
$mysqlConnect->close();
}
}
?>