0
I’m trying to solve a problem always PHP is returning the Else code "Wrong administrator password."
But the fact is that the password is correct... Well I tried everything so far.
<?php
$email = $_POST['email'];
$tempo = $_POST['tempo'];
$plugin = $_POST['plugin'];
$emaild = $_POST['emaild'];
$password = $_POST['password'];
$query55 = @mysql_num_rows(mysql_query("SELECT * FROM cadastro WHERE email='$emaild' AND senha='$password' "));
if($query55 == 1) {
$aleatorio = rand(6, 6); // 5 À 10 CARACTERES
$valor = substr(str_shuffle("ABCDEFGHIJKLMNOPKRSTUVWXYZ0123456789"), 0, $aleatorio);
date_default_timezone_set('America/Sao_Paulo');
$buy_date = date("d/m/Y | H:i:s");
$query = "SELECT * FROM plugin WHERE plugin_name='$plugin'";
$result= @mysqli_query("$query"); // inicia a pesquisa
while ($row = @mysql_fetch_array($result)) {
$plugin_name = stripslashes($row['plugin_name']);
if($tempo == 6){
$plugin_custo = stripslashes($row['plugin_custo_1']);
}elseif($tempo == 1){
$plugin_custo = stripslashes($row['plugin_custo_2']);
}elseif($tempo == 'eterno'){
$plugin_custo = stripslashes($row['plugin_custo_3']);
}
}
if($tempo == 6){
$tomorrow = mktime (date("H"), date("i"), date("s"), date("m")+6, date("d"), date("Y"));
}elseif($tempo == 1){
$tomorrow = mktime (date("H"), date("i"), date("s"), date("m")+12, date("d"), date("Y"));
}elseif($tempo == 'permanente'){
$tomorrow = "permanente";
}
$db_host = "";
$db_user = "";
$db_pass = "";
$db_name = "";
$conn = new mysqli($db_host, $db_user, $db_pass, $db_name);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO compras (email, transaction_id, custo, buy_date, item_token, status, item_nome, tempo) VALUE ('$email',
'$valor', '$plugin_custo', '$buy_date', '$valor', 'Pago', '$plugin', '$tempo') ";
if ($conn->query($sql) === TRUE) {
echo json_encode("Plugin adicionado com sucesso.");
echo "<h1>TESTE</h1>";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$sql2 = "INSERT INTO plugin_comprados (buy_date, plugin_token, plugin_owner, termino, plugin_name)
VALUE ('$buy_date', '$valor', '$email', '$tomorrow', '$plugin')";
if ($conn->query($sql2) === TRUE) {
echo json_encode("Plugin adicionado com sucesso.");
echo "<h1>TESTE</h1>";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
return;
}else {
echo json_encode("Senha de administrador errada.");
}
?>
because Voce declared the function with @? @mysql_num_row
– Julio Henrique
Have you tried taking @ out of front of functions to see if an error is occurring? Use of @ in PHP
– Pagotti
Missed passing connection to function here =>
mysqli_query("$query");
– rray
@rray No
mysql_
connection is optional. I just don’t understand why to usemysql_
andmysqli_
together.– Valdeir Psr