I'm working on a function and it was working good until I had an error that tells me I should swich from mysql to mysqli so I did swich but I'm having a lot of errors ! (the function is working fine but I have a lot of errors!).
This is my code :

function login(){
if(isset($_SESSION['user']) and isset($_SESSION['password'])){
    $username = $_SESSION['user'];
$sql = "SELECT * FROM users WHERE username='$username'";
$query = mysqli_query($con,$sql);
while($user = mysql_fetch_object($query)){
    $id = $user->id;
echo "Welcome $username ".$user
." <a href='myaccount.php?id=$id'>My Account</a>"
." | <a href='myoffers.php?id=$id'>My offers</a>"

." | "."<a href='add_offer.php?id=$id'>Add an Offer</a>"
." | "."<a href='logout.php'>Logout</a>";
}else {
echo "<table><form action='check_login.php' method='POST'>
<td><input type='text' name='username' placeholder='Username' /></td>
<td><input type='password' name='password' placeholder='Password' /></td>
<td><input type='submit' value='Login' /></td>


This is a screenshot of the errors :
Click Here

You also need to change mysql_fetch_object to mysqli_fetch_object,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.