Ok guys, I need help with this one. I am getting the error: Error in
query: SELECT label FROM menu WHERE id = '1'. Why am I getting this
error? It seems right to me. I have the following code to call the class
object, and I listed the class below it (I'm fairly new to classes):


// 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_db_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];
   }
}


Thanks to anyone, in advance, that can help me with this one.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to