ch1326 Posted April 14, 2010 Share Posted April 14, 2010 Hi everyone I need help with my "public fetch()", which is not working. seem to be something wrong with arrays Here is the code <?php class MYSQL { private $user = "root"; private $pass = "password"; private $host = "localhost"; private $db = "userlist"; public function __construct(){ $this->user; $this->pass; $this->host; $this->db; $this->connDB(); } private function connDB(){ $conn = mysql_connect($this->host, $this->user, $this->pass); if (!$conn){ print(mysql_error()); echo "<BR/> <BR/> Please check your login again. <BR /><BR />"; }else{ return mysql_select_db($this->db, $conn); } } public function fetch($tName){ $sql = "select * from $tName"; $result = mysql_query($sql); return mysql_fetch_array($result); } public function addData($tName, $field, $val){ $sql = "insert into $tName ($field) values ($val)"; return mysql_query($sql); } } ?> Thank again for the help Link to comment https://forums.phpfreaks.com/topic/198497-need-help-with-my-public-fetch/ Share on other sites More sharing options...
Ken2k7 Posted April 14, 2010 Share Posted April 14, 2010 What's the exact error message? I can't see anything wrong with it, but you probably didn't check if $result contains anything before calling mysql_fetch_array(). Link to comment https://forums.phpfreaks.com/topic/198497-need-help-with-my-public-fetch/#findComment-1041619 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.