我正在尝试在实时服务器上执行以下操作,但它不会执行。在当地主机上一切都很好。我能够在实时服务器上执行其他sop>
$mysqli = new mysqli("localhost", "username", "password", "database");
if(isset($_POST['username'])&& isset($_POST['password']) ){
$username =$_POST['username'];
$password = md5($_POST['password']);
if ($mysqli) {
/* Prepared statement, stage 1: prepare */
if (!($stmt = $mysqli->prepare("select acc.accountId, acc.firstname, prof.imagename from accounts acc inner join profilepicture prof on prof.accountId=acc.accountId where acc.emailAddress=(?) and acc.password=(?)"))) {
echo "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
}
/* Prepared statement, stage 2: bind and execute */
$stmt->bind_param("ss", $username,$password);
$stmt->execute();
$result = $stmt->get_result();
$row = $result->fetch_assoc();
if(!empty($row)){
`enter code here`
`enter code here`// STATEMENTS TO EXECUTE IF DETAILS EXISTS
}
答案 0 :(得分:0)
这可能是原因:您正在登录没有默认数据库,没有用户名和密码的mysql
$mysqli = new mysqli("localhost", "", "", "");
应该是这样的:
$mysqli = new mysqli("localhost", "user", "password", "database");
阅读此http://php.net/manual/en/mysqli.quickstart.connections.php
答案 1 :(得分:0)
在实时服务器或cpanel中..转到mysql部分创建数据库和用户及密码...并授予该用户编辑更新和删除的权限..然后在
$ mysqli = new mysqli(" localhost","","","");
添加所有三个用户名密码和数据库名称..然后..它将正常工作.. 希望它有效