Value problem containing comma

Asked

Viewed 332 times

0

When executing this query:

mysqli_query($dbc, "insert into toons values(NULL, $toonId, '$toonName', $admin, '$dna', $bank, $money, $hp, '$inventory', $lastPlace)")

I get this mistake:

You have an error in your SQL syntax; check the manual that Corresponds to your Mysql server version for the right syntax to use near ' '', ', ', ', ', ', ')' at line 1

What is causing this?

1 answer

3

Database only accepts decimal places with . (point). If you are passing 1,99 in the variable money is likely to give problem not only in the bank. It uses a replace in the variable of , for ..

mysqli_query($dbc, "insert into toons values(NULL, $toonId, '$toonName', $admin, '$dna', $bank, str_replace(",", ".", $money), $hp, '$inventory', $lastPlace)")

Browser other questions tagged

You are not signed in. Login or sign up in order to post.