Hello, I'm fairly new to this, having trouble with a basic query. I can run the query in Terminal, but when I write it into PHP I get the following error message:
Warning: mysql_query() expects parameter 2 to be resource, null given in (etc.)
and here is the problematic line:
mysql_query ( 'INSERT INTO users (id, username, password, first_name, last_name) VALUES (1, \'john\', \'password\', \'john\', \'thompson\')', NULL )
it's not clear to me where that NULL is coming from.
here's what i'm writing in the page i'm trying to load:
$sql = sprintf("INSERT INTO users (id, username, password, first_name, last_name) VALUES (1, 'john', 'password', 'john', 'thompson')");
$result = $db->query($sql);
and here's how the method is written on the page that's being included:
public function query($sql) {
$result = mysql_query($sql, $this->connection);
$this->confirm_query($result);
return $result;
}
Again, I can just enter the row into MySql directly and no trouble, but I can't get it to work through PHP. Any advice? I feel like something simple and glaring is at fault here, but I can't see it.
Thanks so much -
Elliot