Insert

Closed
Advanced Security - PHP Register/Login System Advanced Security - PHP Register/Login System April 28, 2018
Login to reply
Milos Stojanovic Support Agent
7 months ago
Closed due to inactivity.
Milos Stojanovic Support Agent
7 months ago

Hey Rene,

Ok, no problem. You should remove the "id" field from the array if it is autoincrement.

I've never had this situation with the ASDatabase class and your code seems fine, so I guess that it is something specific to your setup or the data you are trying to insert. I would recommend you to enable the debug mode like it is explained inside the docs and to see if there are any errors returned by MySQL. If there are errors you will know what's wrong and how to fix it then.

rene Licona
7 months ago

Thanks, sorry about the lack of format.

It was just for testing purposes, the id should be auto increment.

Thanks.

Rene

Milos Stojanovic Support Agent
7 months ago

Hey,

Is there a reason why you are setting the id to 0 while you are building the query?

Btw, I've updated your ticket to actually wrap the code within a code tag. You can do that by selecting the code you want to wrap and then click on the magic wand icon inside the editor toolbar and select code. :) It improves readability a bit.

rene Licona
7 months ago

Hello,

Let me begging by saying I am no coding expert.

I have this old query:

if ($category == "Disbursement" )
{ $query_image = "INSERT INTO $tbl_name(id, amount, date, description, category, path, name) VALUES ('', '$amount', '$date', '$description', '$category', '$uploadfile','$fileName')"; 
I have replaced it with the new query:
if ($category == "Disbursement" ) {
$db->insert('wf', array(
    "id" => 0,
    "amount" => $amount,
    "date" => $date,
    "description" => $description,
    "category" => $category,
    "path" => $uploadfile,
    "name" => $fileName 
));


Upon submission the code is inserting a blank row. Hence I am not carrying my data from the posted form.

Can you help me with the right syntax?

 Thank you.