我正在使用Dreamweaver来生成用于连接到数据库的PHP和SQLi代码。我已经成功地做到了这一点,但是我不断地得到以下错误:
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);
?>发布于 2015-06-07 12:16:26
您正在使用mysql_和mysqli_ 函数。您应该只使用mysqli或PDO。
mysql_函数已不再推荐使用.
mysqli_函数与mysql_函数有些不同。大多数时候,您需要添加一个额外的参数:连接资源。
例如:
$link = mysqli_connect("localhost", "my_user", "my_password", "my_database");
mysqli_query($link, "SHOW TABLES");只需用google "php “查找有关特定函数的信息。
https://stackoverflow.com/questions/30692522
复制相似问题