Web Analytics Made Easy -
StatCounter trouble calling external php file - CodingForum

Announcement

Collapse
No announcement yet.

trouble calling external php file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • trouble calling external php file

    I have been able to call external php files for a while now, but for some reason this script isnt taking. Hopefully someone can see where I am going wrong.

    Code:
    <?php
      
    include_once "/photo_site/photo_slideshow.php";
      
      
    ?>
    I am using php to call html code.

    The link to my site is:
    http://royalvillicus.com/photo_site/photo.html

    Thanks for any help

  • #2
    That filepath correct? Seems to me like that should exist off of a public_html directory in a user profile.
    Enable you're error reporting:
    PHP Code:
    ini_set('display_errors'1);
    error_reporting(E_ALL); 
    chances are its the path that can't be found.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

    Comment


    • #3
      well the code you gave me didnt seem to work out, could easily be some other setting I need to create before it will enable.

      So I just went and changed the photo.html over to a .php extension.

      I got these php errors

      Warning: include_once(/photo_site/photo_slideshow.php) [function.include-once]: failed to open stream: No such file or directory in /home1/royalvil/public_html/photo_site/photo.php on line 128

      Warning: include_once() [function.include]: Failed opening '/photo_site/photo_slideshow.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home1/royalvil/public_html/photo_site/photo.php on line 128

      Warning: include_once(/photo_site/photo_carousel.php) [function.include-once]: failed to open stream: No such file or directory in /home1/royalvil/public_html/photo_site/photo.php on line 192

      Warning: include_once() [function.include]: Failed opening '/photo_site/photo_carousel.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home1/royalvil/public_html/photo_site/photo.php on line 192



      You speak of them needing to be in a public folder. I have them all in the public folder. The same exact file path I use to call images and the .css and .js file, they all in the same place and call just fine.

      Do I need to make the home page a .php file and have it print all the html? then just include the two php files (also holding more html)

      Thanks a lot for your help

      Comment


      • #4
        Is there a reason why you have to use the full path and can't use a relative one? Anyway, if you have to, run echo dirname(__FILE__); from within photo_slideshow.php. It will give you the full path of the directory it's sitting in.
        .My new Javascript tutorial site: http://reallifejs.com/
        .Latest article: Calculators — Tiny jQuery calculator, Full-fledged OOP calculator, Big number calculator
        .Latest quick-bit: Including jQuery — Environment-aware minification and CDNs with local fallback

        Comment


        • #5
          Ok, I figured it out. If anyone is curious how I got it to work, I just used the name of the file and dropped the rest of the file path and the folders the file is inside of.

          For some reason php was looking for the files inside of photo.php (home page)

          php seems to be so smart its dumb. Its so smart it doesnt need the complete file path to find the right file. But if you tell it the full file path it will have problems. go figure.

          This may have been what you were talking about with the relative file path.

          Thanks for all your help

          Comment


          • #6
            You didn't actually tell it the full file path. The full path should have been /home1/royalvil/public_html/photo_site/photo_*

            Comment


            • #7
              Originally posted by surreal5335 View Post
              Ok, I figured it out. If anyone is curious how I got it to work, I just used the name of the file and dropped the rest of the file path and the folders the file is inside of.

              This may have been what you were talking about with the relative file path.
              It very well may have been.
              .My new Javascript tutorial site: http://reallifejs.com/
              .Latest article: Calculators — Tiny jQuery calculator, Full-fledged OOP calculator, Big number calculator
              .Latest quick-bit: Including jQuery — Environment-aware minification and CDNs with local fallback

              Comment


              • #8
                Ultimate problem is the filepath.
                However, from the second post, I'd say the initial problem is that it wasn't being served as a php page. PHP extension is required unless you've set up apache, IIS or whatever you're web server is to handle .html as .php files.
                Its important to know the filepaths. Absolutes are fine, but let PHP handle the legwork:
                PHP Code:
                <?php

                require_once dirname(__FILE__) . '/./photo_slideshow.php';
                ?>
                This would seek photo_slideshow.php using an absolute path relative to the current file. Sounds funny.
                Indogoesdr indicated what you'd need to do for a full hardcoded filepath.
                PHP Code:
                header('HTTP/1.1 420 Enhance Your Calm'); 
                Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

                Comment

                Working...
                X