Forum Moderators: coopster
<?php
require_once("config2.php");
require_once("helper.php");
require_once("class.mysql.php");
$db = new MySQL($host,$dbUser,$dbPass,$dbName);
$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
if(isValidEmail($the_email))
{
$email = mslash($the_email);
$sql = "SELECT * FROM offers WHERE email = $email";
$result = $db->query($sql);
if($result->size() == 0)
{
$sql = "INSERT INTO offers(name, phone, email) VALUES($name, $phone, $email)";
$result = $db->query($sql);
if($db->isError())
{
die("error inserting email");
}
}
}
?>
Also, note that you can echo your query to debug it.
Just echo $sql before call the result.
To know what wrong with the query, copy it and paste it in SQLMyAdmin, a tool to manage your database. It will tell what wrong with the query.