Hi, I am trying to insert an image path name into mysql. I not sure how to insert the path only if the path name "image name" does not exist. Also, I get duplicate rows when uploading image path name, not sure why. Here is some code. Any suggestions would be appreciated.

//insert image path
$insert = mysql_query("INSERT INTO mystuff.image(user_id, image_id, name)VALUES('$_POST[hiddenField]','','$file')");
echo mysql_error();

$file is the image name and the hiddenField is user_id of the logged in user.

Recommended Answers

All 5 Replies

if you don't want image path name duplication try to set the field to unique.

Thank you, I thought about that but I really don't want the column to be unique. Any other thoughts?

yeah i agree with codewall if you dont want the field to be unique then you must query it if it return 0 rows dn it doesnt exist... using mysql_num_rows to check if there are records for that path

Thanks, I found a way to get things to work with a unique col.

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.