Jump to content

Recommended Posts

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();

 

}

}

 

?>

Link to comment
https://forums.phpfreaks.com/topic/87156-solved-oop-query-problem/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.