Ashraf Kamarudin Ashraf Kamarudin - 5 months ago 9
MySQL Question

my INSERT query not working

i dont know why but these values are not going into my database.these is my code.

<?php
define('INCLUDE_CHECK',true);

require '../database/connect.php';

session_name('user');
session_set_cookie_params(2*7*24*60*60);
session_start();

if(isset($_POST['submit']) && $_POST['submit']=='Submit')
{

$stdID='CC13051';
$itemCODE='00';
$pckgeID='1';
$condition='qwe';
$duration='5';
$status='Not Approved';

mysqli_query($link," INSERT INTO storage_details(stdID,itemCODE,pckgeID,cndition,duration,status)
VALUES(

'$stdID',
'$itemCODE',
'$pckgeID',
'$condition',
'$duration',
'$status',

)");
if (mysql_errno()) {
die('Invalid query: ' . mysql_error());
}

}
?>


mysql_err didnt give out anything.or am i using it in the wrong way?

Answer

i forgot to remove the comma after $status. thanks to @Tobias Baumeister for pointing it out.

mysqli_query($link,"    INSERT INTO storage_details(stdID,itemCODE,pckgeID,cndition,duration,status)
    VALUES(

           '$stdID',
           '$itemCODE',
           '$pckgeID',
           '$condition',
           '$duration',
           '$status', <-- this comma should not be here

           )");