PHP mysql_query()没有找到这样的文件或目录?

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.

This might be caused by mysql.sock file path is not configured properly for php.

  1. So please make sure you installed the mysql db engine, and find where the mysql.sock file is located.

  2. Then you need to configure in php.ini file:

Find these lines, configure like the following:

mysql.default_socket = /path/mysql.sock mysqli.default_socket = /path/mysql.sock pdo_mysql.default_socket = /path/mysql.sock

  1. Restart apache server and mysql service

You can't mix mysqli_* with mysql_*. It's safer to do it the mysqli way anyways:

//see if email exists in database
$stmt = $con->prepare('SELECT * FROM rsvpWedding WHERE email=?'); // question mark is a placeholder
$stmt->bind_param('s', $email); // 's' means it's a string
$stmt->execute();
$stmt->bind_result($result); // assign the result to your $result var
$stmt->fetch();

See the docs here: http://php.net/manual/en/mysqli.prepare.php

your not printing anything thats why! try using mysqli_num_rows($result)

echo that one

if its greater than zero then it exist if none then youre all good