0

I get the following error when trying to run the an INSERT statement:

ERROR: INSERT INTO company (company, adr_street, city, Prov, postal, country) VALUES (company1, 67 46 street sw, city1, province1, w9w9w9, Canada) 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 '46 street sw, city1, province1, w9w9w9, Country)' at line 1

This is the vardump:

array(7) { ["company"]=> string(8) "company1" ["adr_street"]=> string(15) "67 46 street sw" ["city"]=> string(5) "city1" ["prov"]=> string(9) "province1" ["postal"]=> string(6) "w9w9w9" ["country"]=> string(6) "Canada" ["Submit"]=> string(6) "submit" }

This is the query:

$sql="INSERT INTO company (`company`, `adr_street`, `city`, `Prov`, `postal`, `country`) VALUES ($company, $adr_street, $city, $prov, $postal, $country)";

Any insight would be appreciated.

Thanks!

A l w a y s S u n n y
  • 36,497
  • 8
  • 60
  • 103
jd0117
  • 105
  • 9

1 Answers1

0

Wrap your text/string values with single quote like below.

INSERT INTO company (company, adr_street, city, Prov, postal, country) 
VALUES ('company1', '67 46 street sw', 'city1', 'province1', 'w9w9w9', 'Canada');
Hatim Stovewala
  • 1,333
  • 10
  • 19