WordPress.org

Ready to get started?Download WordPress

Forums

Need some help calling an php file (14 posts)

  1. pbwordp
    Member
    Posted 5 years ago #

    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']))
    { ?>

  2. pbwordp
    Member
    Posted 5 years ago #

    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...

  3. pbwordp
    Member
    Posted 5 years ago #

    OK, here is the code...
    `<div id="header">
    <?php
    if(eregi("application/x-shockwave-flash", $_SERVER['HTTP_ACCEPT']))
    { ?>

  4. pbwordp
    Member
    Posted 5 years ago #


  5. pbwordp
    Member
    Posted 5 years ago #

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

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

  6. pbwordp
    Member
    Posted 5 years ago #

    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.

  7. Christian Schenk
    Member
    Posted 5 years ago #

    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?

  8. pbwordp
    Member
    Posted 5 years ago #

    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']))
    { ?>

  9. pbwordp
    Member
    Posted 5 years ago #

    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.

  10. Christian Schenk
    Member
    Posted 5 years ago #

    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.

  11. Matty Cohen
    Member
    Posted 5 years ago #

    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?

  12. pbwordp
    Member
    Posted 5 years ago #

    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?

  13. pbwordp
    Member
    Posted 5 years ago #

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

  14. Christian Schenk
    Member
    Posted 5 years ago #

    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...

Topic Closed

This topic has been closed to new replies.

About this Topic