0
我正在製作一個私人消息系統。我的表單正確發佈到我的表,但返回查詢拉怪的東西。我有點新加入的表...JOIN查詢返回100450(inetuser)
PHP代碼SQL查詢:
function fetch_messages() {
$sql = "SELECT
`conversations`.`con_id`,
`conversations`.`con_subject`,
MAX(`conversations_messages`.`message_date`) AS `con_last_reply`
FROM `conversations`
LEFT JOIN `conversations_messages` ON `conversations`.`con_id` = `conversations_messages`.`con_id`
INNER JOIN `conversations_members` ON `conversations`.`con_id` = `conversations_members`.`con_id`
WHERE `conversations_members`.`user_id` = 31
AND `conversations_members`.`con_deleted` = 0
GROUP BY `conversations`.`con_id`
ORDER BY `con_last_reply` DESC";
$result = mysql_query($sql);
$conversations = array();
while (($row = mysql_fetch_assoc($result)) !== false) {
$conversations[] = array(
`id` => $row['con_id'],
`subject` => $row['con_subject'],
`con_last_reply` => $row['last_reply']
);
}
return $conversations;
}
返回數組:
Array ([0] => Array (
[uid=8927072(user007) gid=100450(inetuser) groups=100450(inetuser) ] => 1
[] =>))
(這幾乎就像它的返回我的FTP信息user007是我打開的ftp連接名稱,但這不是表格中的內容!!)
您的數組輸出與您的代碼根本不匹配。你確定你正在傾倒正確的數組嗎?此外,mysql_函數已被棄用,並替換爲mysqli_(或者您可以使用PDO) – datasage
我同意,您的代碼無法創建該數組。它沒有'id','subject'和'con_last_reply'鍵。相反,它有一些看起來像Unix'id'命令的輸出作爲鍵。 – Barmar
@datasage是的我正在傾銷「print_r(fetch_messages());」是的,我知道這就是爲什麼它很奇怪...是的,我知道mysql_functions已經失效,我還沒有切換。 – hobbywebsite