thanks for replay akhileshbc
yes, it returns false, but why does it return false while I have tested the sql statement at phpMyAdmin and it works !!!
here is my code :
PHP Code:
<?php
class myClass
{
public $dbh;
public function __construct()
{
$this->dbh = new PDO('mysql:host=localhost;rdisast_db', 'rdisast_user', '$+f~65G@e');
}
public function getFieldData($tableName, $fieldNumber, $value, $columnName)
{
$sth = $this->dbh->query("SELECT * FROM `$tableName` WHERE `$columnName`='$value'");
$fetch = $sth->fetch();
return $fetch[$fieldNumber];
}
public function preLang($httpReferer)
{
$l = '';
$explodedReferer = explode('/',$httpReferer);
$c = count($explodedReferer);
for ($i = 0; $i < $c; $i++) {
if ($explodedReferer[$i] == 'du' || $explodedReferer[$i] == 'en') {
$l = $explodedReferer[$i];
break;
}
}
if ($l == '') {
$l = $this->getFieldData('settings','dl','1','id');
}
return $l;
}
}
$obj = new myClass;
if (!$_GET['lang']) {
$language = $obj->preLang($_SERVER['HTTP_REFERER']);
} else {
$language = $_GET['lang'];
}
if ($language == 'du') {
$lKey = 2;
} else {
$lKey = 1;
}
$tr = array();
$gT = $obj->dbh->query('SELECT * FROM `translate`');
while($t = $gT->fetch()) {
$tr[$t['code']] = $t['word'.$lKey];
}
?>
the first execution of a sql statemnt is in getFieldData() function, and when I debricated it, the error become at the line of while loop "while($t = $gT->fetch()) "
I think the problem in in db connection, but I am sure of the username and password, and permissions for this user