Strange Syntax Error MySQL Error when using PHP -
i've got syntax error near line 1 somewhere in code:
//... $nr = 126; $expl = "'test'"; $da = "'2003-12-01'"; $tax = 2.5; $cost = 100; //here error $sql = "insert tbl (type, nr, explan, date, tax, cost) values('example'," + $nr + ",'"+ $expl + "','" + $da + "'," + $tax + "," + $cost + ");";
this error log:
error: 103.5 have error in sql syntax; check manual corresponds mysql server version right syntax use near '103.5' @ line 1
i'm using php version 5.6.3 , mysql version 5.6.21
i cant figure out, problem :(
you're using +
concatenate strings, doesn't work in php. have use .
.
there strange arithmatic going on produces 103.5
, 2.5 + "," + 100
. ","
converted int(1)
or something.
Comments
Post a Comment