我使用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,但错误仍然存在 –