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."; }; ?> Link to comment https://forums.phpfreaks.com/topic/243640-problems-with-insert-query-please-help-urgent/ Share on other sites More sharing options...
xyph Posted August 2, 2011 Share Posted August 2, 2011 Urgent? Oh really, do go on... Link to comment https://forums.phpfreaks.com/topic/243640-problems-with-insert-query-please-help-urgent/#findComment-1250955 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??? Link to comment https://forums.phpfreaks.com/topic/243640-problems-with-insert-query-please-help-urgent/#findComment-1250956 Share on other sites More sharing options...
xyph Posted August 2, 2011 Share Posted August 2, 2011 I'm quite sure I can. Link to comment https://forums.phpfreaks.com/topic/243640-problems-with-insert-query-please-help-urgent/#findComment-1250960 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... Link to comment https://forums.phpfreaks.com/topic/243640-problems-with-insert-query-please-help-urgent/#findComment-1250961 Share on other sites More sharing options...
xyph Posted August 2, 2011 Share Posted August 2, 2011 Then kindly follow the posting rules/guidelines. Link to comment https://forums.phpfreaks.com/topic/243640-problems-with-insert-query-please-help-urgent/#findComment-1250965 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?? Link to comment https://forums.phpfreaks.com/topic/243640-problems-with-insert-query-please-help-urgent/#findComment-1250967 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? Link to comment https://forums.phpfreaks.com/topic/243640-problems-with-insert-query-please-help-urgent/#findComment-1250971 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!'; Link to comment https://forums.phpfreaks.com/topic/243640-problems-with-insert-query-please-help-urgent/#findComment-1250973 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 Link to comment https://forums.phpfreaks.com/topic/243640-problems-with-insert-query-please-help-urgent/#findComment-1250986 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 Link to comment https://forums.phpfreaks.com/topic/243640-problems-with-insert-query-please-help-urgent/#findComment-1250990 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 Link to comment https://forums.phpfreaks.com/topic/243640-problems-with-insert-query-please-help-urgent/#findComment-1250992 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()); Link to comment https://forums.phpfreaks.com/topic/243640-problems-with-insert-query-please-help-urgent/#findComment-1250997 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()); Link to comment https://forums.phpfreaks.com/topic/243640-problems-with-insert-query-please-help-urgent/#findComment-1250999 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.... Link to comment https://forums.phpfreaks.com/topic/243640-problems-with-insert-query-please-help-urgent/#findComment-1251001 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 Link to comment https://forums.phpfreaks.com/topic/243640-problems-with-insert-query-please-help-urgent/#findComment-1251005 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!!!! Link to comment https://forums.phpfreaks.com/topic/243640-problems-with-insert-query-please-help-urgent/#findComment-1251029 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.