I had this working earlier but had to tweak the code for some function that will be preformed later on but now I can't get the data to upload to the SQL server. I get error:

PDOStatement::errorInfo(): Array ( [0] => 42000 [1] => 1064 [2] => You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'all, fillmore, johnson, otoe, richardson, seward, butler, gage, lancaster, pawne' at line 1 )

My PHP is: http://pastebin.com/QA5KFGQ5
My HTML is: http://pastebin.com/3nXsdfWU

I am not sure if it is just because when you do not check a check box it sends over nothing so certain variables have nothing to grab and it is therefore messing up the statement, I am not sure if I manually have to check if the Input for the Checkboxes is a certain value and if not set it to nothing or something along those lines, any help.

Recommended Answers

All 3 Replies

All is a mysql reserved word. If you need to use it because you have a column called all, you need to place it in quotes inside your query: 'all'

Ok that worked but now I get BHV cannot be Null and I never check it, in my code where it says:

$bhv = filter_input(INPUT_POST, 'bhv', FILTER_SANITIZE_STRING);

do I need to add

$bhv = filter_input(INPUT_POST, 'bhv', FILTER_SANITIZE_STRING);
if ($bhv == ""){
    $bhv="";
}

and do this as a check for each checkbox to fix the problem?

Yeah, you'll need to provide default values. Create a function that accepts the parameter, does the input_filter bit and either returns its value or an empty string. Then you can call that function instead of filter_input for each variable.
That'll get rid of the endless if's you were probably thinking of adding.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.