Jump to content

schubertgergo

New Members
  • Posts

    5
  • Joined

  • Last visited

schubertgergo's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Sorry not working... i changed: <?php class DataBase { private $con; private $host; private $user; private $password; private $dataBase; private $queryString; private $result; private $row; function __construct() { $this->host = 'localhost'; $this->user = 'root'; $this->password = ''; $this->dataBase = 'importtable'; $this->con = new mysqli($this->host, $this->user, $this->password, $this->dataBase); } function connectionString() { if ($this->con->error) { echo "Sikertelen adatbázis kapcsolódás"; die(); } } function selectUser($query){ $this->queryString=mysqli_real_escape_string($this->con,$query); $this->result=$this->con->query($this->queryString); $this->row=$this->result->fetch_assoc(); echo $this->row['id']; } } class showUser extends DataBase { private $userId; function __construct($id) { $this->userId = $id; } function showData() { if(filter_var($this->userId)){ $q = "select * from user where id=" . $this->userId; $this->selectUser($q); } else{ } } } $o= new showUser(1); $o->showData(); ?> now i have this messages: Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\import_\dbconn.php on line 32 Fatal error: Call to a member function query() on a non-object in C:\xampp\htdocs\import_\dbconn.php on line 33
  2. mysqli has fetch_asssoc. i use mysqli connection not mysql connection
  3. thank you, but i still have a problem with the query. Fatal error: Call to a member function fetch_assoc() on a non-object in C:\xampp\htdocs\import_\dbconn.php on line 50 here is the code: <?php class DBCon { private $con; private $host; private $user; private $password; private $dataBase; function __construct() { $this->host = 'localhost'; $this->user = 'root'; $this->password = ''; $this->dataBase = 'importtable'; } function connectionString() { $this->con = new mysqli($this->host, $this->user, $this->password, $this->dataBase); if ($this->con->error) { echo "Sikertelen adatbázis kapcsolódás"; die(); } else { return $this->con; } } } class showUser extends DBCon { private $userId; function __construct($id) { $this->userId = $id; } function showData() { $q = "select * from user where id=" . $this->userId; $r = $this->connectionString()->query($q); while ($row = $r->fetch_assoc()) { echo $row['name']; } } } $o=new showUser(1); $o->showData(); ?>
  4. hi, here is my code: class DBCon{ private $con; private $host; private $user; private $password; private $dataBase; function __construct(){ $this->host = 'localhost'; $this->user = 'root'; $this->password = ''; $this->dataBase = 'import'; $this->con = new mysqli($this->host, $this->user,$this->password, $this->dataBase); } function connectionString(){ if($this->con->error){ echo "Sikertelen adatbázis kapcsolódás"; die(); } else{ return $this->con; } } } class showUser{ private userId; function __construct($id){ $this->userId=$id; } function showData(){ $q="select * from user where id=".$this->id; $r=$con->query($q); while($row=$r->fetch_assoc()){ echo $row['name']; } } } I dont know how to add the $con value to showuser class, and make the showdata() function work. Thank you for your help.
  5. Hi! The user upload a csv file to the server. next time he want to upload another csv file. if we have collisoin on the rows, have to ask the user to delete it or insert a new record. then we have to make the changes. Our question is: when we save the file only the changes will be saved in the server, or the whole file will be saved by the php? Thank you
×
×
  • 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.