duankun9280 2015-01-15 04:54
浏览 54

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.

  • 写回答

3条回答 默认 最新

  • drxyaox153896 2015-01-15 05:10
    关注

    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
    评论

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题