0

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.

3
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by phpDave
0

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

1

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

0

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

This question has already been answered. 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.