简体   繁体   中英

MySQL syntax error, for no apparent reason

I have this MySQL statement writen in PHP, but it seems to contain a syntax-error.

$user_forum_sql = ( !empty($forum_id) ) ? " WHERE session_page = " . intval($forum_id) : '';
    $sql = "SELECT * FROM " . $session_table_name . '"'.$user_forum_sql.'"';

This is the error I'm having. I'm not sure what is causing it.

SQL Error : 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 '""' at line 1

SELECT * FROM ""
$user_forum_sql = ( !empty($forum_id) ) ? " WHERE session_page = " . intval($forum_id) .'' ;
$sql = "SELECT * FROM " . $session_table_name.$user_forum_sql;
echo $sql;

Your $session_table_name is empty, so you might have not started your session or have not set the value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM