Topic: Insert query help needed

Hey,

Ive made this query to add the uploaded file information into the database:

$db->query('INSERT INTO ebookbooks (link, desc, uploaded_by, date_uploaded) VALUES('.$f_name.','.$f_desc.','.$user['username'].','.date("Y-m-j").')') or error('Unable to add ebook to database', __FILE__, __LINE__, $db->error());

The variables are defined here:

$f_desc = $_POST['desc'];
$f_name = $_FILES['file']['name'];

and here are the table structures:

     id          tinyint(3)   auto_increment
    name     varchar(80)         
    link        varchar(90)         
    desc       blob     BINARY     No             
    category     varchar(30)         
    uploaded_by     varchar(50)         
    date_uploaded     date         No     0000-00-00

Just need a second eye to look at it because it keeps returning the error when query is run. Might be just some silly mistake that I cant see but maybe someone else can.

Thanks in advance

Re: Insert query help needed

whats the error? most times that helps sort out the problem.

Re: Insert query help needed

The one that comes up if the query is not successful:

or error('Unable to add ebook to database', __FILE__, __LINE__, $db->error());

Re: Insert query help needed

Well, strings should be between single quotes when entering into the DB, like this:

$db->query("INSERT INTO ebookbooks (`link`, `desc`, `uploaded_by`, `date_uploaded`) VALUES('".$f_name."','".$f_desc."','".$user['username']."','".date("Y-m-j")."')") or error('Unable to add ebook to database", __FILE__, __LINE__, $db->error());

Re: Insert query help needed

Thanks alot again elbekko, fixed