dongtu9823 2013-01-29 12:27 采纳率: 0%
浏览 4
已采纳

来自函数的PHP图像

I am a php newbie so please go easy.

I created queries for imgFld and imageFldName. I am trying to find why my images from my db are not being displayed.

I have the below code:

image_show(stripslashes($row['imgFld']),stripslashes($row['imageFldName']));

echo ' '.$records_num;

function image_show($name_image, $alt_tag) {

    if (file_exists("mywebsite.co.uk/images/'$name_image'")) {
        $img = getimagesize('mywebsite.co.uk/images/'.$name_image);
        echo '<img src="mywebsite.co.uk/images/'.$name_image.'" alt = '.$alt_tag.' border=0 align="bottom"';
        echo 'width = '. $img[0] .' height = ' .$img[1] . ' />';
    } else {
        echo 'Add an image here';
    }

}

Im getting the image names from a column inside my db and each column has an 'image.jpg', connecting it with the img src script from HTML so that I can display the images from the db.

However no images are being displayed and I cant find the error. Doesnt seem like anything is wrong. When I echo $name_image nothing is produced.

  • 写回答

2条回答 默认 最新

  • dongzhuner6981 2013-01-29 12:28
    关注

    In that case it means that there is nothing populating the $name_image variable.

    Assuming that website directory is a local one, the cause of this is most likely your arguments when you call the image_show function. They do not match the order you have specified.

    The first argument should be the name and the second the alt text, as defined:

    function image_show($name_image, $alt_tag)
    

    However you are passing the id to $name_image and the name as $alt_tag.

    That should be it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图