0
你好,我使用PDO第1次和得到錯誤上午......不不到哪我錯了,這裏是我的代碼PDO誤差函數
function student_one_image($student_id){
$DBH = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
$STH = $DBH->query("SELECT * from school_students, school_student_one_image where (school_student_one_image.student_id = school_students.student_id)
and school_student_one_image.student_id = '$student_id'");
$STH->setFetchMode(PDO::FETCH_ASSOC);
$row = $STH->fetch();
return $row
錯誤是無法通過套接字連接到本地MySQL服務器' /var/lib/mysql/mysql.sock
,如果我使用MySQL的嘗試它的工作
function student_one_image($student_id){
$data= mysql_query("SELECT * from school_students, school_student_one_image where (school_student_one_image.student_id = school_students.student_id)
and school_student_one_image.student_id = '$student_id'");
$result = mysql_fetch_array($data);
return $result;
請幫助
你有沒有輸出你的'$ host','$ dbname','$ user'和'$ pass'變量的值是否在函數內?這可能是他們是空的 – Laimoncijus
是的,我已經嘗試了兩種方式....直接也(用戶名和通行證),但仍然無法正常工作 – Harinder