Syntax Error on this line?

Discussion in 'PHP' started by mokimofiki, Dec 28, 2008.

  1. #1
    The image will not display that I am trying to show with the following line of code:

    <img src=images/".$droprow["name"].".jpg>
    Code (markup):
    The image is in the proper location and if I replace this code with a static code such as:

    <img src="images/avatar.jpg">
    Code (markup):
    It works fine .... it seems I need the " around the image src but am not sure how to do this any help would be great thank you.
     
    mokimofiki, Dec 28, 2008 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #2
    try to trim the space by using trim function from the variable $droprow["name"]


    or

    try

    <?
    echo $droprow["name"];
    echo "<img src=images/".$droprow["name"].".jpg>";

    ?>

    right click the image and see what link it is showing even though it does not display image right click the cross

    You will come to know what it is passing to page

    Regards

    Alex
     
    kmap, Dec 28, 2008 IP
  3. mokimofiki

    mokimofiki Well-Known Member

    Messages:
    444
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    130
    #3
    Okay trimming spaces changes the image name so what I really need to know I guess is how to add a " where there needs to be one within an echo:

    echo "display this image <img src="black ruler.jpg" <br /> Black Ruler";



    EDIT: the above code isn't what i'm actually using its just easier to explain with something short.
     
    mokimofiki, Dec 28, 2008 IP
  4. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #4
    have u tried this

    <?
    echo $droprow["name"];
    echo "<img src=images/".$droprow["name"].".jpg>";

    ?>


    Please write the output of above lines

    Regards

    Alex
     
    kmap, Dec 28, 2008 IP
  5. hassanahmad1

    hassanahmad1 Active Member

    Messages:
    150
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #5
    use ' or \"
     
    hassanahmad1, Dec 28, 2008 IP
    mokimofiki likes this.
  6. mokimofiki

    mokimofiki Well-Known Member

    Messages:
    444
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    130
    #6
    ' worked great thank you :)

    kmap your code worked great alone but within the function it was stopping the code from running at the echo .... an echo wasent actually used it was done within a variable that displayed within another display.

    Thank you both for your help :)
     
    mokimofiki, Dec 28, 2008 IP