/    Sign up×
Community /Pin to ProfileBookmark

skip over code

The below code sets the size the image should be displayed. The problem is sometimes the value $row[‘image_name’] could be blank. when its blank i get this error message

Warning: getimagesize() [function.getimagesize]: Read error! in /mnt/w0400/d11/s01/b02a5c57/www/familyclick.ca/photos/photos.php on line 114

thats because $row[‘image_name’] is blank.

any ideas how to over come this the below is not working

[code=php]
if(!$row[‘image_name’] = “”){
$image = “../user_images/”.$row[‘image_name’];
$tempimg = getImageSize($image);
$size = $tempimg[3];
$size = explode(“””,$size);
$width = $size[1];
$height = $size[3];

$newwidth=100;
$newheight=($height/$width)*100;
}

if($row[‘image_name’] = “”){

$newwidth=100;
$newheight=90;
}

[/code]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@pcthugJul 19.2007 — Judging by the first line in your code, I think you may need to study up on your php [url=http://au2.php.net/operators.comparison]Comparison Operators[/url]. To look for non equal values you should use the [font=courier new]!=[/font] operator. So your first line should have been

[code=php]
if ($row['image_name'] != ""){
[/code]


But I'd suggest using the following code

[code=php]
$newwidth = 100;
$newheight = 90;

if (!empty($row['image_name']))
{
list ($width, $height) = getimagesize("../user_images/{$row['image_name']}");
$newheight = ($height/$width) * 100;
}
[/code]


If you unsure about anything feel free to ask.
×

Success!

Help @kproc spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...