PHP script not working anymore

Discussion in 'PHP' started by bluemouse2, Aug 10, 2009.

  1. #1
    Hi, I have a problem with a PHP script.

    I've moved the script to another location and now I'm getting errors like:

    Warning: require_once(includes/common.php) [function.require-once]: failed to open stream: No such file or directory in ..........

    But the file is there.

    The php code I'm using to call the files is

    require_once "includes/common.php";

    fopen() is not supported where script is now located.

    Is this why I'm getting this code error? Do you have any ideas how to fix it?

    Thank you.
     
    bluemouse2, Aug 10, 2009 IP
  2. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #2
    Try using the absolute directory, something like: /user/home/domains/site.com/includes/.
     
    ThePHPMaster, Aug 10, 2009 IP
  3. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #3
    require_once "./includes/common.php";

    Try that
     
    Bohra, Aug 11, 2009 IP
  4. badeyes

    badeyes Active Member

    Messages:
    411
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #4
    try this

    require_once("/includes/common.php");

    or

    require_once("./includes/common.php");

    or

    require_once ("../includes/common.php");

    or find the exact path e.g. /user/home/domain where is your includes folder is.
     
    badeyes, Aug 12, 2009 IP
  5. kblessinggr

    kblessinggr Peon

    Messages:
    539
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #5
    If you know the includes folder is in the same folder as the script you are running you can do something like this.

    
    $curpath = realpath('./');
    require_once($curpath."/includes/common.php");
    
    Code (markup):
     
    kblessinggr, Aug 12, 2009 IP
  6. Codex-m

    Codex-m Peon

    Messages:
    36
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6

    This might caused by some lacking features in your PHP installation. Try uploading this to your root directory:

    
    <?php
    phpinfo();
    ?>
    
    Code (markup):
    Then make sure that all functions you used in your PHP script are enabled by your hosting provider, for example if you are using fopen, try to look at the phpinfo information if that is enabled.

    Otherwise , you need to contact your hosting provider or do some upgrade. Do not forget to delete your phpinfo.php after troubleshooting because it poses security risk by being accessible to others.
     
    Codex-m, Aug 12, 2009 IP
  7. bluemouse2

    bluemouse2 Well-Known Member

    Messages:
    4,055
    Likes Received:
    130
    Best Answers:
    0
    Trophy Points:
    185
    #7
    fopen() is not allowed only curl

    still need a solution on this thank you all.
     
    bluemouse2, Aug 12, 2009 IP
  8. olddocks

    olddocks Notable Member

    Messages:
    3,275
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    215
    #8
    could be ftp problem. using ascii mode not binary mode to upload.
    besides these, why not use include "includes/common.php"
     
    olddocks, Aug 12, 2009 IP
  9. kblessinggr

    kblessinggr Peon

    Messages:
    539
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Normally only a problem if the code was somehow encoded. Course ioncube now encodes in ascii mode by default (via the purchased encoder) so less likely to be that.

    But even if that were the case the error would not be saying file not found, but simply importing garbage data.
     
    kblessinggr, Aug 13, 2009 IP
  10. bluemouse2

    bluemouse2 Well-Known Member

    Messages:
    4,055
    Likes Received:
    130
    Best Answers:
    0
    Trophy Points:
    185
    #10
    when looking at the code the lines are somehow scrambled... any tips how to fix this?
     
    bluemouse2, Aug 13, 2009 IP
  11. kblessinggr

    kblessinggr Peon

    Messages:
    539
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #11
    How so scrambled? Can you paste an example?
     
    kblessinggr, Aug 13, 2009 IP
  12. bluemouse2

    bluemouse2 Well-Known Member

    Messages:
    4,055
    Likes Received:
    130
    Best Answers:
    0
    Trophy Points:
    185
    #12
    instead of new code lines when opening in editor i see many lines of code on same row - long rows...
     
    bluemouse2, Aug 13, 2009 IP
  13. olddocks

    olddocks Notable Member

    Messages:
    3,275
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    215
    #13
    thats common because its running different os.
     
    olddocks, Aug 13, 2009 IP
  14. kblessinggr

    kblessinggr Peon

    Messages:
    539
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Sounds like a line break issue, kinda like downloading a Unix file onto a windows system without the FTP application automatically converting the line breaks (windows typically uses something like \r\n where as unix/linux is typically just \n)

    FTP applications generally running in ASCII or Auto transfer mode will typically try to convert the line breaks in known files types (Which breaks a php file with binary encoding). I never really noticed it since switching to a mac (which uses a linux style file system)
     
    kblessinggr, Aug 13, 2009 IP
  15. bluemouse2

    bluemouse2 Well-Known Member

    Messages:
    4,055
    Likes Received:
    130
    Best Answers:
    0
    Trophy Points:
    185
    #15
    do you know how to fix it? does it really make a difference?
     
    bluemouse2, Aug 13, 2009 IP
  16. kblessinggr

    kblessinggr Peon

    Messages:
    539
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Normally doesn't make a difference, but can however be annoying to edit. Depending on the IDE you are using to edit you may even be able to change your encoding somewhere in the menu.
     
    kblessinggr, Aug 13, 2009 IP
  17. bluemouse2

    bluemouse2 Well-Known Member

    Messages:
    4,055
    Likes Received:
    130
    Best Answers:
    0
    Trophy Points:
    185
    #17
    if this is not the problem affecting the code then i wont mind....
     
    bluemouse2, Aug 13, 2009 IP