0

How can i update if Image field in MYSQL is empty or no image is uploaded?

I tried this but doesnt update anything.

     UPDATE `db`.`ts126` SET `Image` = LOAD_FILE('C:\Users\user\Desktop\aa\bb\cc\placeholder.png') WHERE Image="" 

Also i tried

    UPDATE `db`.`ts126`
   SET `Image` = 'C:\Users\user\Desktop\aa\bb\cc\placeholder.png'
 WHERE Image="" OR Image IS NULL

Which is without LOAD_FILE in this case it updates the images [BLOB - 64 B] but When i display the image using PHP code Nothing shows up

1
  • subject says "null". you can NOT test for null with =. try where image is null instead Commented Dec 3, 2015 at 21:53

1 Answer 1

1

Try:

UPDATE `db`.`ts126`
  SET `Image` = LOAD_FILE('C:\Users\user\Desktop\aa\bb\cc\placeholder.png')
WHERE Image="" OR Image IS NULL
Sign up to request clarification or add additional context in comments.

11 Comments

Can i Update image field without LOAD_FILE something is wrong with this command and my database i tired using it several time but no luck
Are you sure your path is correct? What is the size of the file? Can you add SHOW CREATE TABLE db.ts126 and the result of SELECT @@max_allowed_bytes?
the Size of the file is 27Kb and Limit is (Max: 131 kKiB) where do i add that code next to update command?
I tried update all without Load_File and from PHP doesn't show the image and on mysql it shown me [BLOB - 64 B]
Sorry I'm not too clear on your problem. Can you update the question with the code you're running and the output?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.