mysql_query(你的SQL语句,$conn) or die('对不起,记录不存在!');

解决方案 »

  1.   

    不妨尝试这种做法/**
     * 提取新闻内容。
     * @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;
    }
      

  2.   

    修改一下
    /**
     * 提取新闻内容。
     * @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;
    }
      

  3.   

    使用or die子句,或者判断是否执行SQL成功(if($reuslt == TRUE)),或者用PHP的异常处理(try...catch...)
      

  4.   


    <?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';
    ?> 
      

  5.   

    你这是数据错误还是php错误啊 没看懂