I need to convert my code to PDO and I don't know where is the problem.
$user = $_SESSION['user_email'];
$get_user = "SELECT * FROM users where user_email='$user'";
//This 2 lines was there in original
$run_user = mysqli_query($con,$get_user); //original
$row=mysqli_fetch_array($run_user); //original
//Converting to PDO
$run_user = $con->prepare($get_user);
$run_user->execute();
$row = $run_user->fetch(PDO::FETCH_ASSOC); //line 27
// line 38 and 39
$user_id = $row['user_id'];
$user_name = $row['user_name'];
My errors are:
Warning: mysqli_stmt::fetch() expects exactly 0 parameters, 1 given in /Applications/XAMPP/xamppfiles/htdocs/network/includes/header.php on line 27
Notice: Trying to access array offset on value of type null in /Applications/XAMPP/xamppfiles/htdocs/network/includes/header.php on line 38
Notice: Trying to access array offset on value of type null in /Applications/XAMPP/xamppfiles/htdocs/network/includes/header.php on line 39