0
votes

I was working on my XAMPP local server and coding php using netbeans, the below code was working fine.

 $sql = "INSERT INTO enneagram (name,course,activity,type,Peacemaker,Loyalist,Achiever,Reformer,Individualist,Helper,Challenger,Investigator,Enthusiast,Instinctive,Feeling,Thinking,Assertive,Dutiful,Withdrawn) VALUES ('$answerdata[0]','$answerdata[1]','$answerdata[2]','$mytypes',$A,$B,$C,$D,$E,$F,$G,$H,$I,$instinctive,$feeling,$thinking,$assetive,$dutiful,$withdrawn)";

I uploaded the file on online server and now it is giving me this error

'Connection failed: SQLSTATE[42000]: Syntax error or access violation: 1064 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 \'. VALUES (\'Karim Bahsoun\',\'communication\',\'activity\',\'|Loyalist|Individualis\' at line 1'

it's my third day looking at the code and not realizing why it worked offline and not online.

1

1 Answers

0
votes

There is a . after Withdrawn) which should not be there.

Also note that using POST data directly into your SQL leaves you wide open to SQL injections. You should really use a prepared statement