Cant seem to get GD working

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
john76
-


Joined: 16 Jun 2005
Posts: 22
Location: Middlesbrough

PostPosted: Sat Oct 29, 2005 2:54 am    Post subject: Cant seem to get GD working Reply with quote

Having a little poblem the script below creating thumbs on the fly. I don't know wheather I have set php.ini correctly or its the script itself. I've uncommented the gd2.dll bit in php.ini. But still nothing. Any help would be most appreciated.

the site where the script is from, with a working example...

http://evoluted.net/archives/2005/08/directory_listi_2.php
_________________
Back to top View user's profile Send private message Visit poster's website MSN Messenger
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Sat Oct 29, 2005 3:56 am    Post subject: Reply with quote

Does it give errors? If so, which?
Make sure you actually have php_gd2.dll, too. Find the extension_dir directive in php.ini, make sure that php_gd2.dll exists at that path.
If not, then make sure the php.ini you edited is in C:\WINDOWS (Or the Directory you installed PHP, under linux.), as C:\WINDOWS is the first place it looks for it.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Sat Oct 29, 2005 9:22 am    Post subject: Re: Cant seem to get GD working Reply with quote

john76,

What are the error messages you get? Knowing them will help us narrow the search space.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
john76
-


Joined: 16 Jun 2005
Posts: 22
Location: Middlesbrough

PostPosted: Sat Oct 29, 2005 11:37 am    Post subject: not giving any error messages Reply with quote

Its not giving any error messages, its just not creating the thumbnail images as the original script does.
I have the gd2.dll in the ext dir. I installed php using the tutorial from trustPunks site. I turned the show all errors comment on, and ran the script but no errors came up. But come to think about it, I've had problems creating pics/thumbnails using gd2 before.
Is there any other little changes that needs to be made in php.ini to get gd2 working?

john
_________________
Back to top View user's profile Send private message Visit poster's website MSN Messenger
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Sat Oct 29, 2005 11:49 am    Post subject: Re: not giving any error messages Reply with quote

john76 wrote:
Its not giving any error messages, its just not creating the thumbnail images as the original script does.
I have the gd2.dll in the ext dir. I installed php using the tutorial from trustPunks site. I turned the show all errors comment on, and ran the script but no errors came up. But come to think about it, I've had problems creating pics/thumbnails using gd2 before.
Is there any other little changes that needs to be made in php.ini to get gd2 working?

john


Stick error_reporting(E_ALL) as the first thing on your script, and see if any notices/errors appear.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
john76
-


Joined: 16 Jun 2005
Posts: 22
Location: Middlesbrough

PostPosted: Sat Oct 29, 2005 12:31 pm    Post subject: still no errors Reply with quote

I've put a show error sript into the php and still nothing.

Here is the page on my site, it may be easier to see what problems I'm having if you see it for yourself...

http://tripstar.no-ip.org/upload/files/list.php

and this is the error reporting script I added

Code:

error_reporting(E_ALL);
ini_set(“display_errors”, “on”);
ini_set(“log_errors”, “on”);
ini_set(“error_log”, “styleetrip.txt”);


many thanks again for your responces

John
_________________
Back to top View user's profile Send private message Visit poster's website MSN Messenger
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Sat Oct 29, 2005 11:09 pm    Post subject: Re: still no errors Reply with quote

john76 wrote:
I've put a show error sript into the php and still nothing.

Here is the page on my site, it may be easier to see what problems I'm having if you see it for yourself...

http://tripstar.no-ip.org/upload/files/list.php

and this is the error reporting script I added

Code:

error_reporting(E_ALL);
ini_set(“display_errors”, “on”);
ini_set(“log_errors”, “on”);
ini_set(“error_log”, “styleetrip.txt”);


many thanks again for your responces

John


I take it you're not using the php.ini in C:\WINDOWS, copy & paste the one you're using into C:\WINDOWS, setting error_reporting to at least E_ALL & ~E_NOTICE & ~E_STRICT.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
john76
-


Joined: 16 Jun 2005
Posts: 22
Location: Middlesbrough

PostPosted: Sun Oct 30, 2005 11:30 am    Post subject: in windows Reply with quote

yeah, my php.ini is in the windows directory. I've installed php using trustpunks tutorial.
And I used the error settings too. and still no errors.
_________________
Back to top View user's profile Send private message Visit poster's website MSN Messenger
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Sun Oct 30, 2005 12:35 pm    Post subject: Reply with quote

In dlf/i.php, Change:
Code:
if ($type == 'jpg' || $type == 'jpeg') $img = @imagecreatefromjpeg($filename);
elseif ($type == 'png') $img = @imagecreatefrompng($filename);
elseif ($type == 'gif')  {
   if(!function_exists('imagecreatefromgif')) die('Error: Your version of GD does not support GIFs');
   $img = @imagecreatefromgif($filename);
}

With:
Code:
if ($type == 'jpg' || $type == 'jpeg') $img = imagecreatefromjpeg($filename);
elseif ($type == 'png') $img = imagecreatefrompng($filename);
elseif ($type == 'gif')  {
   if(!function_exists('imagecreatefromgif')) die('Error: Your version of GD does not support GIFs');
   $img = imagecreatefromgif($filename);
}

_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
john76
-


Joined: 16 Jun 2005
Posts: 22
Location: Middlesbrough

PostPosted: Sun Oct 30, 2005 2:22 pm    Post subject: script from hell Reply with quote

changed as above, and still no joy.
Maybe I should just accept that it's not going to work! lol
_________________
Back to top View user's profile Send private message Visit poster's website MSN Messenger
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Sun Oct 30, 2005 2:56 pm    Post subject: Reply with quote

Okay. Ideas:
- Copy & paste the correct php.ini into wherever you installed PHP.
- Paste example one off of http://php.net/manual/en/function.set-error-handler.php into the top of i.php.
- Run the script in in CGI mode. (Not ideal, more of a last resort, cause no $_SERVER variables will get passed.)
- Search your system for php.ini and delete them all.
- Put an echo "Okay.<br />\n" after every line to find out where the error is, when viewing http://tripstar.no-ip.org/upload/files/dlf/i.php?f=1st.jpg.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
roganty
-


Joined: 08 Jun 2004
Posts: 357
Location: Bristol, UK

PostPosted: Sun Oct 30, 2005 3:44 pm    Post subject: Reply with quote

This may sound simple, but are the paths to the files correct?

the php script is located in /upload/files/dlf/ http://tripstar.no-ip.org/upload/files/dlf/i.php
and the images in /upload/files/ http://tripstar.no-ip.org/upload/files/1st.jpg
_________________
Anthony R

Roganty
| Links-Links.co.uk
Back to top View user's profile Send private message Visit poster's website
john76
-


Joined: 16 Jun 2005
Posts: 22
Location: Middlesbrough

PostPosted: Sun Oct 30, 2005 5:22 pm    Post subject: Reply with quote

Right, tried all of monkeynations ideas..
click link to see error report as copied from ex1 script

http://tripstar.no-ip.org/upload/files/dlf/i.php?f=1st.jpg.

When echoes are added, nothing is shown....

http://tripstar.no-ip.org/upload/files/dlf/test.php


and to roganty, all the files are in the right places
_________________
Back to top View user's profile Send private message Visit poster's website MSN Messenger
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Mon Oct 31, 2005 2:27 am    Post subject: Reply with quote

john76 wrote:
Right, tried all of monkeynations ideas..
click link to see error report as copied from ex1 script

http://tripstar.no-ip.org/upload/files/dlf/i.php?f=1st.jpg.

When echoes are added, nothing is shown....

http://tripstar.no-ip.org/upload/files/dlf/test.php


and to roganty, all the files are in the right places


404s on both.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
john76
-


Joined: 16 Jun 2005
Posts: 22
Location: Middlesbrough

PostPosted: Mon Oct 31, 2005 4:49 am    Post subject: I give in Reply with quote

I've decide to use another script, although some what naff, i does what I want.

So, thanks for all your help, and I guess it must have been a dodgy script or something!

John
_________________
Back to top View user's profile Send private message Visit poster's website MSN Messenger
RTAdams89
-


Joined: 06 Nov 2005
Posts: 102

PostPosted: Sun Nov 06, 2005 4:40 am    Post subject: Reply with quote

I to am having issues. When I first installed the script, it listed files fine, but it wouldn't display thumbnails (it didn't even show a blank box or anything). I then changed
Code:
<?
if($showthumbnails) {
?>
<script language="javascript" type="text/javascript">
<!--
function o(n, i) {
   document.images['thumb'+n].src = 'dlf/i.php?f='+i;

}

function f(n) {
   document.images['thumb'+n].src = 'dlf/trans.gif';
}
//-->
</script>
<?
}
?>


to

Code:
<?
if($showthumbnails=true) {
?>
<script language="javascript" type="text/javascript">
<!--
function o(n, i) {
   document.images['thumb'+n].src = 'dlf/i.php?f='+i;

}

function f(n) {
   document.images['thumb'+n].src = 'dlf/trans.gif';
}
//-->
</script>
<?
}
?>


And it now displays a box with a red x where the image should be. Has any one else found a solution to this?
Back to top View user's profile Send private message
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Sun Nov 06, 2005 12:01 pm    Post subject: Reply with quote

RTAdams89 ->
It would need to be if($showthumbnails==true) (I.E. Double = sign.), although that didn't need changing.

It seems to work fine on my computer on PHP 5 and 4 and on abyss and apache.
If it didn't show the box at all, make sure that the GD module is enabled and correctly loaded.
I can't see any other reason it wouldn't work, though.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
RTAdams89
-


Joined: 06 Nov 2005
Posts: 102

PostPosted: Sun Nov 06, 2005 11:39 pm    Post subject: Reply with quote

After some tweaking of my php.ini the script displays the thumbnail box with out any modifications. However it shows a red x instead of the thumbnail. Looking at my error log i see

Code:
PHP Fatal error:  Only variables can be passed by reference in C:\web\test\dlf\i.php on line 7


Here is the first part of "i.php":

Code:
<?php
$filename = '../'.$_REQUEST['f'];

if(!file_exists($filename)) die('Error: File does not exist');
if(!function_exists('imagecreatetruecolor')) die('Error: GD2 not installed / configured');

$type = strtolower(end(explode('.', $filename)));
if ($type == 'jpg' || $type == 'jpeg') $img = @imagecreatefromjpeg($filename);
elseif ($type == 'png') $img = @imagecreatefrompng($filename);
elseif ($type == 'gif')  {
   if(!function_exists('imagecreatefromgif')) die('Error: Your version of GD does not support GIFs');
   $img = @imagecreatefromgif($filename);
}
else die("Error: Image type not supported");


Since this is working for other people it must be my web server's settings (or PHP's). Any ideas as to what the problem is?
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Mon Nov 07, 2005 10:35 am    Post subject: Reply with quote

RTAdams89 wrote:

Code:
PHP Fatal error:  Only variables can be passed by reference in C:\web\test\dlf\i.php on line 7



This is a new bug (or behavior, if PHP people still insist on that) that was introduced with PHP 5.0.5. Google for "Only variables can be passed by reference" and you'll see that all PHP scripts are broken with this new error and people are complaining all over the place.

The PHP bug report (and discussion) is in http://bugs.php.net/bug.php?id=33643 .

Either change your code to avoid the buggy pattern or downgrade to PHP 5.0.4.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
RTAdams89
-


Joined: 06 Nov 2005
Posts: 102

PostPosted: Mon Nov 07, 2005 2:49 pm    Post subject: Reply with quote

Not knowing anything about PHP, is there a easy way to change that code to work with 5.0.5?

If i installed PHP following the tutorial, how do I go about downgrading? Just download the 5.0.4 binary and copy the EXE files into my PHP folder?
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Tue Nov 08, 2005 10:44 am    Post subject: Reply with quote

RTAdams89,

The problem with your code is with the use of end().

end() expects a variable containing an array as a parameter. But you're giving it a result of the execution of another function. This was tolerated with previous releases but it is no more accepted by PHP.

So all you have to do is to replace:

Code:
$type = strtolower(end(explode('.', $filename)));


with

Code:
$fn_array = explode('.', $filename);
$type = strtolower(end($fn_array));

_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group