0

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.

2
Contributors
3
Replies
28
Views
3 Years
Discussion Span
Last Post by hericles
2

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'

0

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?

Edited by toxicandy

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.