Solutions for imagecreate () in the gd class library

Source: Internet
Author: User
The imagecreate () code in the gd class library is as follows: & lt ;? Php // header (& quot; content-type: image/png & quot;); include (& quot; config. php & quot;); $ s1 = & quot; SELECT * FROMquestionWHER about imagecreate () in the gd class library ()
The code is as follows:

// Header ("content-type: image/png ");
Include ("config. php ");
$ S1 = "SELECT * FROM question WHERE t = 0 ";
$ Result = mysql_query ($ s1 );
$ I = 0;
While ($ row = mysql_fetch_array ($ result ))
{
$ Id = $ row ["id"];
$ Content0 = $ row ["content"];
$ S2 = "SELECT * FROM question WHERE t = '$ ID '";
$ Result1 = mysql_query ($ s2 );
Echo"
















";Echo" ";While ($ rows = mysql_fetch_array ($ result1 )){$ Content = $ rows ["content"];$ Num = $ rows ["num"] * 10;$ Im = imagecreate ($ num, 20 );$ Black = imagecolorallocate ($ im, rand (0,254), rand (0,255), rand (0,255 ));$ Name = $ I;Imagepng ($ im, "E: \ apache \ htdocs \ image \ Logs ");Echo" ";Echo" ";Echo" ";Imagedestroy ($ im );$ I ++;}Echo"
". $ Content0 ."
". $ Content ."". ($ Num/10 )."
";
}
?>

When imagecreate is placed in a loop, the following error occurs: Warning: imagecreate () [function. imagecreate]: Invalid image dimensions.

Why is the output image a single image?

------ Solution --------------------
Warning: imagecreate () [function. imagecreate]: Invalid image dimensions: Invalid image size
Description: $ num = $ rows ["num"] * 10. here, $ rows ["num"] may be an empty string value. As for why it is null, it depends on your table design.
------ Solution --------------------
You fooled me.
Echo"";
OnlyThis is the result!
You need
Echo"";

To get



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.