21,886
社区成员
发帖
与我相关
我的任务
分享
<?php
require_once('db_fns.php');
$conn = db_connect();
$result = $conn->query('select * from st');
if(!$result){
throw new Exception( mysql_errno().":".mysql_error());
}
?>
<?php
require_once('db_fns.php');
$conn = db_connect();
try{
$result = $conn->query('select * from st');
if(!$result){
echo $conn->error.":".$conn->erron;
throw new Exception( $conn->erron.":".$conn->error);
}
}catch( Exception $e){
echo $e->getMessage();
}
?>
<?php
function db_connect()
{
$result = new mysqli('localhost', 'root', '111111', 'coldstorage');
if (!$result)
throw new Exception('Could not connect to database server');
else
return $result;
}
?>
<?php
require_once('db_fns.php');
$conn = db_connect();
try{
$result = $conn->query('select * from st');
if(!$result){
echo $conn->error.":".$conn->erron;
throw new Exception( $conn->erron.":".$conn->error);
}
}catch( Exception $e){
echo $e->getMessage();
}
?>
<?php
require_once('db_fns.php');
$conn = db_connect();
try{
$result = $conn->query('select * from st');
if(!$result){
echo mysql_errno().":".mysql_error();
throw new Exception( mysql_errno().":".mysql_error());
}
}catch( Exception $e){
echo $e->getMessage();
}
?>
<?php
$conn = mysql_connect('localhost','root','554981044');
mysql_select_db("test");
try{
$result = mysql_query('select * from st');
if(!$result){
throw new Exception( mysql_errno().":".mysql_error());
}
}catch( Exception $e){
echo $e->getMessage();
}