我使用Dreamweaver生成連接到數據庫的PHP和SQLi代碼。這是我已經成功完成,但我不斷收到以下錯誤:如何使用Dreamweaver中的PHP和MySQLi將網頁連接到數據庫
Warning: mysqli_select_db() expects parameter 1 to be mysqli, string given in C:\wamp\www\Maseno\Site\Template.php on line 32
Warning: mysqli_query() expects parameter 1 to be mysqli, string given in C:\wamp\www\Maseno\Site\Template.php on line 34
Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\wamp\www\Maseno\Site\Template.php on line 34,
這裏是我的源代碼:
<?php require_once('../../Connections/connect.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "",
$theNotDefinedValue = "") {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ?
mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysqli_select_db($database_connect, $connect);
$query_Users = "SELECT * FROM students";
$Users = mysqli_query($query_Users, $connect) or die(mysqli_error());
$row_Users = mysqli_fetch_assoc($Users);
$totalRows_Users = mysqli_num_rows($Users);
?>
感謝您的協助Frankbeen,但我已經在另一個文件中完成了這項工作,我在這裏調用,就像我在任何其他文件中完成的那樣構成網站的一部分。 –
我也試過並改爲mysqli,但錯誤仍然存在 –