$ result = mysql_query($ strSQL);不工作

时间:2016-01-23 11:55:05

标签: php mysql wordpress

我有一个由查询组成的页面模板(WordPress),并显示查询的输出。它已停止工作。在phpMyAdmin中查询确实有效。

$strSQL = "SELECT xgqq_cimy_uef_data.ID, xgqq_cimy_uef_data.USER_ID, xgqq_cimy_uef_data.FIELD_ID AS UserID, xgqq_cimy_uef_data.VALUE AS Phone, xgqq_usermeta.user_id AS TheID, xgqq_usermeta.meta_key, xgqq_usermeta.meta_value AS FirstNameField, xgqq_usermeta_1.umeta_id AS LastNameID, xgqq_usermeta_1.meta_key, xgqq_usermeta_1.meta_value AS LastNameField, xgqq_users.user_email FROM ((xgqq_cimy_uef_data INNER JOIN xgqq_users ON xgqq_cimy_uef_data.USER_ID = xgqq_users.ID) INNER JOIN xgqq_usermeta ON xgqq_users.ID = xgqq_usermeta.user_id) INNER JOIN xgqq_usermeta AS xgqq_usermeta_1 ON xgqq_usermeta.user_id = xgqq_usermeta_1.user_id WHERE (((xgqq_cimy_uef_data.USER_ID)<>1) AND ((xgqq_cimy_uef_data.FIELD_ID)=4) AND ((xgqq_usermeta.meta_key)='first_name') AND ((xgqq_usermeta_1.meta_key)='last_name')) ORDER BY xgqq_usermeta_1.meta_value";

   $result = mysql_query($strSQL);

      while ($row = mysql_fetch_assoc($result)) {

         $firstname = $row['FirstNameField'];
         $lastname = $row['LastNameField'];
         $email = $row['user_email'];
         $phone = $row['Phone'];
         $profile = $row['USER_ID'];

         //Outputs results into a table
         echo'   <tr>
                    <td>' . $firstname .' ' . $lastname .'</td>
                    <td><a href="mailto:' . $email.'">' . $email.'</a></td>
                    <td>' . $phone .'</td>
                    <td><a href="?profile_id='. $profile .'">View Profile</a></td>
               </tr>';
      }

当我打开错误报告时,它指向

$result = mysql_query($strSQL);

是问题所在。我不太确定要改变什么,尽管在这里和其他地方尝试过建议,但它不起作用。

1 个答案:

答案 0 :(得分:0)

您的查询应该有效,如果它不起作用,我猜的唯一原因是您使用的是最新版本的PHP,而Mysql在最新版本的PHP中被折旧。