PHP异常如何处理? mysql_query(你的SQL语句,$conn) or die('对不起,记录不存在!'); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不妨尝试这种做法/** * 提取新闻内容。 * @id 内容ID */function getContents($id){ if(is_numeric($id)){ return "显示的错误信息或者信息的ID"; } $contents = null; // 访问数据库提取新闻内容 $contents = mysql_query(你的SQL语句,$conn); if(empty($contents)){ return "显示的错误信息或者信息的ID"; } return $contents;} 修改一下/** * 提取新闻内容。 * @id 内容ID */function getContents($id){ if(!is_numeric($id)){ return "显示的错误信息或者信息的ID"; } $contents = null; // 访问数据库提取新闻内容 $contents = mysql_query(你的SQL语句,$conn); if(empty($contents)){ return "显示的错误信息或者信息的ID"; } return $contents;} 使用or die子句,或者判断是否执行SQL成功(if($reuslt == TRUE)),或者用PHP的异常处理(try...catch...) <?phptry { $error = 'Always throw this error'; throw new Exception($error); // 从这里开始,tra 代码块内的代码将不会被执行 echo 'Never executed';} catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n";}// 继续执行echo 'Hello World';?> 你这是数据错误还是php错误啊 没看懂 onload图片的问题 求类似QQ动感影集的源码 修改linux中ftp的密码, 有个正则不会,帮忙写下? PHP怎么做下载 请问分布注册是用这样做了吗 寻找php+mysql高手合作 一个路由 + 一个php网站 , 怎么做到对局域网内用户指定URL跳转? 大家有思路吗? 想把一个php文件生成的html内容存入数据库 thinkPHP 导航菜单 来几道PHP题?大家做吧 请高手指教 。 。。如何限制文件下载人数?
* 提取新闻内容。
* @id 内容ID
*/
function getContents($id){
if(is_numeric($id)){
return "显示的错误信息或者信息的ID";
}
$contents = null;
// 访问数据库提取新闻内容
$contents = mysql_query(你的SQL语句,$conn);
if(empty($contents)){
return "显示的错误信息或者信息的ID";
}
return $contents;
}
/**
* 提取新闻内容。
* @id 内容ID
*/
function getContents($id){
if(!is_numeric($id)){
return "显示的错误信息或者信息的ID";
}
$contents = null;
// 访问数据库提取新闻内容
$contents = mysql_query(你的SQL语句,$conn);
if(empty($contents)){
return "显示的错误信息或者信息的ID";
}
return $contents;
}
<?php
try {
$error = 'Always throw this error';
throw new Exception($error); // 从这里开始,tra 代码块内的代码将不会被执行
echo 'Never executed';} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}// 继续执行
echo 'Hello World';
?>