problem if i didn't upload any picture

Discussion in 'PHP' started by kumar84, Aug 10, 2007.

  1. #1
    Hai friends

    In my PHP CODING

    i did this


    <? $image_src = $userinfo [0]["pic"];
    $image_src1 =$userinfo [0]["pic_big"];
    $image_src2= $userinfo [0]["pic_small"];
    ?>

    <h2> Picture =<img src="<?php echo "$image_src"; ?>" > </h2><br>

    <h2> Picture(Big)=<img src="<?php echo "$image_src1"; ?>"></h2><br>

    <h2> Picture(Small)=<img src="<?php echo"$image_src2";?>"></h2><br>


    After running this coding Iam able to get the uploaded picture SUCCESSFULLY


    But in case i didn't upload any picture and i run this code means
    it is displaying error as


    Errors while loading page from application

    Runtime errors:

    HTML error while rendering tag "img": Missing required URLHTML error while rendering tag "img": Missing required URLHTML error while rendering tag "img": Missing required URL



    for me it want to display no picture has been uploaded
    So what i want do for this
    can anybody help me by rectifying this code in PHP
     
    kumar84, Aug 10, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    I would disabled HTML errors in php.ini.

    
    ini_set('html_errors', '0');
    
    PHP:
    Or you could do:
    
    <?php
    if (!empty($image_src))
    {
    ?>
        <h2> Picture =<img src="<?php echo $image_src; ?>" > </h2><br>
    <?php
    }
    ?>
    
    PHP:
     
    nico_swd, Aug 10, 2007 IP