我在运行项目时遇到了此错误

时间:2018-11-16 13:26:13

标签: php mysql

  

“致命错误:未捕获错误:调用未定义函数   C:\ laragon \ www \ farmer \ config \ config.php:3中的mysql_connect()   跟踪:#0 C:\ laragon \ www \ farmer \ Execute \ ExLogin.php(6):include()#1   {main}在第3行的C:\ laragon \ www \ farmer \ config \ config.php中抛出“

这是config.php

<?php
mysql_connect("localhost", "root", "newton2010") or die(mysql_error());
mysql_select_db("farmer") or die(mysql_error());
?>

<?Php

//session_start();
$dbhost_name = "localhost";
$database = "farmer";// database name
$username = "root"; // user name
$password = "newton2010"; // password 

//////// Do not Edit below /////////
try {
$dbo = new PDO('mysql:host=localhost;dbname='.$database, $username, $password);
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}

?>

这是我的Exlogin.php

    <?php
// Start the session
session_start();


include '../config/config.php';
include '../config/config1.php';
include '../config/connect.php';

 $UName = ($_POST["Username"]);
 $PW = ($_POST["Password"]);
  $status = "Accepted";
 $PassWord=0;
 $UserName=0;

$quer= mysql_query("SELECT * FROM customers where username='$UName' AND password='$PW' ");
while($ss = mysql_fetch_array($quer))
    {
    $UserName=$ss['username'];
    $PassWord=$ss['password'];
    $userid=$ss['customerid'];
    $name=$ss['firstnames'];
    $activate=$ss['status'];
    //$profilepicture=$ss['profilepicture'];
    //$IDBranch=$ss['IDBranch'];
    $role=$ss['role'];
    }

if($PassWord!=$PW || $UserName!=$UName || $activate!=$status ){
echo "<script>alert('You account is disabled or You have entered Incorrect UserName or Password')</script>";
echo "<script>location.href='../index.php'</script>";
}
else
{
$_SESSION["Id"]=$userid;
$_SESSION["name"]=$name;
//$_SESSION["profilepicture"]=$profilepicture;
//$_SESSION["IDBranch"]=$IDBranch;
$_SESSION["role"]=$role;

?>

<!--<script>
var person = prompt("Please enter your name", "Harry Potter");
if (person != null) {
    document.getElementById("demo").innerHTML =
    "Hello " + person + "! How are you today?";
}
</script>-->
<script>location.href='../dashboard.php'</script>"; --> 

<?php } ?>

1 个答案:

答案 0 :(得分:0)

我使用@sadikhasan提出的关于使用fix.mysql.inc.php的建议

然后我遇到了这个新错误“解析错误:语法错误,意外的'<',期望第4行的C:\ laragon \ www \ farmer \ config \ config.php中的文件结束”

这是我更新的config.php

    <?php
include_once('fix_mysql.inc.php');

<?php
mysql_connect("localhost", "root", "newton2010") or die(mysql_error());
mysql_select_db("farmer") or die(mysql_error());
?>

<?Php

//session_start();
$dbhost_name = "localhost";
$database = "farmer";// database name
$username = "root"; // user name
$password = "newton2010"; // password 

//////// Do not Edit below /////////
try {
$dbo = new PDO('mysql:host=localhost;dbname='.$database, $username, $password);
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}

?>