dousendun8411 2014-05-04 11:45
浏览 35
已采纳

MySQL错误2002使用INSERT INTO时

I have a problem with mysql. When I execute this, that give me an error: No such file or directory 2002, but SELECT query work perfect and print typ on the screen. What can I solve this problem?

<?php
$con=mysqli_connect("db4free.net","****","****","*****");
if (mysqli_connect_errno($con))
{
   echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$username = $_GET['username'];
$password = $_GET['password'];
$result = mysqli_query($con,"SELECT Typ FROM Uzytkownik where Login='$username' and Haslo='$password'");

$row = mysqli_fetch_array($result);
$data = $row[0];
if($data){
echo $data;
}

$que =  "INSERT INTO Uzytkownik VALUES ('10','tr','t','a')";
if( !mysql_query($que) ) {
     echo  "ERROR!!: ".mysql_error().mysql_errno() ;
}
mysqli_close($con);
?>

Result of this:

testERROR!!: No such file or directory2002

EDIT Sorry, I pasted wrong code, but it was already changed

  • 写回答

2条回答 默认 最新

  • doudou5101 2014-05-04 12:59
    关注

    You cannot mix mysqli_* functions with mysql_* functions.

    replace this:

    if( !mysql_query($que) ) {
         echo  "ERROR!!: ".mysql_error().mysql_errno() ;
    }
    

    with

    if( !mysqli_query($con, $que) ) {
         echo  "ERROR!!: ".mysqli_error($con) ;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services