SQL 구문에 오류가 있습니다워드 프레스 데이터베이스 - 내가 다음 코드 한
<?php
$exists_photos = $wpdb->get_results("SELECT * FROM $dsp_galleries_photos galleries, $dsp_user_albums_table albums WHERE galleries.album_id=albums.album_id AND galleries.status_id=1 AND galleries.album_id IN ($ids1) ORDER BY RAND() LIMIT 6");
$i=0;
foreach ($exists_photos as $user_photos) {
$photo_id=$user_photos->gal_photo_id;
$album_id1=$user_photos->album_id;
$file_name=$user_photos->image_name;
$private=$user_photos->private_album;
$image_path="/wp-content/uploads/dsp_media/user_photos/user_".$member_id."/album_".$album_id1."/".$file_name;
if(($i%3)==0){
?>
하면 그것은 오류 다음 반환 :
WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 for query SELECT COUNT(*) FROM wp_dsp_galleries_photos WHERE status_id=1 AND album_id IN() made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/ArtSee/page.php'), the_content, apply_filters('the_content'), call_user_func_array, do_shortcode, preg_replace_callback, do_shortcode_tag, call_user_func, wp_include_file, include('/plugins/dsp/profile_header.php'), include('/plugins/dsp/member_dsp_header.php'), include('/plugins/dsp/headers/view_profile_header.php'), include('/plugins/dsp/view_profile_setup.php')
제안을 이해할 수있을 것이다. 감사합니다
이들은 PHP 변수입니다. 오류를 보면 SQL이 실행되기 전에 테이블 이름이 올바른 것으로 변환 된 것을 볼 수 있습니다. 즉, 'wp_dsp_galleries_photos'. 오류가있는 곳이 아닙니다. –
나는 항상 $ 기호를 테이블 이름에서 벗어나서 SELECT * FROM'$ dsp_galleries_photos' 갤러리와 같은 것이거나 포스터 부분에 오타가 있어야한다고 가르쳤다. 내 실수는 – bhttoan
또한 코드 게시 실제로 테이블 이름을 뛰어 올라 또 다른 이유가있는 오류에 표시된 코드를 포함하지 않습니다 – bhttoan