Answer the question
In order to leave comments, you need to log in
Why does mysqli_query() get NULL as first parameter?
database.php :
$ip = "127.0.0.1";
$user = "root";
$password = "";
$db = "crm";
$connection = mysqli_connect($id, $user, $password, $db);
global $connection;
if ($connection == false) {
echo "Произошла ошибка";
}
include "database.php";
function saveOrder (){
mysqli_query($connection, "UPDATE `orders` `order_status`=".$_POST['orderStatus'].",`customer_surname`=".$_POST['customerSurname'].",`customer_name`=".$_POST['customerName'].",`customer_patronymic`=".$_POST['customerPatronymic'].",`email`=".$_POST['email'].",`phone_number`=".$_POST['phoneNumber'].",`second_phone_number`=".$_POST['secondPhoneNumber'].",`address`=".$_POST['address']." WHERE `order_number`=".$order_number);
mysqli_query($connection, "UPDATE `order_items` SET `item1` = ".$_POST['vendorCode'][0].", `item2` = ".$_POST['vendorCode'][1].", `item3` = ".$_POST['vendorCode'][2].", `item4` = ".$_POST['vendorCode'][3].", `item5` = ".$_POST['vendorCode'][4].", `item6` = ".$_POST['vendorCode'][5].", `item7` = ".$_POST['vendorCode'][6].", `item8` = ".$_POST['vendorCode'][7].", `item9` = ".$_POST['vendorCode'][8].", `item10` = ".$_POST['vendorCode'][9].", `item11` = ".$_POST['vendorCode'][10].", `item12` = ".$_POST['vendorCode'][11].", `item13` = ".$_POST['vendorCode'][12].", `item14` = ".$_POST['vendorCode'][13].", `item15` = ".$_POST['vendorCode'][14].", `item16` = ".$_POST['vendorCode'][15].", `item17` = ".$_POST['vendorCode'][16].", `item18` = ".$_POST['vendorCode'][17].", `item19` = ".$_POST['vendorCode'][18].", `item20` = ".$_POST['vendorCode'][19]." WHERE `order_items`.`order_number` =".$order_number);
}
saveOrder();
Answer the question
In order to leave comments, you need to log in
Global $connection; - in your function
It's better not to write like that, get bogged down in functionality and a mess of global variables
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question