我曾经使用过不好的例子,但自从我切换后我解决了它。
解决了我的问题。坏的例子:
$currentdj = "SELECT username FROM djsays WHERE current = '1'";
$result = mysql_query($currentdj);
while($dj = mysql_fetch_row($result))
echo $dj;
?>
使用好:
$mysqli = new mysqli('hostname','user','password','databasename');
if (!$mysqli) {
// connect failure, check connect_error()
echo $mysqli->connect_error();
}
else {
// Call query() to execute your SQL
$result = $mysqli->query("SELECT * FROM some_table");
if ($result) {
// $result is an object of type mysqli_result
// Call fetch_assoc() on $result
while ($row = $result->fetch_assoc())
echo $row['id'];
}
}
?>