redherring Posted January 25, 2008 Share Posted January 25, 2008 Hi there - Again, as a result of "upgrading" from php 4.3.8 to php 5.2.5 some dynamic image generation code has ceased to function. From what I can tell, the function "imagecreatefromgif" is still supported. I wonder if any of you would be SO kind as to take a quick peak at the code and see if anything jumps out at you as being "wrong". Thanks so much in advance. Here it is: ******************************** <?php header ("Content-type: image/png"); $clientID = $_GET['clientID']; $server = "localhost,1433"; $username = 'myusername'; $password = 'mypassword'; // // grab subscribed since year // $sqlconnect = mssql_connect($server, $username, $password); $sqldb = mssql_select_db("mydatabase1",$sqlconnect); $sqlquery = "SELECT DATEPART(yyyy, subscribed_since) AS 'subscribed_since_year' FROM mytablename1 WHERE clientID = $clientID;"; $result = mssql_query($sqlquery); while ($row=mssql_fetch_array($result)){ $subscribed_since = $row['subscribed_since_year'];} mssql_close($sqlconnect); // // grab companyname // $sqlconnect4 = mssql_connect($server, $username, $password); $sqldb4 = mssql_select_db("mydatabase1",$sqlconnect4); $sqlquery4 = "SELECT companyname AS 'clientname' FROM mytablename1 WHERE clientID = $clientID;"; $result4 = mssql_query($sqlquery4); while ($row=mssql_fetch_array($result4)){ $companyname = $row['clientname'];} mssql_close($sqlconnect4); // // grab positive feedback ratings // $sqlconnect2 = mssql_connect($server, $username, $password); $sqldb2 = mssql_select_db("mydatabase2",$sqlconnect2); $sqlquery2 = "SELECT rating FROM mytablename2 WHERE clientID = '$clientID' AND rating = 'positive';"; $result2 = mssql_query($sqlquery2); $ratings_positive = mssql_num_rows($result2); mssql_close($sqlconnect2); // // grab negative feedback ratings // $sqlconnect3 = mssql_connect($server, $username, $password); $sqldb3 = mssql_select_db("mydatabase2",$sqlconnect3); $sqlquery3 = "SELECT rating FROM mytablename2 WHERE clientID = '$clientID' AND rating = 'negative';"; $result3 = mssql_query($sqlquery3); $ratings_negative = mssql_num_rows($result3); mssql_close($sqlconnect3); $string_companyname_label = 'Company Name: '; $string_companyname = $companyname; if ( strlen($string_companyname) > 16) { $string_companyname = substr($string_companyname, 0, 16) . '..'; } $string1_label = 'Member Since: '; if ( $subscribed_since == '' ) { $string1 = 'na'; } else { $string1 = $subscribed_since; } $string2_label = 'Positive Customer Feedback Score: '; if ( $ratings_positive + $ratings_negative > 0 ) { $string2 = number_format(($ratings_positive / ($ratings_positive + $ratings_negative) * 100), 0, '.', '') . '%'; } else { $string2 = 'na'; } $font = 2; $font2 = 2; $width = ImageFontWidth($font)* strlen($string1_label) ; $width2 = ImageFontWidth($font)* strlen($string2_label) ; $width3 = ImageFontWidth($font)* strlen($string_companyname_label) ; $height = ImageFontHeight($font)* 2.5 ; $height2 = ImageFontHeight($font)* 1.25 ; $height3 = ImageFontHeight($font)* 3.75 ; $im = imagecreatefromgif("http://www.signsearch.com/images/feedback_image1b.gif"); $x = $width + 5; $x2 = $width2 + 5; $x3 = $width3 + 5; $y = imagesy($im)-$height; $y2 = imagesy($im)-$height2; $y3 = imagesy($im)-$height3; $background_color = imagecolorallocate ($im, 255, 255, 255); //white background $text_color = imagecolorallocate ($im, 3, 3, 108);//black text $text_color2 = imagecolorallocate ($im, 255, 0, 0);//red text imagestring ($im, $font2, 7, 21, $string_companyname, $text_color); // // remove member since detail // //imagestring ($im, $font, 92, 43, $string1, $text_color2); // imagestring ($im, $font, 92, 53, $string2, $text_color2); imagepng ($im); ?> ************************************* Link to comment https://forums.phpfreaks.com/topic/87845-php5-and-imagecreatefromgif/ Share on other sites More sharing options...
redherring Posted January 26, 2008 Author Share Posted January 26, 2008 Sorry... i know that's a bit of a dog's breakfast to post, but since I'm in Never Never Land on this one, I didn't want to take anything out in case that was the offending piece of code. Just to add that, browsing to the associated php file appending a value for the variable "clientID" of "xxxxx" simply renders a page with a broken image of property "feedback_image1b.php?clientID=xxxxx". Thanks again in advance for helping to sort this out. I hate it when things break... Link to comment https://forums.phpfreaks.com/topic/87845-php5-and-imagecreatefromgif/#findComment-449393 Share on other sites More sharing options...
redherring Posted January 26, 2008 Author Share Posted January 26, 2008 OK. I'm sorry. I was lazy. Chopped up the file to just this and it still won't work: **************************** <?php header ("Content-type: image/png"); $im = imagecreatefromgif("http://www.signsearch.com/images/feedback_image1b.gif"); imagepng ($im); ?> **************************** Soooooooooooooo... there must really be something fundamental missing from my php5 installation. Here's hoping that somebody can point me in the right direction. Thanks. Link to comment https://forums.phpfreaks.com/topic/87845-php5-and-imagecreatefromgif/#findComment-449425 Share on other sites More sharing options...
redherring Posted January 26, 2008 Author Share Posted January 26, 2008 And the following test, taken from elsewhere, also just renders a broken image: ************************************ <?php function LoadGif ($imgname) { $im = @imagecreatefromgif ($imgname); /* Attempt to open */ if (!$im) { /* See if it failed */ $im = imagecreatetruecolor (150, 30); /* Create a blank image */ $bgc = imagecolorallocate ($im, 255, 255, 255); $tc = imagecolorallocate ($im, 0, 0, 0); imagefilledrectangle ($im, 0, 0, 150, 30, $bgc); /* Output an errmsg */ imagestring ($im, 1, 5, 5, "Error loading $imgname", $tc); } return $im; } header("Content-Type: image/gif"); $img = LoadGif("bogus.image"); imagegif($img); ?> Link to comment https://forums.phpfreaks.com/topic/87845-php5-and-imagecreatefromgif/#findComment-449542 Share on other sites More sharing options...
cooldude832 Posted January 26, 2008 Share Posted January 26, 2008 you usually want to use imagedestroy($im) after you display it or store it also all the extra properties on imagepng imagegif imagejpg like the resolution and destination are required I believe in some version also remove your suppression of the errors (@) to see if that is an issue. Link to comment https://forums.phpfreaks.com/topic/87845-php5-and-imagecreatefromgif/#findComment-449556 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.