Problem adding an image to database using SQL [duplicate]
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
mariadb mysql-loadfile
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.
add a comment |
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
mariadb mysql-loadfile
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
add a comment |
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
mariadb mysql-loadfile
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
mariadb mysql-loadfile
edited Nov 14 '18 at 16:51
jww
53.1k39226499
53.1k39226499
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
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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.
add a comment |
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
?)
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 14 '18 at 3:38
JsonJson
135
135
add a comment |
add a comment |
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
?)
add a comment |
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
?)
add a comment |
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
?)
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
?)
answered Nov 14 '18 at 16:03
Rick JamesRick James
68.1k559100
68.1k559100
add a comment |
add a comment |
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