Zadejte hledaný výraz...

Call to undefined function mysql_connect()

matusy
verified
rating uzivatele
(14 hodnocení)
1. 12. 2019 15:32:41
Zdravím,
vedel by ma niekto približne nasmerovať kde môže byť chyba?
Na index.php mi vyhadzuje chybu:
Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:xampphtdocsconnection.php:2 Stack trace: #0 C:xampphtdocsindex.php(2): include_once() #1 {main} thrown in C:xampphtdocsconnection.php on line 2
insert.php funguje. Zapíše do db to čo má.
Pripojenie je ale napísané ako "mysqli", kdežto v connection.php zase "mysql"
Tak som skúsil v connection namiesto mysql_select_db použiť mysqli_connect(), ale vyhodilo tú istú chybu.
connection.php
mysql_connect('localhost','root','');
mysql_select_db('youtube');
?>
insert.php
$username = $_POST;
$password = $_POST;
$gender = $_POST;
$email = $_POST;
$phoneCode = $_POST;
$phone = $_POST;
if (!empty($username) || !empty($password) || !empty($gender) || !empty($email) || !empty($phoneCode) || !empty($phone)) {
$host = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbname = "youtube";
//create connection
$conn = new mysqli($host, $dbUsername, $dbPassword, $dbname);
if (mysqli_connect_error()) {
die('Connect Error('. mysqli_connect_errno().')'. mysqli_connect_error());
} else {
$SELECT = "SELECT email From register Where email = ? Limit 1";
$INSERT = "INSERT Into register (username, password, gender, email, phoneCode, phone) values(?, ?, ?, ?, ?, ?)";
//Prepare statement
$stmt = $conn->prepare($SELECT);
$stmt->bind_param("s", $email);
$stmt->execute();
$stmt->bind_result($email);
$stmt->store_result();
$rnum = $stmt->num_rows;
if ($rnum==0) {
$stmt->close();
$stmt = $conn->prepare($INSERT);
$stmt->bind_param("ssssii", $username, $password, $gender, $email, $phoneCode, $phone);
$stmt->execute();
echo "New record inserted sucessfully";
} else {
echo "Someone already register using this email";
}
$stmt->close();
$conn->close();
}
} else {
echo "All field are required";
die();
}
?>
index.php
1. 12. 2019 15:32:41
https://webtrh.cz/diskuse/call-to-undefined-function-mysql_connect#reply1426657
ne
verified
rating uzivatele
(22 hodnocení)
1. 12. 2019 15:39:46
mysql_ je od PHP 5.5 deprecated a od 7 uz neexistuje..
mysqli_ sa pouziva trocha inak..
takze bud vratit spat na starsiu verziu PHP, alebo prepisat
1. 12. 2019 15:39:46
https://webtrh.cz/diskuse/call-to-undefined-function-mysql_connect#reply1426656
matusy
verified
rating uzivatele
(14 hodnocení)
1. 12. 2019 15:45:16
Vďaka moc :)
1. 12. 2019 15:45:16
https://webtrh.cz/diskuse/call-to-undefined-function-mysql_connect#reply1426655
Pro odpověď se přihlašte.
Přihlásit