You are here: Help with PHP Class connection « PHP Programming Language « IT news, forums, messages
Help with PHP Class connection

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация