0
The following errors are appearing:
Warning: mysqli_query() expects at least 2 Parameters, 1 Given in C: xampp htdocs rede profile.php on line 25
Warning: mysqli_fetch_assoc() expects Parameter 1 to be mysqli_result, null Given in C: xampp htdocs rede profile.php on line 26
Warning: mysqli_query() expects at least 2 Parameters, 1 Given in C: xampp htdocs rede profile.php on line 31
Warning: mysqli_error() expects Exactly 1 Parameter, 0 Given in C: xampp htdocs rede profile.php on line 31
My code:
<?php
include("header.php");
$id = $_GET["id"];
$saberr = mysqli_query($connect, "SELECT * FROM users WHERE id='$id'");
$saber = mysqli_fetch_assoc($saberr);
$email = $saber["email"];
if ($email==$login_cookie) {
header("Location: myprofile.php");
}
$pubs = mysqli_query($connect, "SELECT * FROM pubs WHERE user='$email' ORDER BY id desc");
if (isset($_POST['add'])) {
add();
}
function add(){
$login_cookie = $_COOKIE['login'];
if (!isset($login_cookie)) {
header("Location: login.php");
}
$id = $_GET['id'];
$saberr = mysqli_query("SELECT * FROM users WHERE id='$id'");
$saber = mysqli_fetch_assoc($saberr);
$email = $saber['email'];
$data = date("Y/m/d");
$ins = "INSERT INTO amizades (de, para, data) VALUES ('$login_cookie', '$email', '$data')";
$conf = mysqli_query($ins) or die(mysqli_error());
if ($conf) {
header("Location: profile.php?id=".$id);
}else{
echo "<h3>Erro ao enviar pedido...</h3>";
}
}
if (isset($_POST['cancelar'])) {
cancel();
}
Wouldn’t have to call the connection here?
$conf = mysqli_query($connect, $ins) or die(mysqli_error());
– Miguel Silva