0

I am in a nasty situation. I am trying to echo an iframe in php based on an if statement. However this returns a blank space.

I think this is due to the wrong escaping [single/double quotation] but can't figure it out :(

My code:

echo '<iframe src="'.$the_iframe_calling_url.'" frameborder="0"></iframe>';

any luck on this?

Okay, here is my code with if block. I am stuck with this :(

//check if this is image or not
    if (($file_type === 'image/gif')or($file_type === 'image/jpeg')or($file_type === 'image/jpg')or($file_type === 'image/pjpeg')or($file_type === 'image/x-png')or($file_type === 'image/png') ){
        echo '<img src="'.$final_file_url.'" width="70%" />';
        }

    else{

    $the_iframe_calling_url = 'https://docs.google.com/viewer?url='.$final_file_url; //http url

    //echo $final_file_url;
    echo '<iframe src="'.$the_iframe_calling_url.'" frameborder="0"></iframe>';


    echo $the_iframe_calling_url;
        }
    }
Jorge Campos
  • 22,647
  • 7
  • 56
  • 87
MKM
  • 33
  • 5
  • 3
    You're going to have to add more code. At the very least, you need to give us the `if` statement and the definition of `$the_iframe_calling_url`. What does the outputted HTML look like? – andrewsi Oct 25 '13 at 16:28
  • $the_iframe_calling_url is perfectly okay. the value of $the_iframe_calling_url is https://docs.google.com/viewer?url=http://acssales.net/data/uploads/tweaks.docx and it is a valid link – MKM Oct 25 '13 at 16:33
  • OK. So what is your code outputting? Can you add the rendered HTML to your question? Is the echo even being called? – andrewsi Oct 25 '13 at 16:34
  • @andrewsi: My code is outputting a blank iframe box :( but this should contain the targeted data from URL. – MKM Oct 25 '13 at 16:35
  • Look at the source of the page you're generating. What is the `src` attribute for your ` – andrewsi Oct 25 '13 at 16:38
  • @andrewsi: the src is perfect. I echoed it and it is completely okay. – MKM Oct 25 '13 at 16:40
  • If you change the src to a random website, it works; but with this specific URL, you're not getting anything? – andrewsi Oct 25 '13 at 16:41

1 Answers1

2

There is nothing wrong with your code. Maybe the url your are trying to open is the problem. $the_iframe_calling_url

Or the if statement that was said in the comment

Since you posted the URL you are trying to show in an Iframe here is your answer:

Iframe google problem

Community
  • 1
  • 1
Jorge Campos
  • 22,647
  • 7
  • 56
  • 87