当前位置: 首页 > 知识库问答 >
问题:

deprecated:mysql_connect():mysql扩展被弃用,以后将被删除:使用mysqli或PDO[duplicate]

钱飞翼
2023-03-14

共有1个答案

夏飞掣
2023-03-14
$result = mysqli_query($link, $query); // $link being the connection variable
<?php 
$link = mysql_connect('hostname','dbuser','dbpassword'); 
if (!$link) { 
    die('Could not connect to MySQL: ' . mysql_error()); 
} 
echo 'Connection OK'; mysql_close($link); 
?>
<?php 
$link = mysqli_connect('hostname','dbuser','dbpassword','db_name'); 
if (!$link) { 
    die('Could not connect to MySQL: ' . mysqli_error($link)); 
} 
echo 'Connection OK'; mysqli_close($link); 
?>
    null
    null
 类似资料: