hi to all m new to OOP PHP. i have following piece of code here in the following:
test.php
<?php
class test
{
private $dbhost;
private $dbname;
private $user;
private $pass;
public function __construct()
{
$this->dbhost = 'localhost';
$this->dbname = 'XXXX';
$this->user = 'root';
$this->pass = '';
}
public function open($obj)
{
$con = mysql_connect($this->dbhost,$this->user,$this->pass) or die(mysql_error());
$db = mysql_select_db($this->dbname)or die(mysql_error());
$query = mysql_query("SELECT * FROM '".$obj."'") or die(mysql_error());
}
}
?>
in the other file named test2.php i have the following piece of code:
<?php
require_once('testClass.php');
$obj = new test();
$obj2 = 'user';
$obj->open($obj2);
?>
and i got the following error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''user'' at line 1
thnx in advance for help