0
So, I was making a site per host site on wampserver, and it was working normally, now I put it to host on hostiger, and it’s no longer pulling the table data. Does anyone know what it could be??
//Codigo onde mostra os produtos
<?php
error_reporting (E_ALL & ~ E_NOTICE & ~ E_DEPRECATED);
require("banco.php");
$server = "mysql.hostinger.com.br";
$db = "u888901778_users"; // Indique o nome do banco de dados que será aberto
$usuario = "u888901778_jo"; // Indique o nome do usuário que tem acesso
$password = "***********"; // Indique a senha do usuário
//1º passo - Conecta ao servidor MySQL
$conect = mysql_connect($server,$user,$password ) or die (mysql_error());
//2º passo - Seleciona o Banco de Dados
$select_db = mysql_select_db($db) or die (mysql_error());
$sql = "SELECT * FROM camiseta_Masc";
$qr = mysql_query($sql) or die(mysql_error());
while($ln = mysql_fetch_assoc($qr)){
echo '<div class="col-md-4 bottom-cd simpleCart_shelfItem">';
echo '<div class="product-at ">';
echo '<a href="single.php"><img class="img-responsive" src="Produtos/Imagens/Camisetas masculinas/'.$ln['imagem'].'" />';
echo '<div class="pro-grid">';
echo '<span class="buy-in">Buy Now</span>';
echo '</div>';
echo '</a>';
echo '</div>';
echo '<br>';
echo '<font color="black" font face="Roboto" align="center" size="3px">'.$ln['nome'].'</font>';
echo '<p>';
echo '<font color="#00688B" size="2px">Por R$ '.number_format($ln['preco'], 2, ',', '.').'</font>';
echo '<div class="content">';
echo '<a href="checkout.php?acao=add&id='.$ln['id'].'" class="botao01">Comprar</a>';
echo '</div>';
echo '<br><br>';
echo '</div>';
}
?>
//Codico onde conecta ao banco
<?php
$server = "mysql.hostinger.com.br";
$user = "u888901778_jo";
$password = "************";
$database = "u888901778_users";
try {
$con = new PDO("mysql:host=$server;dbname=$database;", $user,$password);
} catch (PDOException $e) {
die("Conexão falhou:".$e->getMessage());
}
?>
Show the code of what you have. It may be N things.
– Thiago
Did you set up the host database as well? Did you create all the tables? Did you import any data? Changed the connection data in the code to connect to the hosting database?
– Woss
@Andersoncarloswoss I imported from the bank at wamp
– Pottker Mil_Grau
It may be because you are using an external address "mysql.hostinger.com.br" and their firewall is blocking. Try using "localhost" instead.
– Kleber Silva
Maybe the network firewall is blocking, try changing the line: $server = "mysql.hostinger.com.br"; To: $server = "127.0.0.1";
– Kleber Silva
I put it on and it didn’t work
– Pottker Mil_Grau