I have my php class:
<?php
class Service {
private $servicio;
private $db;
private $procesos;
public function __construct() {
//$this->servicio = array();
$this->procesos = array();
$this->$db = new mysqli("localhost", "root", "", "prospera");
}
private function setNames() {
return $this->db->query("SET nombre 'utf8'");
}
public function getServicios() {
self::setNames();
$sql = "SELECT id, nombre, precio FROM tbproducto";
foreach ($this->db->query($sql) as $res) {
$this->servicio[] = $res;
}
return $this->servicio;
$this->db = null;
}
public function setServicio($nombre, $precio) {
self::setNames();
$sql = "INSERT INTO tbproducto(nombre, precio) VALUES ('" . $nombre . "', '" . $precio . "')";
$result = $this->db->query($sql);
if ($result) {
return true;
} else {
return false;
}
}
public function getListaProcesos(){
$sql = "SELECT DISTINCT proceso2 FROM tbuniverso WHERE proceso2 LIKE '%B2_18'";
foreach ($this->db->query($sql) as $res ) {
$this->procesos[] = $res;
}
return $this->procesos;
$this->db = null;
}
}
?>
this class is where I get the data from the DB, to fill a drop-down list, this class communicates with another class that I use as a controller:
<?php
require ("modelo.php");
require_once ("../index.php");
$services = new Service();
$datos = $services->getListaProcesos();
?>
The problem is that when I run the page where my form sends me this error php: Parse error: syntax error, unexpected '' (T_STRING), expect function (T_FUNCTION) or const (T_CONST) in C: \ wamp64 \ www \ webprueba \ php \ modelo.php on line 2
What I understand is that you expect a parameter but I'm not sure, if you could guide me in this matter, thank you.