Solved

imagecreatefromstring undefinded?

Posted on 2004-08-12
5
1,312 Views
Last Modified: 2013-12-12
Hi,

can someone tell me why this piece of code:


    /**
    * Loads an image from a string (e.g. database)
    * @param string the image
    * @param mime mime type of the image
    * @return boolean
    * @access public
    */
    function loadData ($image,$mime) {
        if ( in_array($mime,$this->types) ) {
            $this->source=imagecreatefromstring($image);
            $this->sourceWidth=imagesx($this->source);
            $this->sourceHeight=imagesy($this->source);
            $this->sourceMime=$mime;
            $this->initThumb();
            return true;
        } else {
            trigger_error('Image MIME type '.$mime.' not supported');
            return false;
        }
    }

produces an error telling me imagecreatefromstring is not defined? Urgent.
0
Comment
Question by:Wojciech Duda
5 Comments
 
LVL 3

Expert Comment

by:thecode101
ID: 11783907
What version of php are you using?
0
 
LVL 7

Expert Comment

by:madwax
ID: 11783913
Hi mcwojtekk,

The piece of code you have there is a part of a class, which I don't know if you have. On the row:
$this->source=imagecreatefromstring($image);

You are namely calling an function called: "imagecreatefromstring" with a parameter $image. This function must be defined somewhere and it isn't in the piece of code you have provided. If you have the function in the class try to put $this-> infront of so that you get:

$this->source=$this->imagecreatefromstring($image);

Good luck!
//madwax

Cheers!
0
 
LVL 8

Author Comment

by:Wojciech Duda
ID: 11784003
I have installed EasyPHP 1.7. I have the full class but it was coded by someone else. Now if I try to view the page this error comes up:

Fatal error: Call to undefined function: imagecreatefromstring() in c:\program files\easyphp1-7\www\*******_intranet\includes\lib\thumbnail.php on line 174

From what I understand this function is part of php, why the 'undefined' error?
0
 
LVL 33

Accepted Solution

by:
snoyes_jw earned 500 total points
ID: 11784099
imagecreatefromstring requires the GD library.  You can check if this is enabled by using this code:

<?php
var_dump(gd_info());
?>

If that produces an undefined function error, you need to enable GD.  Find the file php.ini (probably in the windows directory) and check that the line extension=php_gd2.dll is not commented (does not have a leading semi-colon).  The version of PHP included with EasyPHP should have a built-in version of GD; if not, check the first link below for further instructions.

http://us2.php.net/manual/en/ref.image.php
http://us2.php.net/manual/en/function.imagecreatefromstring.php
0
 
LVL 8

Author Comment

by:Wojciech Duda
ID: 11785828
Editing the php.ini helped. Thanks a lot.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question