user3020920
user3020920

Reputation: 3

Cant find the mistake in this code, page shows up blank

<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
session_start();
if(!isset($_SESSION['user_id'])){
header('Location: login.php');
exit();
}
include('includes/db_connect.php');
$userid = $_SESSION['user_id'];
$sql = ("SELECT file_id FROM files WHERE user_id='$userid'");
$query = $db->query($sql);
if($query->num_rows ===1){
echo "<a href="index.php">Sorry you have already uploaded a file, to delete the current file and upload another please select retieve file from the homepage</a>";
}else{
echo "you can upload a file";
}
?>

The above checks to see if the user has uploaded a file. It does this by seeing if their is a file with their user id. some reason the page is just blank when loaded.

include just hold the connection string

been looking at this for ages, help would be appreciated, thank you in advance

Upvotes: 0

Views: 37

Answers (1)

Jack
Jack

Reputation: 2830

This line has a syntax error:

echo "<a href="index.php">Sorry you have already uploaded a file, to delete the current file and upload another please select retieve file from the homepage</a>";

If you define a string with double quotes ("), you must escape all double quotes contained in the string.

Replace it with this:

echo "<a href=\"index.php\">Sorry you have already uploaded a file, to delete the current file and upload another please select retieve file from the homepage</a>";

Upvotes: 1

Related Questions