I have a MySQL database set up with Hostmysite.com. It connects just fine, and the idea of my php file is to take form values and input it into the SQL database. I am trying to create a feature that doesn't allow duplicate entries by comparing the email to see if it exists in the db...
The php code I think is right, but on die() it returns No such file or directory found??? That doesn't make sense.
<?php
//connection variables is excluded to get to the point of the problem
$con = mysqli_connect($host, $user, $pass, $db);
if (!$con){
die("Connection failed: " .my_sqli_connect_err());
}
$email = $_POST["email"];
$email = mysqli_real_escape_string($con, $email);
//see if email exists in database
$findEmail = "SELECT * FROM rsvpWedding WHERE email='" . $email."';";
$results = mysql_query($findEmail)or die(mysql_error());
?>
The:
$results
Returns a No such file or directory exists? I don't understand the SQL statement is correct and I believe my php code is also correct.
I don't know if this has anything to do with the problem, but this does mix:
mysqli_*();
with
mysql_*();
*****UPDATE ******
I believe I understand why I am getting that error of No such file or directory found. According to the web page : http://php.net/manual/en/function.mysql-query.php When sql_query() is executed it tries to connect to a link that was executed on
sql_connect()
not
sqli_connect()
If it can't find one it will try and attempt a connection with sql_connect() with no arguments, if that fails it will generate an error.. From researching online I see that No such file or directory is normally associated with sql_connect() errors.
So i suppose my question to this post sort of changes to how do I create a resource using the sqli_* syntax. I tried
$results = mysqli_query($con, $findEmail) or die(mysql_error());
but that still doesn't work, it just skips that entire code block... doesn't even produce an error.