I cannot for the love of god figure out why this statement is not executing. When I limit it to
mysql_query("INSERT INTO my_pets() VALUES ()", $con);
it fires just fine, creating an empty row (NULL in every cell), but as soon as I give it columns and values, it refuses. See below.
Can someone point out a mistake or any other reason this (seemingly) correct code isn't firing when columns and values are specified?
Premises:
- $h, $un, $pw, and $db are all fine, as I have copied it from documents that work as we speak.
- There are no typos or mistakes in upper/lower case characters of column names and such.
The code:
<?php
session_start();
$h="..."; // Host name
$un="..."; // Mysql username
$pw="..."; // Mysql password
$db="..."; // Database name
$con = mysql_connect("$h", "$un", "$pw")or die("cannot connect");
mysql_select_db("$db")or die("cannot select DB");
$name = "Pip";
$gender = "F";
$species = "Dog";
mysql_query("INSERT INTO my_pets (name, gender, species) VALUES ('$name', '$gender', '$species')", $con);
mysql_close($con);
?>