post 글 입력시 테이블 이 존재하지 않습니다

post 글 입력시 테이블 이 존재하지 않습니다

QA

post 글 입력시 테이블 이 존재하지 않습니다

본문

테이블명이 g5_write_z1  입니다

아래처럼 지정하면 되는거 같은데.....
실행을 하면 존재하지 않는 게시판이 아니라고 나오네요 ㅠㅠ

 

 

//게시판 테이블 정보
    $bo_table = $newpost[g5_write_z1];
    if(!strlen($bo_table)) return FALSE; //bo_table 값이 지정되지 않았습니다.
    $board = sql_fetch(" select * from {$g5['board_table']} where bo_table = '$bo_table' ");
    if(!$board) return FALSE; //bo_table이 존재하지 않습니다.
    
    //회원정보 및 권한 확인
    $member = get_member($newpost[mb_id]);
    if(!$member) return FALSE; //mb_id가 존재하지 않습니다.
    //if($board[bo_write_level] > $member[mb_level]) return FALSE; //글쓰기 권한이 없습니다.
    
 

이 질문에 댓글 쓰기 :

답변 5

1. var_dump($board); 삭제
2. $bo_table = 'z1'; => $bo_table = $new_post['bo_table']; 로 변경
   (하단에 $newpost 에서 bo_table 값을 입력하기 때문에 함수내에서 적을 필요는 없습니다)
3. mysql_insert_id => sql_insert_id 로 교체
   (버전따라 다르기 때문에 그누보드 내장 함수로 교체)

감사합니다.. 오류없이 저장이 잘 되네요.~~~

하나만 더 여쭤볼께요..
php 에서 post 로 변수값을 전달해서 게시판 테이블에 저장을 하면 게시판 리스트에서도 정상적으로 표시되고.. view 화면에도 잘 들어가집니다..
하지만  리스트화면에서  검색필드에 검색어 입력후 검색을 하면 검색이 되어 지질 않는 문제가 있어서

위 방법으로 게시글을 작성해보면 검색이 될까 해서 해보는건데
위 방법으로 게시판에 글이 작성되어도 
검색 필드에서 검색으로 하면 검색이 안되네요

검색이 되도록 하려면 어떻게 해야 할까요??

var_dump($board); 찍어보세요.

값을 잘못지정한거같네여

위 테이블명일때 아래의 어느 부분을 수정해야 하나요??
맨 아래부분에만 입력을 했는데도 안되네요 ㅠㅠㅠ


function insert_write($newpost)
{
global $g5;

//게시판 테이블 정보
$bo_table = $newpost[bo_table];
if(!strlen($bo_table)) return FALSE; //bo_table 값이 지정되지 않았습니다.
$board = sql_fetch(" select * from {$g5['board_table']} where bo_table = '$bo_table' ");
if(!$board) return FALSE; //bo_table이 존재하지 않습니다.


var_dump($board);

//회원정보 및 권한 확인
    $member = get_member($newpost[mb_id]);
    if(!$member) return FALSE; //mb_id가 존재하지 않습니다.
    //if($board[bo_write_level] > $member[mb_level]) return FALSE; //글쓰기 권한이 없습니다.

//카테고리 설정
    $ca_name = $newpost[ca_name];
if ($ca_name && strpos($board[bo_category_list], $ca_name) === FALSE){
$category_list = $board[bo_category_list]."|".$ca_name;
$sql = " update {$g5['board_table']} set bo_category_list = '$category_list' where bo_table = '$bo_table' ";
sql_query($sql);
}

//변수 정리
    $write_table = $g5[write_prefix].$bo_table;
    $wr_num = get_next_num($write_table);
    $ca_name = addslashes($ca_name);
    $html = "html1";
    $secret = "";
    $mail = "";
    $wr_subject = addslashes(trim($newpost[wr_subject]));
    $wr_content = addslashes(trim($newpost[wr_content]));
    if(!$wr_subject) return FALSE; //글 제목이 없습니다.
    if(!$wr_content) return FALSE; //글 내용이 없습니다.
    $mb_id = $member[mb_id];
    $wr_password = $member[mb_password];
    $wr_name = $board[bo_use_name] ? $member[mb_name] : $member[mb_nick];
$wr_email = $member[mb_email];
$wr_homepage = $member[mb_homepage];
    for($i=1; $i<=10; $i++){
        $wr = "wr_{$i}";
        ${$wr} = addslashes($newpost[$wr]);
    }
    $wr_link1 = $newpost[wr_link1];
    $wr_link2 = $newpost[wr_link2];

//글 입력하기
$sql = " insert into $write_table
                set wr_num = '$wr_num',
                    wr_reply = '',
                    wr_comment = 0,
                    ca_name = '$ca_name',
                    wr_option = '$html,$secret,$mail',
                    wr_subject = '$wr_subject',
                    wr_content = '$wr_content',
                    wr_link1 = '$wr_link1',
                    wr_link2 = '$wr_link2',
                    wr_link1_hit = 0,
                    wr_link2_hit = 0,
                    wr_hit = 0,
                    wr_good = 0,
                    wr_nogood = 0,
                    mb_id = '$mb_id',
                    wr_password = '$wr_password',
                    wr_name = '$wr_name',
                    wr_email = '$wr_email',
                    wr_homepage = '$wr_homepage',
                    wr_datetime = '".G5_TIME_YMDHIS."',
                    wr_last = '".G5_TIME_YMDHIS."',
                    wr_ip = '{$_SERVER['REMOTE_ADDR']}',
                    wr_1 = '$wr_1',
                    wr_2 = '$wr_2',
                    wr_3 = '$wr_3',
                    wr_4 = '$wr_4',
                    wr_5 = '$wr_5',
                    wr_6 = '$wr_6',
                    wr_7 = '$wr_7',
                    wr_8 = '$wr_8',
                    wr_9 = '$wr_9',
                    wr_10 = '$wr_10' ";
    sql_query($sql);
   
    $wr_id = mysql_insert_id();

    sql_query(" update $write_table set wr_parent = '$wr_id' where wr_id = '$wr_id' "); //부모 아이디에 UPDATE
sql_query(" insert into {$g5['board_new_table']} ( bo_table, wr_id, wr_parent, bn_datetime, mb_id ) values ( '{$bo_table}', '{$wr_id}', '{$wr_id}', '".G5_TIME_YMDHIS."', '$mb_id' ) "); //새글 INSERT   
    sql_query(" update {$g5['board_table']} set bo_count_write = bo_count_write + 1 where bo_table = '{$bo_table}' "); //게시글 1 증가

return array('bo_table' => $bo_table, 'wr_id' => $wr_id, 'sca' => $ca_name);
//return TRUE;

}


//$newpost[mb_id], $newpost[bo_table], $newpost[wr_subject], $newpost[wr_content] 값만 지정하고,
//insert_write($newpost); 라고 실행시키면 글이 해당 게시판에 올라갑니다.

$newpost = array(
'mb_id' => 'admin',
'bo_table' => 'g5_write_z1',
'wr_subject' => G5_TIME_YMDHIS.' - 자동등록글',
'wr_content' => "<span style='font-size:14pt;'>이 글은 자동으로 등록되었습니다.</span>"
);

$result = insert_write($newpost);

$newpost['bo_table'] = 'g5_write_z1';
 

//게시판 테이블 정보
$bo_table = $newpost[bo_table] = 'g5_write_z1';
if(!strlen($bo_table)) return FALSE; //bo_table 값이 지정되지 않았습니다.
$board = sql_fetch(" select * from {$g5['board_table']} where bo_table = '$bo_table' ");
if(!$board) return FALSE; //bo_table이 존재하지 않습니다.

이렇게 바꾸라는 거죠?  변경후
      http://host/post.php

싱행해봐도  게시판에 글이 등록 안됩니다..

 $bo_table = $newpost[g5_write_z1];

 $bo_table = "z1";

으로 변경해보세요

 

왜냐면 하단에 

g5_write 를 조하는

$write_table = $g5[write_prefix].$bo_table; 

가 있고, 

$write_table로 insert문을 실행합니다.

 

지금같은 방식으로 호출하면 

테이블이

g5_write_g5_write_z1 

이될겁니다.

 

 

 

말씀해주신 대로 해봣는데요..
에러메세지가 이렇게 뜹니다..

array(94) { ["bo_table"]=> string(2) "z1" ["gr_id"]=> string(4) "qqqq" ["bo_subject"]=> string(20) "고객 위치 확인" ["bo_mobile_subject"]=> string(0) "" ["bo_device"]=> string(4) "both" ["bo_admin"]=> string(0) "" ["bo_list_level"]=> string(1) "1" ["bo_read_level"]=> string(1) "1" ["bo_write_level"]=> string(1) "1" ["bo_reply_level"]=> string(1) "1" ["bo_comment_level"]=> string(1) "1" ["bo_upload_level"]=> string(1) "1" ["bo_download_level"]=> string(1) "1" ["bo_html_level"]=> string(1) "1" ["bo_link_level"]=> string(1) "1" ["bo_count_delete"]=> string(1) "1" ["bo_count_modify"]=> string(1) "1" ["bo_read_point"]=> string(1) "0" ["bo_write_point"]=> string(1) "0" ["bo_comment_point"]=> string(1) "0" ["bo_download_point"]=> string(1) "0" ["bo_use_category"]=> string(1) "0" ["bo_category_list"]=> string(0) "" ["bo_use_sideview"]=> string(1) "0" ["bo_use_file_content"]=> string(1) "0" ["bo_use_secret"]=> string(1) "0" ["bo_use_dhtml_editor"]=> string(1) "0" ["bo_use_rss_view"]=> string(1) "0" ["bo_use_good"]=> string(1) "0" ["bo_use_nogood"]=> string(1) "0" ["bo_use_name"]=> string(1) "1" ["bo_use_signature"]=> string(1) "0" ["bo_use_ip_view"]=> string(1) "0" ["bo_use_list_view"]=> string(1) "0" ["bo_use_list_file"]=> string(1) "0" ["bo_use_list_content"]=> string(1) "0" ["bo_table_width"]=> string(3) "100" ["bo_subject_len"]=> string(2) "60" ["bo_mobile_subject_len"]=> string(2) "30" ["bo_page_rows"]=> string(1) "5" ["bo_mobile_page_rows"]=> string(1) "3" ["bo_new"]=> string(2) "24" ["bo_hot"]=> string(3) "100" ["bo_image_width"]=> string(3) "600" ["bo_skin"]=> string(11) "theme/basic" ["bo_mobile_skin"]=> string(12) "nmv3ymmap100" ["bo_include_head"]=> string(0) "" ["bo_include_tail"]=> string(0) "" ["bo_content_head"]=> string(0) "" ["bo_mobile_content_head"]=> string(0) "" ["bo_content_tail"]=> string(0) "" ["bo_mobile_content_tail"]=> string(0) "" ["bo_insert_content"]=> string(0) "" ["bo_gallery_cols"]=> string(1) "4" ["bo_gallery_width"]=> string(3) "174" ["bo_gallery_height"]=> string(3) "124" ["bo_mobile_gallery_width"]=> string(3) "125" ["bo_mobile_gallery_height"]=> string(3) "100" ["bo_upload_size"]=> string(7) "1048576" ["bo_reply_order"]=> string(1) "1" ["bo_use_search"]=> string(1) "1" ["bo_order"]=> string(1) "0" ["bo_count_write"]=> string(2) "14" ["bo_count_comment"]=> string(1) "0" ["bo_write_min"]=> string(1) "0" ["bo_write_max"]=> string(1) "0" ["bo_comment_min"]=> string(1) "0" ["bo_comment_max"]=> string(1) "0" ["bo_notice"]=> string(0) "" ["bo_upload_count"]=> string(1) "2" ["bo_use_email"]=> string(1) "0" ["bo_use_cert"]=> string(0) "" ["bo_use_sns"]=> string(1) "0" ["bo_sort_field"]=> string(0) "" ["bo_1_subj"]=> string(0) "" ["bo_2_subj"]=> string(0) "" ["bo_3_subj"]=> string(0) "" ["bo_4_subj"]=> string(0) "" ["bo_5_subj"]=> string(0) "" ["bo_6_subj"]=> string(0) "" ["bo_7_subj"]=> string(0) "" ["bo_8_subj"]=> string(0) "" ["bo_9_subj"]=> string(0) "" ["bo_10_subj"]=> string(0) "" ["bo_1"]=> string(0) "" ["bo_2"]=> string(0) "" ["bo_3"]=> string(0) "" ["bo_4"]=> string(0) "" ["bo_5"]=> string(0) "" ["bo_6"]=> string(0) "" ["bo_7"]=> string(0) "" ["bo_8"]=> string(0) "" ["bo_9"]=> string(0) "" ["bo_10"]=> string(0) "" }
Warning: mysql_insert_id(): Access denied for user 'sun7684'@'localhost' (using password: NO) in /host/home1/sun7684/html/post.php on line 94

Warning: mysql_insert_id(): A link to the server could not be established in /host/home1/sun7684/html/post.php on line 94

94번째 줄은    $wr_id = mysql_insert_id();  이부분 입니다


아래는 적용했떤 전체 소스 입니다

<?php
define('_INDEX_', true);
include_once('./_common.php');


//ver1.0 150414 @_untitle_d


function insert_write($newpost)
{
global $g5;

//게시판 테이블 정보
$bo_table =  "z1";
if(!strlen($bo_table)) return FALSE; //bo_table 값이 지정되지 않았습니다.
$board = sql_fetch(" select * from {$g5['board_table']} where bo_table = '$bo_table' ");
if(!$board) return FALSE; //bo_table이 존재하지 않습니다.


var_dump($board);

//회원정보 및 권한 확인
    $member = get_member($newpost[mb_id]);
    if(!$member) return FALSE; //mb_id가 존재하지 않습니다.
    //if($board[bo_write_level] > $member[mb_level]) return FALSE; //글쓰기 권한이 없습니다.

//카테고리 설정
    $ca_name = $newpost[ca_name];
if ($ca_name && strpos($board[bo_category_list], $ca_name) === FALSE){
$category_list = $board[bo_category_list]."|".$ca_name;
$sql = " update {$g5['board_table']} set bo_category_list = '$category_list' where bo_table = '$bo_table' ";
sql_query($sql);
}

//변수 정리
    $write_table = $g5[write_prefix].$bo_table;
    $wr_num = get_next_num($write_table);
    $ca_name = addslashes($ca_name);
    $html = "html1";
    $secret = "";
    $mail = "";
    $wr_subject = addslashes(trim($newpost[wr_subject]));
    $wr_content = addslashes(trim($newpost[wr_content]));
    if(!$wr_subject) return FALSE; //글 제목이 없습니다.
    if(!$wr_content) return FALSE; //글 내용이 없습니다.
    $mb_id = $member[mb_id];
    $wr_password = $member[mb_password];
    $wr_name = $board[bo_use_name] ? $member[mb_name] : $member[mb_nick];
$wr_email = $member[mb_email];
$wr_homepage = $member[mb_homepage];
    for($i=1; $i<=10; $i++){
        $wr = "wr_{$i}";
        ${$wr} = addslashes($newpost[$wr]);
    }
    $wr_link1 = $newpost[wr_link1];
    $wr_link2 = $newpost[wr_link2];

//글 입력하기
$sql = " insert into $write_table
                set wr_num = '$wr_num',
                    wr_reply = '',
                    wr_comment = 0,
                    ca_name = '$ca_name',
                    wr_option = '$html,$secret,$mail',
                    wr_subject = '$wr_subject',
                    wr_content = '$wr_content',
                    wr_link1 = '$wr_link1',
                    wr_link2 = '$wr_link2',
                    wr_link1_hit = 0,
                    wr_link2_hit = 0,
                    wr_hit = 0,
                    wr_good = 0,
                    wr_nogood = 0,
                    mb_id = '$mb_id',
                    wr_password = '$wr_password',
                    wr_name = '$wr_name',
                    wr_email = '$wr_email',
                    wr_homepage = '$wr_homepage',
                    wr_datetime = '".G5_TIME_YMDHIS."',
                    wr_last = '".G5_TIME_YMDHIS."',
                    wr_ip = '{$_SERVER['REMOTE_ADDR']}',
                    wr_1 = '$wr_1',
                    wr_2 = '$wr_2',
                    wr_3 = '$wr_3',
                    wr_4 = '$wr_4',
                    wr_5 = '$wr_5',
                    wr_6 = '$wr_6',
                    wr_7 = '$wr_7',
                    wr_8 = '$wr_8',
                    wr_9 = '$wr_9',
                    wr_10 = '$wr_10' ";
    sql_query($sql);
   
    $wr_id = mysql_insert_id();

    sql_query(" update $write_table set wr_parent = '$wr_id' where wr_id = '$wr_id' "); //부모 아이디에 UPDATE
sql_query(" insert into {$g5['board_new_table']} ( bo_table, wr_id, wr_parent, bn_datetime, mb_id ) values ( '{$bo_table}', '{$wr_id}', '{$wr_id}', '".G5_TIME_YMDHIS."', '$mb_id' ) "); //새글 INSERT   
    sql_query(" update {$g5['board_table']} set bo_count_write = bo_count_write + 1 where bo_table = '{$bo_table}' "); //게시글 1 증가

return array('bo_table' => $bo_table, 'wr_id' => $wr_id, 'sca' => $ca_name);
//return TRUE;

}


//$newpost[mb_id], $newpost[bo_table], $newpost[wr_subject], $newpost[wr_content] 값만 지정하고,
//insert_write($newpost); 라고 실행시키면 글이 해당 게시판에 올라갑니다.

$newpost = array(
'mb_id' => 'admin',
'bo_table' => 'z1',
'wr_subject' => G5_TIME_YMDHIS.' - 자동등록글',
'wr_content' => "<span style='font-size:14pt;'>이 글은 자동으로 등록되었습니다.</span>"
);

$result = insert_write($newpost);

?>

<a href="<?=G5_BBS_URL?>/board.php?bo_table=<?=$result[bo_table]?>&wr_id=<?=$result[wr_id]?>&sca=<?=$result[sca]?>">결과보기</a>

에러메세지를 보시면

Warning: mysql_insert_id(): Access denied for user 'sun7684'@'localhost' (using password: NO) in /host/home1/sun7684/html/post.php on line 94 

Warning: mysql_insert_id(): A link to the server could not be established in /host/home1/sun7684/html/post.php on line 94 

94번째 줄은    $wr_id = mysql_insert_id();  이부분 입니다 

여기인데

 

일단, 

// var_dump($board); 

로 막으시고


    $wr_id = mysql_insert_id(); 

 

여기서 에러가 또 나오시면

sql_query($sql); 

Echo $sql."<br/>";   // 이걸 추가하셔서

    $wr_id = mysql_insert_id(); 

 

화면상에서 해당쿼리를 긁어서 직접 수행시켜보세요

 

답변을 작성하시기 전에 로그인 해주세요.
전체 123,497 | RSS
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT