env-justin Posted January 22, 2008 Share Posted January 22, 2008 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(); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/87156-solved-oop-query-problem/ Share on other sites More sharing options...
eZe616 Posted January 22, 2008 Share Posted January 22, 2008 function runQuery($query) { $result = mysql_query($query); return $result; } Quote Link to comment https://forums.phpfreaks.com/topic/87156-solved-oop-query-problem/#findComment-445856 Share on other sites More sharing options...
env-justin Posted January 22, 2008 Author Share Posted January 22, 2008 wow I could of swore i had that there in the beginning. thanks. Quote Link to comment https://forums.phpfreaks.com/topic/87156-solved-oop-query-problem/#findComment-446247 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.