Show only certain images

images php coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
User avatar
sandeep605085
New php-forum User
New php-forum User
Posts: 44
Joined: Tue Feb 26, 2013 6:00 am
Location: Mindfire Solutions
Contact:

Mon May 06, 2013 4:55 am

Hi,

I guess there is a problem in executing either of the below sql query.

"SELECT * FROM `cardId` WHERE `status` = '1' ORDER BY `id` ASC LIMIT 10 ";
"SELECT * FROM `images` WHERE `cid` = '$row->id'";

please echo the query and check it by running it directly from mysql command line or mysql query browser to check if query is getting executed.

Thanks,
Sandeep Agrawal
Mindfire Solutions

User avatar
sandeep605085
New php-forum User
New php-forum User
Posts: 44
Joined: Tue Feb 26, 2013 6:00 am
Location: Mindfire Solutions
Contact:

Tue May 07, 2013 6:33 am

Please check at below line
$img = imagecreatefromstring($results2->img);

try echo $results2->img; and check that if it is giving a blank value or any thing other than string as
"imagecreatefromstring" accepts a string containing the image data.

then

$height = $imagesy($img);

is $imagesy is a function? i guess $ should not be there and it should be
$height = imagesy($img);

Thanks,
Sandeep Agrawal
Mindfire Solutions.

User avatar
sandeep605085
New php-forum User
New php-forum User
Posts: 44
Joined: Tue Feb 26, 2013 6:00 am
Location: Mindfire Solutions
Contact:

Tue May 07, 2013 10:18 am

the actual error is at below line that value passed to imagecreatefromstring function is not a valid string.
$img = imagecreatefromstring($results2);

$result2 will return an array and as i told you that imagecreatefromstring accepts string but now you are passing array to it.
$results2 = $query2->fetchAll();

your previous code was correct which was
$img = imagecreatefromstring($results2->img);

but you know better than me that what is the value of $results2->img. if exists or not, if any field is present in database table or not.

solution for other two error depends on $img value as you are passing $img to below two function and $img value comes from imagecreatefromstring($results2->img);

$height = imagesy($img);
$width = imagesx($img);

Thanks,
Sandeep Agrawal
Mindfire Solutions

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest