Solved

imagecreatefromstring undefinded?

Posted on 2004-08-12
5
1,301 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
WooCommerce Sort by Date 4 6
creating 2 user ID's 5 25
Help cleaning out CSS 2 24
Tracking Bouncebacks in PHPMailer 2 4
Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now