尽管使用error_reporting(0)仍然会得到Json Parse错误

时间:2015-03-29 11:29:59

标签: php

我使用php 5.5,因为Logcat消息我收到了Json Parser错误:

 <br />
 <b>Deprecated</b>:  mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in <b>/home4/enippeas/public_html/select_itin2.php</b> on line <b>2</b><br />

我想知道我必须转到pdo(注意我的应用程序仅用于教育目的)但是试图避免收到错误我尝试使用

error_reporting(0);

但我继续得到同样的错误。任何的想法;

php文件

<?php
$con=mysql_connect("localhost","enippeas_enippea","tiramola48" );
$database = "enippeas_etruck1";
$ok = mysql_select_db($database, $con);
mysql_set_charset("utf8",$con); 
error_reporting(0);

$us1 = $_POST['username1'];
$sp1 = $_POST['startPoli1'];
$fp1 = $_POST['finalPoli1'];
$w1 = $_POST['weight1'];
$em1 = $_POST['eidosmetaf1'];
$dD1 = $_POST['depDate1'];
$dT1 = $_POST['depTime1'];


$sql = mysql_query( "  SELECT  `onoma01` , `epitheto01` , `email01` ,`username1`,`startPoli1`, `finalPoli1`, `eidosmetaf1`, `weight1` , `depDate1` , `depTime1`, `tilefono01` 
 FROM customer ,registration1 
 where   
 ( '$sp1'='empty' or customer.startPoli1 = '$sp1') and 
 ( '$w1'='empty' or customer.weight1 <= '$w1') and 
  (  '$em1'='empty' or customer.eidosmetaf1 = '$em1')  and 
  (  '$fp1'='empty' or customer.finalPoli1 = '$fp1')  and 
  (  '$dD1'='empty' or customer.depDate1 = '$dD1')  and 
 (customer.username1 = registration1.username01 )");

    if($sql === FALSE) 
    { 
    die(mysql_error()); 
    }
    $results = array();
    while($row = mysql_fetch_assoc($sql))
{
   $results[] = array(
    'onoma' => $row['onoma01'],
        'epitheto' => $row['epitheto01'],
        'email' => $row['email01'],
        'username1' => $row['username1'],
        'startPoli1' => $row['startPoli1'],
        'finalPoli1' => $row['finalPoli1'],
        'eidosmetaf1' => $row['eidosmetaf1'],
        'weight1' => $row['weight1'],
        'depDate1' => $row['depDate1'],
        'depTime1' => $row['depTime1'],
        'tilefono1' => $row['tilefono01']
         );
         }
    echo json_encode(array('select_itin_results' =>$results));
    mysql_close($con); 
?>

1 个答案:

答案 0 :(得分:0)

或许error_reporting(0);需要转到文件的顶部。

error_reporting用于确定报告的错误级别。如果您只是不希望在页面上显示错误,则最好使用:

ini_set("display_errors", 0);

这样一来,错误就不会被忽略,仍然可以进入日志文件等,它们只是不会输出到你的页面。