View previous topic :: View next topic |
Author |
Message |
john76 -
Joined: 16 Jun 2005 Posts: 22 Location: Middlesbrough
|
Posted: Sat Oct 29, 2005 2:54 am Post subject: Cant seem to get GD working |
|
|
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 |
|
 |
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Sat Oct 29, 2005 3:56 am Post subject: |
|
|
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 |
 |
 |
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Sat Oct 29, 2005 9:22 am Post subject: Re: Cant seem to get GD working |
|
|
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 |
|
 |
john76 -
Joined: 16 Jun 2005 Posts: 22 Location: Middlesbrough
|
Posted: Sat Oct 29, 2005 11:37 am Post subject: not giving any error messages |
|
|
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 |
|
 |
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Sat Oct 29, 2005 11:49 am Post subject: Re: not giving any error messages |
|
|
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 |
 |
 |
john76 -
Joined: 16 Jun 2005 Posts: 22 Location: Middlesbrough
|
Posted: Sat Oct 29, 2005 12:31 pm Post subject: still no errors |
|
|
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 |
|
 |
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Sat Oct 29, 2005 11:09 pm Post subject: Re: still no errors |
|
|
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 |
 |
 |
john76 -
Joined: 16 Jun 2005 Posts: 22 Location: Middlesbrough
|
Posted: Sun Oct 30, 2005 11:30 am Post subject: in windows |
|
|
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 |
|
 |
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Sun Oct 30, 2005 12:35 pm Post subject: |
|
|
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 |
 |
 |
john76 -
Joined: 16 Jun 2005 Posts: 22 Location: Middlesbrough
|
Posted: Sun Oct 30, 2005 2:22 pm Post subject: script from hell |
|
|
changed as above, and still no joy.
Maybe I should just accept that it's not going to work! lol _________________
 |
|
Back to top |
|
 |
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Sun Oct 30, 2005 2:56 pm Post subject: |
|
|
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 |
 |
 |
roganty -
Joined: 08 Jun 2004 Posts: 357 Location: Bristol, UK
|
|
Back to top |
|
 |
john76 -
Joined: 16 Jun 2005 Posts: 22 Location: Middlesbrough
|
|
Back to top |
|
 |
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Mon Oct 31, 2005 2:27 am Post subject: |
|
|
404s on both. _________________
 |
|
Back to top |
 |
 |
john76 -
Joined: 16 Jun 2005 Posts: 22 Location: Middlesbrough
|
Posted: Mon Oct 31, 2005 4:49 am Post subject: I give in |
|
|
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 |
|
 |
RTAdams89 -
Joined: 06 Nov 2005 Posts: 102
|
Posted: Sun Nov 06, 2005 4:40 am Post subject: |
|
|
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 |
|
 |
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Sun Nov 06, 2005 12:01 pm Post subject: |
|
|
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 |
 |
 |
RTAdams89 -
Joined: 06 Nov 2005 Posts: 102
|
Posted: Sun Nov 06, 2005 11:39 pm Post subject: |
|
|
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 |
|
 |
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Mon Nov 07, 2005 10:35 am Post subject: |
|
|
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 |
|
 |
RTAdams89 -
Joined: 06 Nov 2005 Posts: 102
|
Posted: Mon Nov 07, 2005 2:49 pm Post subject: |
|
|
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 |
|
 |
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Tue Nov 08, 2005 10:44 am Post subject: |
|
|
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 |
|
 |
|