您好,我第一次使用 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
错误是 Can't connect to local MySQL server through socket '/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;
请帮忙