0

I have been up and down the Internet for some simple solution and I am simply not finding it. I even opened questions on Stackoverflow with sample code and I've been told that everything is wrong in the code. Then, I don't know what I am doing and my questions get closed IMMEDIATELY. It doesn't make any sense.

All I want to be able to do is Query MySQL database for a text string and then convert it into an image to display on the web browser using PHP and GD Library.

Query Database

Retrieve a TEXT or a STRING (ALPHANUMERIC like any words in English Language) from a MySQL database.

Create an Image using that text for displaying on the browser.

Very similar to what I found on another question, but their answer doesn't work even though it was chosen as a working answer. GD Library image generation does not work with mySQL query My issue is that I can't Query my database for text and create an image of that text all at once on the same page. Very simple example would be helpful.

Please, help.

ThN
  • 3,235
  • 3
  • 57
  • 115

2 Answers2

0

If you are looking to change Base64 string of image, this may be the answer

$entry = base64_decode($stringFromdDatabase);
$image_data = imagecreatefromstring($entry);
$fileName = "sample.jpg";

$dir = [PATH TO WHERE YOU NEED TO STORE IMAGE] . $fileName;
imagejpeg($image_data, $dir);
imagedestroy($image_data);

OR CHECK this answer THIS FOR Words to Image GD Library image generation does not work with mySQL query

Sayd Fuad
  • 313
  • 2
  • 14
  • 1
    Thank you... I just figured out how to do it. What surprises me is that a lot of the programmers on this site only want to point out your mistakes and not give you helpful hints or info even if they don't know what you are talking about... Thank you again Sayd Faud. – ThN Jun 02 '20 at 19:03
0

Since I spent 2 whole day trying to find solution to this question, I am going to post my answer and I feel my answer will help others.

If you want to QUERY alphanumeric TEXT from your MySQL Database and then turn it into an Image of your choice like jpg, png, gif, etc using PHP and GD library right after, you must use PHP Data Objects or PDO for your MySQL DataBase Connection and SQL Query. It looks like for somethings, mysql connection and mysqli connection is no longer supported.

ThN
  • 3,235
  • 3
  • 57
  • 115
  • *"mysql connection and mysqli connection is no longer supported."* - Since when is mysqli_ no longer supported? Mysql_ sure, but not mysqli_, where did you hear that from? – Funk Forty Niner Jun 05 '20 at 14:24