Problem adding an image to database using SQL [duplicate]












-1
















This question already has an answer here:




  • How to use LOAD_FILE to load a file into a MySQL blob?

    5 answers




INSERT INTO items (id,name,image,price) VALUES('1','iphone 5s',LOAD_FILE('C:xampphtdocsproject1.jpg'),300);


this statement cause error



INSERT INTO items (id,name,image,price) VALUES('1','iphone 5s',LOAD_FILE('C:xampphtdocsproject1.jpg'),300)
MySQL said: Documentation


here is the error



#1048 - Column 'image' cannot be null









share|improve this question















marked as duplicate by Madhur Bhaiya, jww, Makyen, sideshowbarker, Pearly Spencer Nov 15 '18 at 1:25


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • Pick a single database engine - the code required will be specific to that engine. SQL Server has no load_file function.

    – SMor
    Nov 14 '18 at 3:22











  • i used maria db.

    – Anupama Dikkumbura
    Nov 14 '18 at 3:34






  • 3





    Possible duplicate of MySQL LOAD_FILE is not working as expected, How do I use LOAD_FILE to insert value from a file into a table?, LOAD_FILE returns NULL, etc.

    – jww
    Nov 14 '18 at 16:48


















-1
















This question already has an answer here:




  • How to use LOAD_FILE to load a file into a MySQL blob?

    5 answers




INSERT INTO items (id,name,image,price) VALUES('1','iphone 5s',LOAD_FILE('C:xampphtdocsproject1.jpg'),300);


this statement cause error



INSERT INTO items (id,name,image,price) VALUES('1','iphone 5s',LOAD_FILE('C:xampphtdocsproject1.jpg'),300)
MySQL said: Documentation


here is the error



#1048 - Column 'image' cannot be null









share|improve this question















marked as duplicate by Madhur Bhaiya, jww, Makyen, sideshowbarker, Pearly Spencer Nov 15 '18 at 1:25


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • Pick a single database engine - the code required will be specific to that engine. SQL Server has no load_file function.

    – SMor
    Nov 14 '18 at 3:22











  • i used maria db.

    – Anupama Dikkumbura
    Nov 14 '18 at 3:34






  • 3





    Possible duplicate of MySQL LOAD_FILE is not working as expected, How do I use LOAD_FILE to insert value from a file into a table?, LOAD_FILE returns NULL, etc.

    – jww
    Nov 14 '18 at 16:48
















-1












-1








-1









This question already has an answer here:




  • How to use LOAD_FILE to load a file into a MySQL blob?

    5 answers




INSERT INTO items (id,name,image,price) VALUES('1','iphone 5s',LOAD_FILE('C:xampphtdocsproject1.jpg'),300);


this statement cause error



INSERT INTO items (id,name,image,price) VALUES('1','iphone 5s',LOAD_FILE('C:xampphtdocsproject1.jpg'),300)
MySQL said: Documentation


here is the error



#1048 - Column 'image' cannot be null









share|improve this question

















This question already has an answer here:




  • How to use LOAD_FILE to load a file into a MySQL blob?

    5 answers




INSERT INTO items (id,name,image,price) VALUES('1','iphone 5s',LOAD_FILE('C:xampphtdocsproject1.jpg'),300);


this statement cause error



INSERT INTO items (id,name,image,price) VALUES('1','iphone 5s',LOAD_FILE('C:xampphtdocsproject1.jpg'),300)
MySQL said: Documentation


here is the error



#1048 - Column 'image' cannot be null




This question already has an answer here:




  • How to use LOAD_FILE to load a file into a MySQL blob?

    5 answers








mariadb mysql-loadfile






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 16:51









jww

53k39226495




53k39226495










asked Nov 14 '18 at 3:19









Anupama DikkumburaAnupama Dikkumbura

74




74




marked as duplicate by Madhur Bhaiya, jww, Makyen, sideshowbarker, Pearly Spencer Nov 15 '18 at 1:25


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Madhur Bhaiya, jww, Makyen, sideshowbarker, Pearly Spencer Nov 15 '18 at 1:25


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • Pick a single database engine - the code required will be specific to that engine. SQL Server has no load_file function.

    – SMor
    Nov 14 '18 at 3:22











  • i used maria db.

    – Anupama Dikkumbura
    Nov 14 '18 at 3:34






  • 3





    Possible duplicate of MySQL LOAD_FILE is not working as expected, How do I use LOAD_FILE to insert value from a file into a table?, LOAD_FILE returns NULL, etc.

    – jww
    Nov 14 '18 at 16:48





















  • Pick a single database engine - the code required will be specific to that engine. SQL Server has no load_file function.

    – SMor
    Nov 14 '18 at 3:22











  • i used maria db.

    – Anupama Dikkumbura
    Nov 14 '18 at 3:34






  • 3





    Possible duplicate of MySQL LOAD_FILE is not working as expected, How do I use LOAD_FILE to insert value from a file into a table?, LOAD_FILE returns NULL, etc.

    – jww
    Nov 14 '18 at 16:48



















Pick a single database engine - the code required will be specific to that engine. SQL Server has no load_file function.

– SMor
Nov 14 '18 at 3:22





Pick a single database engine - the code required will be specific to that engine. SQL Server has no load_file function.

– SMor
Nov 14 '18 at 3:22













i used maria db.

– Anupama Dikkumbura
Nov 14 '18 at 3:34





i used maria db.

– Anupama Dikkumbura
Nov 14 '18 at 3:34




3




3





Possible duplicate of MySQL LOAD_FILE is not working as expected, How do I use LOAD_FILE to insert value from a file into a table?, LOAD_FILE returns NULL, etc.

– jww
Nov 14 '18 at 16:48







Possible duplicate of MySQL LOAD_FILE is not working as expected, How do I use LOAD_FILE to insert value from a file into a table?, LOAD_FILE returns NULL, etc.

– jww
Nov 14 '18 at 16:48














2 Answers
2






active

oldest

votes


















0














Please double check the file path of your "1.jpg" or maybe look at the image format whether it is .jpg or .png.



Else, try this format:




LOAD_FILE('../1.jpg')




"Different backslash position"



I do not think you should mention the C:/xampp/htdocs/project because you are already in the project folder when you run your code.



Hopefully it is working.






share|improve this answer































    0














    You must escape backslashes in any string:



    ... LOAD_FILE('C:\xampp\htdocs\project\1.jpg') ...


    Or, since MySQL will 'correctly' interpret forward-slashes, even on Windows:



    ... LOAD_FILE('C:/xampp/htdocs/project/1.jpg') ...


    (I assume image is declared BLOB or MEDIUMBLOB?)






    share|improve this answer






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      Please double check the file path of your "1.jpg" or maybe look at the image format whether it is .jpg or .png.



      Else, try this format:




      LOAD_FILE('../1.jpg')




      "Different backslash position"



      I do not think you should mention the C:/xampp/htdocs/project because you are already in the project folder when you run your code.



      Hopefully it is working.






      share|improve this answer




























        0














        Please double check the file path of your "1.jpg" or maybe look at the image format whether it is .jpg or .png.



        Else, try this format:




        LOAD_FILE('../1.jpg')




        "Different backslash position"



        I do not think you should mention the C:/xampp/htdocs/project because you are already in the project folder when you run your code.



        Hopefully it is working.






        share|improve this answer


























          0












          0








          0







          Please double check the file path of your "1.jpg" or maybe look at the image format whether it is .jpg or .png.



          Else, try this format:




          LOAD_FILE('../1.jpg')




          "Different backslash position"



          I do not think you should mention the C:/xampp/htdocs/project because you are already in the project folder when you run your code.



          Hopefully it is working.






          share|improve this answer













          Please double check the file path of your "1.jpg" or maybe look at the image format whether it is .jpg or .png.



          Else, try this format:




          LOAD_FILE('../1.jpg')




          "Different backslash position"



          I do not think you should mention the C:/xampp/htdocs/project because you are already in the project folder when you run your code.



          Hopefully it is working.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 14 '18 at 3:38









          JsonJson

          135




          135

























              0














              You must escape backslashes in any string:



              ... LOAD_FILE('C:\xampp\htdocs\project\1.jpg') ...


              Or, since MySQL will 'correctly' interpret forward-slashes, even on Windows:



              ... LOAD_FILE('C:/xampp/htdocs/project/1.jpg') ...


              (I assume image is declared BLOB or MEDIUMBLOB?)






              share|improve this answer




























                0














                You must escape backslashes in any string:



                ... LOAD_FILE('C:\xampp\htdocs\project\1.jpg') ...


                Or, since MySQL will 'correctly' interpret forward-slashes, even on Windows:



                ... LOAD_FILE('C:/xampp/htdocs/project/1.jpg') ...


                (I assume image is declared BLOB or MEDIUMBLOB?)






                share|improve this answer


























                  0












                  0








                  0







                  You must escape backslashes in any string:



                  ... LOAD_FILE('C:\xampp\htdocs\project\1.jpg') ...


                  Or, since MySQL will 'correctly' interpret forward-slashes, even on Windows:



                  ... LOAD_FILE('C:/xampp/htdocs/project/1.jpg') ...


                  (I assume image is declared BLOB or MEDIUMBLOB?)






                  share|improve this answer













                  You must escape backslashes in any string:



                  ... LOAD_FILE('C:\xampp\htdocs\project\1.jpg') ...


                  Or, since MySQL will 'correctly' interpret forward-slashes, even on Windows:



                  ... LOAD_FILE('C:/xampp/htdocs/project/1.jpg') ...


                  (I assume image is declared BLOB or MEDIUMBLOB?)







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 14 '18 at 16:03









                  Rick JamesRick James

                  67.4k558100




                  67.4k558100















                      Popular posts from this blog

                      List item for chat from Array inside array React Native

                      Xamarin.iOS Cant Deploy on Iphone

                      App crashed after uploaded to heroku server