Item not added to cart. Where is the error?

Hello! Item not added to cart. Where is the error?

config.inc.php
<?php

 /* Basic settings */

define(DB_HOST, "localhost"); 
define(DB_LOGIN, "root");
define(DB_PASSWORD, "12345");
define(DB_NAME, "eshop");
define ('ORDERS_LOG, "orders.log"); 
$basket = []; // create an empty array to store the user's trash
$count = 0; // to store the number of items in the cart user
$link = mysqli_connect(DB_HOST, DB_LOGIN, DB_PASSWORD, DB_NAME); // DB connection and selection of database 

// Monitor error in database connection
if( !$link){
 echo 'Error: '
 . mysqli_connect_errno()
 . ': '
 . mysqli_connect_error();
}


 /* / Basic settings */</code-->
br><br><b>lib.inc.php</b><br><pre><code class="php"><?php // filter taken from the form data (in argument comes in the date/number). function clearInt($data){ return abs((int)$data); } // filter taken from the form data (in argument comes in the date/number). function clearStr($data){ global $link; // DB connection set to "config.inc.php" return mysqli_real_escape_string($link, trim(strip_tags($data))); } // function saves a new item in the table catalog: addItemToCatalog function ($title, $autor, $bubyear, $price) { global $link;// DB connection set to "config.inc.php" $sql = "INSERT INTO catalog (title, autor, pubyear, price) VALUES (?, ?, ?, ?)"; // a request to insert data into a table catalog (title... - fields table) // execute a query to insert Dunne: if (!$stmt = mysqli_prepare($link, $sql)) { return false; // if the function addItemToCatalog not worked // msqli_prepare() - here's the query, the prepare, it will go critical // the $stmt object will come or false } else { mysqli_stmt_bind_param($stmt, "ssii", $title, $autor, $pubyear, $price); // bind variables to parameters of a prepared statement ($stmt - someone to pass parameters, "ssii" - options what type: str/int) mysqli_stmt_execute($stmt); // now, fill the prepared query with the given parameters mysqli_stmt_close($stmt); return true; } }</code--></code></pre><code class="php"><br><br><b>save2cat.php</b><br><pre><code class="php"><?php // include libraries require "secure/session.inc.php"; require "../inc/lib.inc.php"; require "../inc/config.inc.php"; // Get and filter the data from the form: $title = clearStr($_POST['title']); $autor = clearStr($_POST['autor']); $pubyear = clearInt($_POST['pubyear']); $price = clearInt($_POST['price']); // Call the function addItemToCatalogдля save the new item in the database: if(!addItemToCatalog($title, $author, $pubyear, $price)){ echo 'an error Occurred while adding product to your catalog'; } else { header("Location: add2cat.php"); // redirect (redirect) to "add2cat.php" exit; }</code--></code></pre></code>
June 14th 19 at 20:51
1 answer
June 14th 19 at 20:53
addItemToCatalog function ($title, $autor, $bubyear, $price)
mysqli_stmt_bind_param($stmt, "ssii", $title, $autor, $pubyear, $price);
You need to add? - claude_Walter12 commented on June 14th 19 at 20:56

Find more questions by tags PHP