#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    28
    Rep Power
    0

    Fopen fails to open a php file


    The goal is for one file to open the second file which sends the sms. if i directly start check.php it works but when i try to run it through main.php nothing happens not even an error. suggestions ?

    main.php
    PHP Code:
    <?php
    $test 
    fopen("check.php""r");
    echo 
    "test";
    ?>
    check.php
    PHP Code:
     $ping_ex exec("C:\smssend\SMSUtil /CP COM11 /R \"+37*********\" /M \"test\" "$ping_result$pr); 
    PS i dont want to wait while exec runs , that means main.php needs to run without waiting for a response.
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Location
    Saint-Petersburg, Russia
    Posts
    237
    Rep Power
    29
    C:\smssend\SMSUtil
    Perhaps it is worth doubling backslashes inside the string.

    Why are you trying to fopen it instead of include?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    28
    Rep Power
    0
    if i directly start check.php it works

    tried include it works but waits while exec is running and in my case its ~1minute (feature fof smsutil.exe )
  6. #4
  7. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    fopen($path, 'r') opens the file for reading. It doesn't execute anything. The only thing you could do with this function call is read the source code of the PHP script, which isn't terribly useful.

    If you wanna execute a PHP script from another PHP script, you need to include() it. Note that each script will have access to the variables, constants etc. of the other script.

    I wonder why you do this, though. What's the point of having a separate script vs. writing the code directly into the main script or a function?
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    28
    Rep Power
    0
    Originally Posted by Jacques1
    Hi,

    fopen($path, 'r') opens the file for reading. It doesn't execute anything. The only thing you could do with this function call is read the source code of the PHP script, which isn't terribly useful.

    If you wanna execute a PHP script from another PHP script, you need to include() it. Note that each script will have access to the variables, constants etc. of the other script.

    I wonder why you do this, though. What's the point of having a separate script vs. writing the code directly into the main script or a function?
    Execution time , i want for the main file to run while the second files executes the command written in it. Currently if i use include the main file freezes (waits for code in the second file to finish). Trying to call ajax from php to cal another php ... would appreciate a better solution.
  10. #6
  11. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  12. #7
  13. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Location
    Saint-Petersburg, Russia
    Posts
    237
    Rep Power
    29
    What you really want is to call "exec" asynchronously. It has nothing to do with fopen or inclusion of PHP scripts.

    You can google by "php exec asynchronously" for I am not proficient enough in PHP myself. Looks like you need something like this:
    http://stackoverflow.com/questions/3...ulti-processes
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    28
    Rep Power
    0
    PHP Code:
    $WshShell = new COM("WScript.Shell");         
    $oExec $WshShell->Run("C:\smssend\SMSUtil /CP COM11 /R \"+37**********\" /M $smstext"0false); 
    Fixed thanks for the replies.

IMN logo majestic logo threadwatch logo seochat tools logo