我只创建一个使用php和apache的Web服务器,当我尝试执行连接功能或验证表单等时,服务器以chrome状态响应状态(已取消),请参阅上面的一个文件获取这个错误。
<?php
define( 'ROOT_DIR', dirname(__FILE__) );
define ("DB_SERVIDOR", 'xxx.xxx.xxx.xxx');
define ("DB_USUARIO", "root");
define ("DB_SENHA", "passwd");
define ("DB_NOME", "db_name");
class Connect extends mysqli
{
public function __construct(){
//@mysqli_connect (DB_SERVIDOR, DB_USUARIO, DB_SENHA, DB_NOME);
parent::__construct (DB_SERVIDOR, DB_USUARIO, DB_SENHA, DB_NOME);
if (mysqli_connect_errno() != 0){
header('Location: localhost:8000/oton_contabil/views/error_mysql.view.php?numero_erro='.mysqli_connect_errno().'&msg='.mysqli_connect_error());
}
}//function __construct
public function __destruct()
{
if (mysqli_connect_errno() == 0){
$this->close();
}
}//function __destruct
public function listar_tabela($query, $num_td, $objetos = array()){
$lista_tabela = array();
$td_values = array();
$sql = $this->query($query);// a função query() é nativa da classe mysqli
while ($obj = $sql->fetch_array()){
echo "<tr>";
for($i = 0; $i <= $num_td; $i++ ){
/* Checa se o valor a ser exibido é float */
if(is_numeric($obj[$objetos[$i]]) == true){
if(strpos($obj[$objetos[$i]], '.') != false){
echo "<td style='text-align:right !important;'>".number_format($obj[$objetos[$i]], 2, ',', '.')."</td>";
}
else{
echo "<td style='text-align:left !important;'>".substr($obj[$objetos[$i]], 0, 100)."</td>";
}
}
elseif($obj[$objetos[$i]] == '0000-00-00'){
echo "<td style='text-align:left !important;'></td>";
}
elseif(DateTime::createFromFormat('Y-m-d', $obj[$objetos[$i]])){
echo "<td style='text-align:left !important;'>".date('d/m/Y', strtotime($obj[$objetos[$i]]))."</td>";
}
else{
echo "<td style='text-align:left !important;'>".substr($obj[$objetos[$i]], 0, 100)."</td>";
}
}
echo "</tr>";
}
$sql->close();
}
}//class
$conexao = new Connect();
$sql = $conexao->query("select * from cadastro_cliente");
$obj = $sql->fetch_object();
echo $obj['cli_id'];
echo "lalalal";
?>