I am doing a tutorial from a book and I can't get it to work. I have proofread the code over and over. I am getting an error when trying to use the second function named emailChecker. The first is just my DB connection and I blocked out the info for security...
Here is the error:
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 'VALUES ('test@testing.com')' at line 2
Here is the code
Here is my PHP code that has the SQL in it. Anyone see a prob?
<?php
//Function to connect to the database and test the connection
function doDB() {
global $mysqli;
// Establish a connection to the database
$mysqli = new mysqli("xxxxx", "xxxxx","xxxx","xxxxx");
// if connection fails, stop script execution
if (mysqli_connect_errno()){
printf("DATABASE CONNECTION FAILED: ", mysqli_connect_error());
}
}
function emailChecker ($email) {
global $mysqli, $check_res;
//check that email is not already in list
$check_sql = "SELECT id FROM subscribers WHERE email = '".$email."'";
$check_res = mysqli_query($mysqli, $check_sql)
or die(mysqli_error($mysqli));
}
?>