The following errors are appearing:
Warning: mysqli_query () expects at least 2 parameters, 1 given in C: \ xampp \ htdocs \ network \ profile.php on line 25
Warning: mysqli_fetch_assoc () expects parameter 1 to be mysqli_result, null given in C: \ xampp \ htdocs \ network \ profile.php on line 26
Warning: mysqli_query () expects at least 2 parameters, 1 given in C: \ xampp \ htdocs \ network \ profile.php on line 31
Warning: mysqli_error () expects exactly 1 parameter, 0 given in C: \ xampp \ htdocs \ network \ 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();
}