1st user has to fill this form

    <form action="upload.php" method='post' enctype = 'multipart/form-data'>
        ImageName: <input class = "text" type="text" name="imagename" /><br/>
        Description<textarea name="imagedes"cols="16" rows="4"> </textarea><br/>
        <input type ="file" name="fileupload" /><br/>
        <input type="submit" name="submit" value="sumbit" /><br/>
        <a href="index.php">[BACK]</a>
    </form>

than it run php code. here i am getting image infomation

$image_short_name =  $_POST['imagename'];  //get image title from form
            $image_des =  $_POST['imagedes'];     //get description of image

            $image = file_get_contents($_FILES['fileupload']['tmp_name']);       //get image
            $image_full_name = $_FILES['fileupload']['name'];                            //get image realler name
            $image_size = getimagesize($_FILES['fileupload']['tmp_name']);       //get image size


//get user_id from table called user


        $queryget = mysql_query("SELECT user_id FROM user WHERE username = '$user'") or die("query didnt work");
                $row = mysql_fetch_assoc($queryget);    
                $user_id_db = $row['user_id'];

now i have all the infomation. i just want to store in database. my database is called image and it has folling:
image_id
user_id
image
image_full_name
image_short_name
image_des
image_view
image_fav

//insert information into database

if(!$insert = mysql_query("INSERT INTO image VALUES(NULL, 'user_id_db', '$image', '$image_full_name', '$image_short_name', 'image_des')"))
                {
                    echo "problem uploading image";
                }
                else
                {
                    works
                }

it always print "priblem uploading image". so the probblem is in mysql_query()

FULL CODE
<?php
session_start();
include("connect.php");

$user = $_SESSION['username'];
$file = $_FILES['fileupload']['tmp_name'];
$upload_error = "";

//user log in
if($user)
{
    if($file)
    {
        //user get submit button
        if($_SERVER['REQUEST_METHOD'] == 'POST')
        { 
            $image_short_name =  $_POST['imagename'];
            $image_des =  $_POST['imagedes'];

            //check for error first
            //scussess
            //store image in $image
            $image = file_get_contents($_FILES['fileupload']['tmp_name']);
            //store image name in $image_full_name(.jpeg)
            $image_full_name = $_FILES['fileupload']['name'];
            //store image size in $image_size
            $image_size = getimagesize($_FILES['fileupload']['tmp_name']);
            //test if its a image or file
            if($image_size == FALSE)
            {
                echo "Thats not a image";
            }
            else
            {
                //get user id and sote in user_id_db
                $queryget = mysql_query("SELECT user_id FROM user WHERE username = '$user'") or die("query didnt work");
                $row = mysql_fetch_assoc($queryget);    
                $user_id_db = $row['user_id'];

                //insert information into database
                if(!$insert = mysql_query("INSERT INTO image VALUES(NULL, 'user_id_db', '$image', '$image_full_name', '$image_short_name', 'image_des')"))
                {
                    echo "problem uploading image";
                }
                else
                {
                    works
                }
            }
        }
    }
    else
    {
        echo "Please select an image.";
    }
}
else
{
    die("plz log in!");
}
?>

                                   <!-- enctype for upload images-->
<form action="upload.php" method='post' enctype = 'multipart/form-data'>
    ImageName: <input class = "text" type="text" name="imagename" /><br/>
    Description<textarea name="imagedes"cols="16" rows="4"> </textarea><br/>
    <input type ="file" name="fileupload" /><br/>
    <input type="submit" name="submit" value="sumbit" /><br/>
    <a href="index.php">[BACK]</a>
</form>

Check out what the actual error.. Print out mysql_error(). And secondly, in the mysql_query(); You seem to be missing the "$" for user_id_db & image_des.

Notice: Undefined index: fileupload in C:\xampp\htdocs\login_test\upload.php on line 6

You will need to have the html code in another file and php on this file I believe.. Or a mechanism of the code getting executed only when they press the submit button

To get rid of the notice, you can use code like this:

$file = isset($_FILES['fileupload']) ? $_FILES['fileupload']['tmp_name'] : false;
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.