mysql_fetch_array():提供的参数不是有效的MySQL

时间:2011-05-24 03:40:38

标签: php mysql sql

$idc = $_GET['id'];
$name1 = $_GET['name'];
$id2 = $_GET['ids'];
$toplinks = "";

if (isset($_SESSION['category_id'])) {
    // Put stored session variables into local php variable
    $userid = $_SESSION['id'];
    $username = $_SESSION['name'];

}
$sql_2 = mysql_query("SELECT * FROM blabbing WHERE mem_id='$userid' OR men_id='$idc' ORDER BY blab_date DESC LIMIT 20")

while($row = mysql_fetch_array($sql_2)){
    }

2 个答案:

答案 0 :(得分:4)

我认为您的查询中存在错误...您引用了mem_id然后是OR men_id

尝试将or die ( mysql_error () );添加到mysql_query行。

$sql_2 = mysql_query("SELECT * FROM blabbing WHERE mem_id='$userid' OR mem_id='$idc' ORDER BY blab_date DESC LIMIT 20") or die ( mysql_error () );

答案 1 :(得分:1)

你先mysql_connect了吗?