Ajax代码错误

I Have Solve The Problem From The Code But Now It Should Return The Array From The User_level But It Return In blank any idea from the error please

<?php
     $user_level = $_GET['user_level'];
     session_start();
     include_once 'dbconnect.php';

     if(!isset($_SESSION['user'])){
         header("Location: index.php");
     }

    $res=mysql_query("SELECT user_level FROM users where user=".$_SESSION['user']); 

    while($rows=mysql_fetch_array($res)){
       echo $rows['user_level'];
       // close while loop 
    }
die();
?>

Hi hello I have perform this code but it seems to have an error can some one help me with please.

The error is

 A página de bitcoinrotator.publiadds.org.pt is not working

 bitcoinrotator.publiadds.org.pt can not process this request for time. 500

The Code is

<?php
$user_level = $row['user_level'];
$user_level = $_GET['user_level'];

session_start();
include_once 'dbconnect.php';


if(!isset($_SESSION['user'])) //if he isnt logged in
{
    header("Location: index.php");
}

$res=mysql_query("SELECT user_level FROM users where user=".$_SESSION['user']);

$rows=mysql_fetch_array($res);
echo $user_level;
echo $rows['user_level'];
    }

}



?>

</div>

You have a syntax error in your brackets and the way that you are getting your information. You have, first, leed of use mysql becasue this extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used. Returning at your problem. Try this (Changes are commented):

<?php
session_start(); //put your session at the top
require_once 'dbconnect.php'; //not include_once, just require once
$user_level = $_GET['user_level']; 

    if(!isset($_SESSION['user'])) //if he isnt logged in
    {
        header("Location: index.php");
    } //you are finish the if statement

    else //you have to create an else of your if for determinate if your setence if is not complete or not true
    {
//You have an error too in $_SESSION['user']. You have to close in " " or ' ' and use it after in your query. Also and in this example, we will save $_SESSION['user'] in a variable $user.

$user = $_SESSION['user'];
$res = mysql_query("SELECT user_level FROM users where user='$user' ");
//At this point, we will going to create a while for extract information of the query
        while ($rows = mysql_fetch_array($res, MYSQL_NUM)) {
        echo $user_level;
        echo $rows['user_level'];
    }
?>

Well I Finish To Discovery The Way To Do With A friend

There It is The Solution For

<?php
session_start();
include_once 'dbconnect.php';

if(!isset($_SESSION['user']))
{
    echo "You are not logged in.";
}else{
    
}


$res=mysql_query("SELECT user_level FROM users where user_id=".$_SESSION['user'])or die("We didnt did a sql query".mysql_error());

$rows=mysql_fetch_array($res);

$user_level = $rows['user_level'];

echo $user_level;
    





?>

Tanks For The Help

</div>