嘿,伙计们是php开发的新手,我见过类似的代码
$link = mysql_connect('localhost', 'root', 'root');
if ($link) {
die('cannot connect:'.mysql_error());
}
mysql_select_db("chat", $link);
if ($SERVER['REQUEST_METHOD'] == 'POST') {
$message = $_POST['message'];
mysql_query("INSERT INTO posts (message) VALUES ('$message')");
}
$query = mysql_query('SELECT * FROM posts ORDER BY id DESC');
enter code here
while ($row = mysql_fetch_object($query)) {
$posts[] = array(
'message' => $row -> message
);
}
我搞不清$row->message
是什么意思??。。与$row['message']
相同吗。。
希望你们能帮忙谢谢
您可以获取数组/对象的mysql_query结果通知
对于您可以使用的阵列,mysql_fetch_array((;http://www.php.net/manual/en/function.mysql-fetch-array.php
对于可以使用的对象,mysql_fetch_object((;http://www.php.net/manual/en/function.mysql-fetch-object.php
此外,mysql现在已从PHP中删除。所以你可以使用PDO/Mysqli
http://in1.php.net/manual/en/book.pdo.php