-2

重複の可能性:
mysql_fetch_array() は、パラメーター 1 がリソースであると想定しており、select でブール値が指定されています

私のSQLクエリは以下です。ローカル ホストでは問題なく動作しますが、Linux サーバーにアップロードすると上記のエラーが発生します。なにが問題ですか?

これは私のローカル ホストでは機能するのに、なぜ私のサーバーでは機能しないのでしょうか? ファイルパスエラーですか?MySQL データベースは同一で、ローカル ホストとは異なる、サーバー用の特定の接続ファイルがあります。私の他のデータベースクエリは機能しています。

$id 変数の問題ではありません。変数を 1 に置き換えてテストしようとしたのですが、エラー メッセージは同じでした。

データベースへの接続の問題でもありません。このファイルには、正しく機能している他の多くのクエリが含まれています。

    return (mysql_result(mysql_query("SELECT COUNT('id') FROM POSTS WHERE id=$id"),0)==0)?false:true;// this query works. because it doesnt have '' on the words posts/id
4

2 に答える 2

1

エラーチェックは素晴らしいことです:

function getResult() 
{
   try {
      $q = mysql_query( ... );

      if ($q === FALSE)
         throw new Exception(mysql_error(), mysql_errno());

      // Do stuff with the query results here.
   } catch(Exception $e) {
      // Do the error handling here
      //   Message is kept in $e->getMessage();
      //   MySQL specific error code is in $e->getCode();
   }
}
于 2012-04-18T01:16:51.057 に答える
0

The Solution to this was that the query was searching the POST table. instead of the post table.

the table name is apparently case sensitive on my server, but not case sensitive on localhost.

于 2012-04-18T09:31:25.873 に答える