please help error with graphics!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
anmol
Forum Newbie
Posts: 7
Joined: Sat Mar 06, 2004 7:25 pm

please help error with graphics!

Post by anmol »

When I try to run my random.php file through browser it gives me this error
"Warning: imagepng(): Unable to open 'a.png' for writing in /www/htdocs/random.php on line 20"

This is my PHP Code

Code: Select all

code

<?php

$img_number = imagecreate(100,50);

$white = imagecolorallocate($img_number,255,255,255);

$black = imagecolorallocate($img_number,0,0,0);

$grey_shade = imagecolorallocate($img_number,204,204,204);

imagefill($img_number,0,0,$grey_shade);

ImageRectangle($img_number,1000,500,95,44,$black);

ImageRectangle($img_number,1000,500,99,99,$black);

$number = "Sensor1";


imagePNG($img_number,"a.png");

?>

Code: Select all

Can you guide me what am I doing wrong here


I tried "/home/anmol/a.png" also but same error.

Sincerely,

Anmol Misra
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

error message wrote: Unable to open 'a.png' for writing
the error message is telling you what is wrong

further divulging -either its 1
1- a.png isnt there
2- you are not being case-sensitive
3- you are not 'owner' of the directory and cant read /write to it

just a few reasons why it could be
Post Reply