|
Posted by vncntj on 07/08/07 19:15
I keep getting a:
mysql_fetch_array(): supplied argument is not a valid MySQL...
this is my class connection
<?php
class cDatabase {
//class variables defined in constructor
var $host;
var $user;
var $password;
var $databaseName;
//constructor - needed for connection string
function cDatabase($hostName, $userName, $passwordName,
$databaseName){
$this->host = $hostName;
$this->user = $userName;
$this->password = $passwordName;
$this->database = $databaseName;
}
//execute a query
function ExecuteNonQuery($sql){
$conn = mysql_connect($this->host, $this->user, $this->password);
mysql_select_db ($this->database);
$rs = @mysql_query($sql);
settype($rs, "null");
mysql_close($conn);
}
}
?>
and this is the page
<?php
include "dbclass.php";
$cDB = new cDatabase(host, user, password, database);
// test select query
$rs = $cDB->ExecuteNonQuery("Select event from na_events");
while ($row = mysql_fetch_array($rs, MYSQL_ASSOC)) {
echo $row['event'];
}
// kill our objects
settype($rs, "null");
settype($cDB, "null");
?>
Thanks,
Navigation:
[Reply to this message]
|