如何将HTML和php与数据库连接?

时间:2018-08-06 07:43:14

标签: php html

 <?php
    $host = 'localhost';
    $user = 'root';
    $pass = 'faceface';
    $dbname = 'medi'; 
    //mengubung ke host
    $connect = mysql_connect ($host, $user, $pass) or die(mysql_error());
    $select  = mysql_select ($dbname) or die(mysql_error());

$ICNo=$_GET['ICNo'];
$query="SELECT * from patient where ICNo = $ICNo";
$result= mysql_query($connect, $query);

致命错误:未捕获错误:调用C:\ xampp \ htdocs \ medicare \ view_patient.php:451中未定义的函数mysql_connect():堆栈跟踪:#0 {main}抛出于C:\ xampp \ htdocs \ medicare \ 451行上的view_patient.php

有人可以帮我这个忙吗?这是编码和错误。运行此代码时,它将出现一个错误,直到现在我仍无法解决。希望有人可以帮助我解决此编码。

1 个答案:

答案 0 :(得分:0)

<?php 
 $host = 'localhost';
    $user = 'root';
    $pass = 'faceface';
    $dbname = 'medi';
$connect = mysqli_connect($host,$user,$pass,$dbname);


$ICNo=$_GET['ICNo'];
$query="SELECT * from patient where ICNo = '$ICNo'  ";
$result = mysqli_query($connect,$query);


?>