Yes, Jason. I posted it earlier, but here it is again.
// Error I'm getting
Error in query: SELECT label FROM menu WHERE id = 3
Warning: Supplied argument is not a valid MySQL result resource in
e:\localhost\menu\menu.class.php on line 47
// Object being called from get.php
<?php
require("menu.class.php");
$obj = new Menu();
echo $obj->get_label(1);
?>
// Class in the file menu.class.php
class Menu {
var $hostname;
var $user;
var $pass;
var $db;
var $table;
function Menu() {
$this->set_database_parameters("localhost", "username",
"password", "apps", "menu");
}
function set_database_parameters($hostname, $user, $password, $db,
$table) {
$this->hostname = $hostname;
$this->user = $user;
$this->password = $password;
$this->db = $db;
$this->table = $table;
}
function query($query) {
$connection = mysql_connect($this->hostname, $this->user,
$this->pass) or die ("Cannot connect to database");
$ret = mysql _query($this->db, $query, $connection) or die ("Error
in query: $query");
return $ret;
}
function get_label($id) {
$query = "SELECT label FROM $this->table WHERE id = $id";
$result = $this->query($query);
$row = mysql_fetch_row($result);
return $row[0];
}
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php