Hi everyone,
I have the error
Fatal error : Uncaught PDOException: SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected in /opt/lampp/htdocs/yonetimpaneli_phptr/class/VT.php:34 Stack trace: #0 /opt/lampp/htdocs/yonetimpaneli_phptr/class/VT.php(34): PDOStatement->execute(Array) #1 /opt/lampp/htdocs/yonetimpaneli_phptr/data/baglanti.php(5): VT->VeriGetir('ayarlar', 'WHERE ID=?', Array, 'ORDER BY ID ASC', 1) #2 /opt/lampp/htdocs/yonetimpaneli_phptr/index.php(13): include_once('/opt/lampp/htdo...') #3 {main} thrown in **/opt/lampp/htdocs/yonetimpaneli_phptr/class/VT.php** on line **34**".
Anyone help!!!
<?php
class VT{
var $sunucu="localhost";
var $user="root";
var $password="";
var $dbname="yonetimpaneli_phptr";
var $baglanti;
function __construct()
{
try{
$this->baglanti=new PDO("mysql:host".$this->sunucu.";dbname=".$this->dbname.";charset=utf8",$this->user,$this->password);
}catch(PDOException $e){
echo $e->getMessage();
exit();
}
}
/* SELECT * FROM ayarlar WHERE ID=1 ORDER BY ID ASC LIMIT 1*/
public function VeriGetir($tablo,$wherealanlar="",$wherearraydeger="",$orderby="ORDER BY ID ASC",$limit="")
{
$this->baglanti->query("SET CHARACTER SET utf8");
$sql="SELECT * FROM ".$tablo; /*SELECT * FROM ayarlar*/
if(!empty($wherealanlar) && !empty($wherearraydeger)){
$sql.=" ".$wherealanlar; /*SELECT * FROM ayarlar*/
if(!empty($orderby)){$sql.=" ".$orderby;}
if(!empty($limit)){$sql.=" LIMIT ".$limit;}
$calistir=$this->baglanti->prepare($sql);
$sonuc=$calistir->execute($wherearraydeger);
$veri=$calistir->fetchAll(PDO::FETCH_ASSOC);
}else{
if(!empty($orderby)){$sql.=" ".$orderby;}
if(!empty($limit)){$sql.=" LIMIT ".$limit;}
$veri=$calistir->fetchAll(PDO::FETCH_ASSOC);
}
if($veri!=false && !empty($veri)){
$datalar= array();
foreach($veri as $bilgiler){
$datalar[]=$bilgiler; /*$sonuc[0]["baslik]*/
}
return $datalar;
}else{
return false;
}
}
}
?>