Jump to content

Need help with my public fetch()


ch1326

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.