radiations3 Posted August 2, 2011 Share Posted August 2, 2011 HI, The following code is performing the right functionality of moving an image into the specified folder but what its not doing is inserting the file saved path into the mentioned table into the database kindly help me with that how can i do it.. FORM.php <form action="upload.php" method="post" enctype="multipart/form-data"> <p>File: <input type="file" name="filename" /> </p> <p> <input type="submit" value="Upload" /> </p> </form> UPLOAD.php <?php require_once('Connections/hammad.php'); ?> <?php $folder = "pak/".$_FILES['filename']['name']; $n=0; mysql_select_db($database_hammad,$hammad) or die(mysql_error()); mysql_query("INSERT INTO blob (id,pic) VALUES ('$n', '$folder')"); if (is_uploaded_file($_FILES['filename']['tmp_name'])) { if (move_uploaded_file($_FILES['filename']['tmp_name'], $folder)) { Echo "File uploaded"; } else { Echo "file not moved to destination folder. Check permissions"; }; } else { Echo "File is not uploaded."; }; ?> Quote Link to comment Share on other sites More sharing options...
xyph Posted August 2, 2011 Share Posted August 2, 2011 Urgent? Oh really, do go on... Quote Link to comment Share on other sites More sharing options...
radiations3 Posted August 2, 2011 Author Share Posted August 2, 2011 Urgent? Oh really, do go on... Can you help??? Quote Link to comment Share on other sites More sharing options...
xyph Posted August 2, 2011 Share Posted August 2, 2011 I'm quite sure I can. Quote Link to comment Share on other sites More sharing options...
radiations3 Posted August 2, 2011 Author Share Posted August 2, 2011 I'm quite sure I can. then kindly help... Quote Link to comment Share on other sites More sharing options...
xyph Posted August 2, 2011 Share Posted August 2, 2011 Then kindly follow the posting rules/guidelines. Quote Link to comment Share on other sites More sharing options...
radiations3 Posted August 2, 2011 Author Share Posted August 2, 2011 Then kindly follow the posting rules/guidelines. Did i break any rule or what?? Quote Link to comment Share on other sites More sharing options...
xyph Posted August 2, 2011 Share Posted August 2, 2011 Reading them would be a GREAT way to find that out. Now that I've made you wait, what happens when I upload a file with a name like Falken's Maze? Quote Link to comment Share on other sites More sharing options...
radiations3 Posted August 2, 2011 Author Share Posted August 2, 2011 Reading them would be a GREAT way to find that out. Now that I've made you wait, what happens when I upload a file with a name like Falken's Maze? if($help == 'yes') echo 'okay if you can help then that'll be so nice of you' ; else echo 'no problem have a nice day!'; Quote Link to comment Share on other sites More sharing options...
manix Posted August 3, 2011 Share Posted August 3, 2011 make sure that the database is connected and make sure all field/column/row names are correct Quote Link to comment Share on other sites More sharing options...
radiations3 Posted August 3, 2011 Author Share Posted August 3, 2011 make sure that the database is connected and make sure all field/column/row names are correct yes database is connected correctly but iam not getting why isn't inserting where as its performing the image copy functionality perfectly Quote Link to comment Share on other sites More sharing options...
manix Posted August 3, 2011 Share Posted August 3, 2011 add this: or die(mysql_error()); to this: mysql_query("INSERT INTO blob (id,pic) VALUES ('$n', '$folder')"); and you will find the error but my next guess would be that your ID is an auto increment primary key and you're setting it to 0 every time which is incorrect because ID values can not duplicate Quote Link to comment Share on other sites More sharing options...
radiations3 Posted August 3, 2011 Author Share Posted August 3, 2011 add this: or die(mysql_error()); to this: mysql_query("INSERT INTO blob (id,pic) VALUES ('$n', '$folder')"); and you will find the error but my next guess would be that your ID is an auto increment primary key and you're setting it to 0 every time which is incorrect because ID values can not duplicate I am pretty much close to solve this problem kindly help me with this not after adding that die fnction its displaying following error message You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''blob' (id,pic) VALUES ('1', 'pak/2010 Toyota iQ.jpg')' at line 1 mysql_query("INSERT INTO 'blob' (id,pic) VALUES ('$n', '$folder')") or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
manix Posted August 3, 2011 Share Posted August 3, 2011 this is incorrect: mysql_query("INSERT INTO 'blob' (id,pic) VALUES ('$n', '$folder')") or die(mysql_error()); this is correct: mysql_query("INSERT INTO `blob` (`id`,`pic`) VALUES ('$n', '$folder')") or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
radiations3 Posted August 3, 2011 Author Share Posted August 3, 2011 this is incorrect: mysql_query("INSERT INTO 'blob' (id,pic) VALUES ('$n', '$folder')") or die(mysql_error()); this is correct: mysql_query("INSERT INTO `blob` (`id`,`pic`) VALUES ('$n', '$folder')") or die(mysql_error()); THANK YOU VERY MUCH MY ISSUE IS BEING RESOLVED THANKS ALOTTT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ONE MORE QUESTION CAN YOU PLEASE HELP ME WITH DISPLAYING OF IMAGE FROM BLOB FIELD.... Quote Link to comment Share on other sites More sharing options...
manix Posted August 3, 2011 Share Posted August 3, 2011 I can't help you with that right now because I'm really short on time and got to go, but google "image blob field" and you'll probably find the solution Quote Link to comment Share on other sites More sharing options...
radiations3 Posted August 3, 2011 Author Share Posted August 3, 2011 I can't help you with that right now because I'm really short on time and got to go, but google "image blob field" and you'll probably find the solution No problem .. and thanx for helping me out.. if u get some time then do help me with blob field to display image i googled it but what ever solution was given i could not be able to make it work on my server so that's why i am seeking solutions here and i got one as well Thanks to God (1st) & to you!!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.