so i have a table called image. in side image table it has

i am trying to create upload page where user can sumbit image. but i want to make sure a user dont pick same image_short_name.
for ex if a user called "dave" pick a image_short_name "tree" than he can not pick the same image_short_name again.
but another user "chris" can pick the name "tree" but only ones.

        $query = mysql_query("Select * FROM image WHERE image_short_name = '$image_short_name_p'");     
        if(mysql_num_rows($query) >= 1)
            $upload_error .= "That image name is already taken";

this check the whole database. can some one help me with this query.

you have to include the user id in the where clause to further filter the records for the concerned user

$userId = 124;//you program logic to fetch user id

$query = mysql_query(
        "Select * FROM image "
        .   "WHERE image_short_name = '$image_short_name_p' "
        .   "AND user_id=$userId"

(considering userId is int or bigint, else the single quotes..)

Be a part of the DaniWeb community

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