Page 1 of 1

Fatal error: Uncaught Error: Class 'mysql_error' not found in

Posted: Mon Jul 20, 2020 1:20 pm
by sabrina
Fatal error: Uncaught Error: Class 'mysql_error' not found in C:\wamp64\www\chocorangups\afterupdate.php on line 34

echo "Query Failed: " . new mysql_error(); <---- line 34

Re: i keep gets this error,can you help me please. Tq

Posted: Mon Jul 20, 2020 1:23 pm
by shah.nawaraj.forum
Also post your source code

Re: i keep gets this error,can you help me please. Tq

Posted: Mon Jul 20, 2020 1:56 pm
by sabrina
<?php

$servername = "localhost:3308";
$username = "root";
$password = "";
$dbname = "chocorangups";

// Create Connection
$conn = new mysqli ($servername, $username, $password, $dbname);
// Check Connection
if ($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}

//Arahan SQL (Structure Query Language)

//$ContohSQL = "DELETE FROM tbl_choco WHERE cust_address = '".$_REQUEST['txtModfield2']."' ";

//Arahan SQL (Structure Query Language)

//$ContohSQL = "UPDATE tbl_choco SET cust_name = 'Mohd Ali', cust_address = 'kota bharu' WHERE cust_id = '1' ";

$ContohSQL = "UPDATE tbl_choco SET cust_name = '".isset($_POST['txtModfield1'])."',cust_address = '".isset($_POST['txtModfield2'])."', phone_num = '".isset($_POST['txtModfield3'])."', type = '".isset($_POST['txtModfield4'])."', quantity= '".isset($_POST['txtModfield5'])."', WHERE cust_id = '".$_GET['custid']."' ";


//Dapatkan hasil pencarian
$hasilQuery = $conn->query($ContohSQL);
echo "Data sudah di update";
//Mengesahkan query
if(!$hasilQuery)
{
//Amaran jika gagal
echo "Query Failed: " . mysql_error();
exit;
}

?>

Re: i keep gets this error,can you help me please. Tq

Posted: Tue Jul 21, 2020 6:00 am
by shah.nawaraj.forum
This may be happen because of mix matching the code.
https://www.w3schools.com/php/func_mysqli_error.asp