I have a simple script which I have included here. the select query works fine but the insert query fails. I am running php, apache and mysql on my macbook.
The table city_profile has ID as a auto increment primary key. And name is a non-null.
function testMySQL() {
$db = new mysqli('localhost', 'root', NULL, 'citee');
//$query = "select * from city_profile"; //this query works
$query = "insert into city_profile ('name','state','country') values ('charlotte','north carolina','usa')";
//whereas the above one fails..
$results = $db->query($query);
if($results) {
echo '<p>The query is successful.</p>';
}else {
echo '<p>The query is NOT successful.</p>';
}
//close the connection
$db->close();
}
try to change this line:
into this: