i cant seem function enter data database , return product_id. when try returning product_id returns 0 along nothing entered database
php function:
function product_id(){ $id_data = "insert `products` (`product_id`, `date_created`) values('', now())"; mysqli_query(database(), $id_data); return $product_id = mysqli_insert_id(database()); }
mysql
create table products( product_id int unsigned not null auto_increment, date_created datetime not null, primary key (product_id) );
here how call function in php
$product_id = product_id();
since cannot insert auto_increment
field remove insert statement , should work.
function product_id(){ $id_data = "insert `products` (`date_created`) values( now())"; mysqli_query(database(), $id_data); return $product_id = mysqli_insert_id(database()); }
also getting mysqli
error in future try using mysqli_error()
function
Comments
Post a Comment