syntax 에러.. 채택완료
질문내용
현재의 카테고리 네비게이션을 만들려고 하는데, syntax 에러가 뜨네요.
ca_id 값이 안들어온 것도 같고...
에러내용
select ca_name from g5_shop_4_category where ca_id = and ca_use = 1
1064 : 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 'and ca_use = 1' at line 1
error file : /project/koteka_4/shop/item.php
코드
</p><p><?php
if ($ca_id) {
$navigation = $bar = "";
$len = strlen($ca_id);
for ($i=1; $i<=$len; $i++)
{
if ($it['ca_name'] == "MEN") {
$code = "10";
}
if ($it['ca_name'] == "WOMEN") {
$code = "11";
}</p><p> $sql = " select ca_name from {$g5['g5_shop_category_table']} where ca_id = $code and ca_use = 1";
$row = sql_fetch($sql);
}
for ($s=1; $s<=$len; $s++)
{
if ($it['ca_name'] == "SUB1") {
$code1 = $code."11";
}
else if ($it['ca_name'] == "SUB2") {
$code1 = $code."12";
}
else if ($it['ca_name'] == "SUB3") {
$code1 = $code."13";
}
else if ($it['ca_name'] == "SUB4") {
$code1 = $code."14";
} </p><p> $sql1 = " select ca_name from {$g5['g5_shop_category_table']} where ca_id = $code1 and ca_use = 1 ";
$row1 = sql_fetch($sql1);
}
for ($j=1; $j<=$len; $j++)
{
if (($it['ca_name']) == "SUB_SUB1") {
$code2 = $code."1111";
}
else if (($it['ca_name']) == "SUB_SUB2") {
$code2 = $code."1212";
}
else if (($it['ca_name']) == "SUB_SUB3") {
$code2 = $code."1313";
}
else if (($it['ca_name']) == "SUB_SUB4") {
$code2 = $code."1414";
} </p><p> $sql2 = " select ca_name from {$g5['g5_shop_category_table']} where ca_id = $code2 and ca_use = 1 ";
$row2 = sql_fetch($sql2);
}
$navigation .= $bar.'<a href="/project/koteka_4/">HOME</a> > ';
if ($code) {
$navigation .= $bar.' <a href="./list_'.$code.'.php?ca_id='.$code.'">'.$row['ca_name'].'</a> > ';
}
if ($code1) {
$navigation .= $bar.' <a href="./list_'.$code1.'.php?ca_id='.$code1.'">'.$row1['ca_name'].'</a> > ';
}
if ($code2) {
$navigation .= $bar.' <a href="./list_'.$code2.'.php?ca_id='.$code2.'">'.$row2['ca_name'].'</a> > ';
}
}</p><p>if ($it_id) $navigation .= " > $it[it_name]";
?></p><p>
답변 2개
select ca_name from g5_shop_4_category where ca_id = and ca_use = 1
ca_id 부분에 찾고자 하는 값이 없어서 에러가 나옵니다.
$sql = " select ca_name from {$g5['g5_shop_category_table']} where ca_id = '{$code}' and ca_use = 1";
위와 같이 수정하셔서 $code 변수에 값이 없어도 에러가 안나오게 하면 됩니다.
또는
if(!$code) exit("parameter error");
변수 체크하는 조건문을 쿼리문 앞단에 두어
에러처리를 하셔도 됩니다.
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인