错误取消定义mysql_connect函数

时间:2016-08-09 06:35:52

标签: php mysql

错误显示 - >

  

致命错误:未捕获错误:在C:\ xampp \ htdocs \ destination.php中调用未定义函数mysqli():18堆栈跟踪:#0 {main}在C:\ xampp \ htdocs \ destination.php中引发第18行

我的代码

<?php

if(isset($_GET['submit']))

 { 

                       $name=$_GET["name"];
                       $age=$_GET["age"];
                       $userid=$_GET["userid"];
                     //  echo "NAME:".$name."<br> AGE:".$age."<br>USERID:".$userid ;
                       //echo "saved";
                        $con = mysql_connect("localhost","root","");
                             if($con)
                           {
                             $db = mysql_select_db("practicedb");
                               if($db)
                               {
                                   $result = mysql_query("insert into info values('".$age."','".$name."','".$userid."')");
                                   echo ("inserted successfully");
                                }
                               else echo ("could not be inseted"); 
                               }
                           else echo ("could not connect to database");
                           }
                         else echo ("could not connect to localhost server");
}

请告诉我如何修复

1 个答案:

答案 0 :(得分:0)

尝试mysqli_connect函数如下

 $con = mysqli_connect('localhost','root','XXX','XXX');