2014-07-17 91 views
0

我下載了這個網站目錄,當我跑了,我收到以下錯誤:致命錯誤:未捕獲的異常「PDOException」

錯誤 致命錯誤:有消息未捕獲的異常'PDOException「SQLSTATE [42S02 ]:基表或視圖未找到:1146表 'u471047401_test.Categories' 不存在」在/home/u471047401/public_html/inc/blocks/sidebar.php:13堆棧跟蹤:#0 /家/ u471047401 /的public_html/inc/blocks/sidebar.php(13):PDOStatement-> execute(Array)#1 /home/u471047401/public_html/index.php(6):require('/ home/u47104740 ...')#2 {main }拋出/home/u471047401/public_html/inc/blocks/sidebar.php上線13

<? 
$cat = $_GET['cat']; 
if(empty($cat)) 
{ 
    $cat = 0; 
} 
$menu_query = (" 
    SELECT cat_id, cat_name, parent_cat 
    FROM Categories 
    WHERE (cat_id = ? OR parent_cat = ?)"); 

$stm = $conn->prepare($menu_query); 
$stm->execute(array($cat, $cat)); 
("u471047401_test.Categories"); 
$categories = $stm->fetchAll(); 

?> 
<div class='col-4 col-lg-4 ' style='padding-left:0;'> 
    <ul class="nav nav-pills nav-stacked well;"> 
<? 
foreach($categories as $categories_row) 
{ 
    $act = $categories_row['cat_id'] == $cat ? 'active' : ''; 
    echo" 
    <li class={$act}> 
     <a href='category.php?cat={$categories_row['cat_id']}'> 
     {$categories_row['cat_name']} 
     </a> 
     </li>"; 

    if($categories_row['cat_id'] == $cat && $categories_row['cat_id'] > 0) 
    { 
    $back_link = "<li><a href=``'category.php?cat={$categories_row['parent_cat']}' title='Go back to previous category'>Back</a></li>"; 
    } 
} 
?> 
    <?= $back_link ?> 
    </ul> 
</div> 

是什麼原因造成這個錯誤?

+1

刪除其涵蓋了單引號的關鍵字「從」 –

回答

3

各地FROM

SELECT cat_id, cat_name, parent_cat FROM Categories 
            ^----^-----here 

刪除引號如果你把引號它,然後數據庫引擎將處理這是靜態的字符串,而不是作爲查詢

+0

:(我來晚了......; P –

+0

現在我得到這個錯誤 – user3850847

+1

不要錯誤信息添加到其他用戶的帖子 –

相關問題