bom dia, subi uma aplicação php para o hostinger da forma indicada no curso, consigo abrir um formulario que só faz um post e não tem codigo php, quando faço o post vou para a pagina que adiciona no banco de dados, o que eu recebo de resposta são os seguintes erros:
Warning: include(connect-to-mysql.php): failed to open stream: No such file or directory in /home/u914665096/public_html/DevMakerTest/DAOcontacts.php on line 2
Warning: include(): Failed opening 'connect-to-mysql.php' for inclusion (include_path='.:/opt/php-5.5/pear') in /home/u914665096/public_html/DevMakerTest/DAOcontacts.php on line 2
Warning: include(connect-to-mysql.php): failed to open stream: No such file or directory in /home/u914665096/public_html/DevMakerTest/Add-contact.php on line 3
Warning: include(): Failed opening 'connect-to-mysql.php' for inclusion (include_path='.:/opt/php-5.5/pear') in /home/u914665096/public_html/DevMakerTest/Add-contact.php on line 3
Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /home/u914665096/public_html/DevMakerTest/DAOcontacts.php on line 6
Warning: mysqli_error() expects parameter 1 to be mysqli, null given in /home/u914665096/public_html/DevMakerTest/Add-contact.php on line 14 falha ao adicionar contato teste. erro:
Warning: mysqli_close() expects parameter 1 to be mysqli, null given in /home/u914665096/public_html/DevMakerTest/Add-contact.php on line 19
codigo da pagina que retorna o erro:
include("DAOcontacts.php");
include("connect-to-mysql.php");
include("head.php");
$name = $_POST["name"];
$telephone = $_POST["telephone"];
$email = $_POST["email"];
if(addContact($connection, $name, $telephone, $email)){?>
<p Class ="alert-success"> contato <?=$name?> adcionado com sucesso! </p><?php
}else{
$ErrorMsg=mysqli_error($connection);
?>
<p Class = "alert-danger"> falha ao adicionar contato <?=$name?>. erro:<?=$ErrorMsg?></p>
<?php
}
mysqli_close($connection);
?>
conecta com o banco de dados:
<?php
$connection = mysqli_connect('mysql.hostinger.com.br','u914665096_dev','devdev','u914665096_dev');
codigo do DAO:
<?php
include("connect-to-mysql.php");
function addContact($connection, $name, $telephone, $email){
$query = "insert into contacts (name, telephone, email) values ('{$name}','{$telephone}','{$email}')";
return mysqli_query($connection, $query);
}
function getContacts($connection){
$query = "select * from contacts";
$contacts = array();
$result = mysqli_query($connection, $query);
while($contact=mysqli_fetch_assoc($result)){
array_push($contacts,$contact);
}
return $contacts;
}
acredito que seja um problrma com os includes, não consigo resolver, alguma luz? :D