0
<?php
    include ("connect.php");
    $_SESSION['username']="kai";
    $username=$_SESSION['username'];
    echo "Welcome,".$username."!<p>";
    $query= mysql_query("Select * from avatar where name = 'username'");

    if(mysql_num_rows($query)==0)
        die("User not found");
    else
    {
        $row = mysql_fetch_assoc($query);
        $location = $row['imagelocation'];
        echo "<img src='$location' width='200' height ='200'>.</p>";
    }
?>
<p/> Upload New Avatar
<form method="post" enctype='multipart/form-data' action='view.php'>
    File: <input type='file' name='myfile'>
    <input type='submit' name = 'submit' value='UPLOAD'>
</form>
2
Contributors
1
Reply
9
Views
3 Years
Discussion Span
Last Post by niranga
0

mysql_query() returns a resource on success, or FALSE on error. So better if you can check for that before calling mysql_num_rows()

if($query)
{
    if(mysql_num_rows($query)==0)
    {
        die("User not found");
    }
    else
    {
        $row = mysql_fetch_assoc($query);
        //other code
    }
}
else
{
    die("Invalid Query");
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.