Support » Themes and Templates » Need some help calling an php file

  • Hello, on my header.php I have a condition… if that conditions is met it should open my flash. php file. If that condition is not met it displays a jpg image. The problem I encounter is calling that php file, which is in the same folder as the header.php.

    here is what I have so far, which is not working.
    <div id=”header”>
    <?php
    if(eregi(“application/x-shockwave-flash”, $_SERVER[‘HTTP_ACCEPT’]))
    { ?>

Viewing 13 replies - 1 through 13 (of 13 total)
  • Anybody have an idea why my text is not showing here… is there some problems with this text editor? I can’t put my code here…

    OK, here is the code…
    `<div id=”header”>
    <?php
    if(eregi(“application/x-shockwave-flash”, $_SERVER[‘HTTP_ACCEPT’]))
    { ?>

    Sorry about that, here is what my code looks like:

    <div id=”header”>
    <?php
    if(eregi(“application/x-shockwave-flash”, $_SERVER[‘HTTP_ACCEPT’]))
    { ?>

    OK… well for some reason I can write the rest of the code. But right after the above code is were I need to call for my flash.php file.

    It’d be great if we could have a look at the code. If you can’t manage to publish it here you may want to use this and post a link to your code here.

    Anyway, I guess you’ll just have to use an include('flash.php') inside the if statement. But you already did that, right?

    Yes I had tried that… nothing happens. Is there something wrong with the code perhaps?

    <?php
    if(eregi(“application/x-shockwave-flash”, $_SERVER[‘HTTP_ACCEPT’]))
    { ?>

    Here is the code…

    <?php
    if(eregi(“application/x-shockwave-flash”, $_SERVER[‘HTTP_ACCEPT’])){ ?>
    include(‘my_flash.php’)
    <?php } else { ?>
    <img src=”my_image.jpg”>
    <?php } ?>

    *here is what I have.

    Do you run into a PHP error, e.g. broken syntax? Or will the if statement never evaluate to true and thus the JPG will be shown all the time? If that’s the case you should try stripos – which might be a good idea anyway since it should be a little bit faster.

    Hi pbwordp.

    If you’re having an issue including the ‘flash.php’ file, try including it like this:

    <?php include(get_bloginfo('template_directory') . '/flash.php'); ?>

    The above line of code will point directly to the flash.php file and include it. If this doesn’t work, please remove the ‘/’ before ‘flash.php’ and try again.

    Is the issue you are experiencing to do with the inclusion of the flash.php file?

    Hi chschenk, yes… it actually never evaluates the if true statement, it displays directly the jpg image. Could you tell me what is wrong here… this should work like this:

    1. check if the flash plugin is available.
    <?php
    if(eregi(“application/x-shockwave-flash”, $_SERVER[‘HTTP_ACCEPT’])){ ?>

    2. If true, I want to include a flash.php file (were I have my flash movie)
    include(‘my_flash.php’)

    3. else or if false, I want to display a JPG image.
    <?php } else { ?>
    <img src=”my_image.jpg”>
    <?php } ?>

    Any thoughts on this?

    Hi mattyza, I had also tried both of your suggestions and it is not working. Any other ideas?

    I’ve tested this with various browsers (Firefox, Safari and Opera) and they don’t seem to add the “application/x-shockwave-flash” to the HTTP accept field, i.e. I wouldn’t see the flash on your site.

    Instead of using PHP you may want to switch to JavaScript for this. Google comes up with some promising results here…

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Need some help calling an php file’ is closed to new replies.