Jump to content

*fixed*


leeming

Recommended Posts

*edit* ive located the error, read down to my later posts



hey, im asking for help with this function, as i dont have much experiance with it... i am looking after a site of a friends while he is away... and this image was working (and has been working) for ages.. but just the other day, it decided to give the red X (for ie)...

so with this, im trying to edit the code a little... but it isnt fixing any thing (im trying to get it to save to a file, insead of just ouputting it stright away)

this is what i have

[code]
$mapid= "map".$numb.".png";

imagepng ($im, $mapid);[/code]

$numb, been a number between 1 and 7, for 7 different maps. so:
map1.png
map2.png
map3.png
... etc

but that code isnt saving to the file as im trying to do... any reasons why?
Link to comment
Share on other sites

imagepng(); returns a boolean value, check what you get whenever you put it in an if/else statement

[code=php:0]
$mapid = "map".$numb.".png";
if (imagepng($im, $mapid)) {
  // should have been written to file.
} else {
  // not working
}
[/code]

if this is not working, then please post the full code, so we can have an in-depth view.
Link to comment
Share on other sites

[quote author=ignace link=topic=103088.msg410223#msg410223 date=1154789813]
imagepng(); returns a boolean value, check what you get whenever you put it in an if/else statement

[code=php:0]
$mapid = "map".$numb.".png";
if (imagepng($im, $mapid)) {
  // should have been written to file.
} else {
  // not working
}
[/code]

if this is not working, then please post the full code, so we can have an in-depth view.
[/quote]

well posting the whole code would be quite confusing.. but... i did test to see if the code was all running, by placing "print" tags, to see if its getting to that line....
found out it was this line stopping the script..

[code]$im = @imagecreatefrompng ("./worldmap.png") or die ("Cannot Initialize new GD image stream");[/code]

so i took off the "@", to see the error (dont know why the or die wasnt working?)

i get this message...
[quote]
Fatal error: Call to undefined function: imagecreatefrompng() in [i]<dir>[/i] on line 8
[/quote]

i double checked by copy and pasting the function, into php.net, and yes it is spelt right... then i checked the php version.. and yes, i belive its valid for the php version (it has always ran before)...

any suggestions now?
Link to comment
Share on other sites

I am not using the GD library, so my help is limited, sorry, but I think the error code is quite clear, and that it ran before, sure, but that also had the @-sign in front of it, not? However "./worldmap.png" bothers me, try changing it to just "worldmap.png" and see what comes up!

I had this problem once with defined(); however the problem lay in one of my classes, what the actual cause was of the problem I can't remember! I don't even remember if it now was the class that was the problem or the class that solved it...
Link to comment
Share on other sites

[quote author=ignace link=topic=103088.msg410234#msg410234 date=1154791133]
I am not using the GD library, so my help is limited, sorry, but I think the error code is quite clear, and that it ran before, sure, but that also had the @-sign in front of it, not? However "./worldmap.png" bothers me, try changing it to just "worldmap.png" and see what comes up!

I had this problem once with defined(); however the problem lay in one of my classes, what the actual cause was of the problem I can't remember!
[/quote]

oh sorry, forgot to mention i tried "worldmap.png" and "./worldmap.png" (thats what it was orginaly)... and no diference...

i just looked up (copy paste) the error message onto google...
[quote]
If this error happens (mostly in the pixel selection) your GD library is not up-to-date or not installed fully. To create and read PNG images, the GD library supports normally the function imagecreatefrompng(). If not, your GD library is not complete.

hand.jpgPlease ask your provider regarding this issue and ask him to add the PNG support to the GD library of PHP. He will do this. Afterwards, the error will not shown again.
[/quote]

if there any way apart from the server admin changing things... for this error to show?... if not, i will have to bug the server admin, to ask if hes messed around with the GD library
Link to comment
Share on other sites

this is relaly weird....

[code]print"SORRY DEBUGGING...DONT BELIVE THE MAP!<BR><BR>";



  $im = @imagecreatefrompng("worldmap.png"); /* Attempt to open */
  if (!$im)
  {
      die('doesnt');
  }
  else
  {
    die('works');
  }

[/code]

it out puts...

[quote]SORRY DEBUGGING...DONT BELIVE THE MAP![/quote]


no "die" comment!?....
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.