aleX_hill Posted February 29, 2012 Share Posted February 29, 2012 OK, so I dont think this is a code issue as such, but I am completely stumped as to where the issue could be. I have a page with some standard include() functions at the top. When I access the page from home, everything operates as it should, when I access it from work (on multiple machines), I get the standard "unable to open stream" and "unable to access" warnings for the include statements. I have tried hard refreshing and deleting cache (not that it should make a shred of difference) etc, but the error is still there after a week or so. Does anyone know what could be causing this issue? Quote Link to comment Share on other sites More sharing options...
Psycho Posted February 29, 2012 Share Posted February 29, 2012 Where is the code in question that is causing this error. The only thing that jumps out at me is that there may be some paths that are dynamically set based upon data from the client PC that would cause the path to be different on your home PC vs. the work PCs. Also, I assume you are running the page on a server that is not on your home network. Quote Link to comment Share on other sites More sharing options...
aleX_hill Posted February 29, 2012 Author Share Posted February 29, 2012 The include is right at the top of the page. All that comes before it are the open php tag and session_start. The file worked fine on the work network for a long time, but just recently stopped. I think the server it was hosted on needed to change nameservers due to a DoS attack, but as far as I can tell that shouldnt be the issue considering I can still access the site, just the servers are having issues accessing the included files. And correct, not on the home network. It seems that the work network is the only place where it wont work. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 29, 2012 Share Posted February 29, 2012 Post the errors verbatim. Quote Link to comment Share on other sites More sharing options...
aleX_hill Posted February 29, 2012 Author Share Posted February 29, 2012 And so the plot thickens. Two different users on different computers get different errors. User 1: Warning: include() [function.include]: Unable to access ../profiles/singleton.php in /path/pages/login.php on line 16 Warning: include(../profiles/singleton.php) [function.include]: failed to open stream: No such file or directory in /path/pages/login.php on line 16 Warning: include() [function.include]: Unable to access ../profiles/singleton.php in /path/pages/login.php on line 16 Warning: include(../profiles/singleton.php) [function.include]: failed to open stream: No such file or directory in /path/pages/login.php on line 16 Warning: include() [function.include]: Failed opening '../profiles/singleton.php' for inclusion (include_path='.:/usr/share/php5/') in /path/pages/login.php on line 16 Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13) in /path/includes/sqlConnect.php on line 5 Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /path/includes/sqlConnect.php on line 6 Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13) in /path/pages/login.php on line 22 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /path/pages/login.php on line 22 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /path/pages/login.php on line 23 User 2: Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13) in /path/includes/menu.php on line 3 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /path/includes/menu.php on line 3 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /path/includes/menu.php on line 4 Followed by general SQL errors further down the page. The user 1 stuff makes sense to a degree. The SQL login details are in one of the include files, so when it cant find that there will be SQL errors. But user 2 can include the files (lack of errors and the session details stored in one of the included files are active), but cannot connect to the SQL server. The SQL connect statement uses information from the SESSION vars, which are all active and populated with the correct details. And like I said in my first post, the errors are not happening when I am not on the work network, so I doubt its a code issue as such. Quote Link to comment Share on other sites More sharing options...
trq Posted February 29, 2012 Share Posted February 29, 2012 Without code we cannot help. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted February 29, 2012 Share Posted February 29, 2012 Edit: Longer version of what thorpe stated. For user #1, you need to determine why the included file cannot be found (i.e. No such file or directory.) Either the path is incorrect or the filename is incorrect or the capitalization of the path/filename in incorrect (assuming you are on an operating system that is case-sensitive.) Also, if this behaves differently for different users or for different client locations, your code IS doing something or you have something in a .htaccess file that is dong something to cause it. For user #2, those errors are occurring on a mysql_query statement. That means that either your mysql_connect() statement is not being executed at all or it is being called and is failing but it has error_reporting and/or display errors turned off/suppressed at the time or you have called a mysql_close statement in your code somewhere between the mysql_connect and the mysql_query statements. Are you sure error_reporting is set to E_ALL, so that all the php detected errors will be reported? You are likely getting some notice messages that would help pin point where the first symptoms of the problem are starting at. Here are some possible things your CODE could be doing that could cause these symptoms - 1) Using short open tags 2) Not having exit; statements after header() redirects to stop the remainder of the code on the page from running while the browser requests the new page. 3) Other relevant php detected errors are occurring, but are hidden either due to the error_reporting/display_errors/log_errors settings or use the @ error suppressor on statements or using or having output_buffering turned on and discarding the buffer or redirecting. 4) Logic errors in the code that are doing different things for different logged in users and/or race conditions in the code (see item #2) that vary depending on the connection speed. For the user #1 errors, if you want us to help, you would need to post enough information about your directory structure so that we would know where the main page is at and where the profiles folder is at and what the exact spelling and capitalization of the folders and files are and at least the code from the start of all the relevant files (showing the opening <?php tags too) through to where the include statements are at. For the user #2 errors, you need to determine if the mysql_connection statement is being called/executed at all (echo something right after the line with the statement), if it is failing or not (do you have error checking logic in your code?), and if it is succeeding, why is it being closed by the time the mysql_query statement is being executed. Short-answer: Your code IS the most likely cause of the problem (there are millions of php web pages that have includes and database connections that work.) If you cannot determine what is causing the problems, then we need to see the relevant code (less any database connection details) that would be needed to reproduce any particular coding problem/symptom/error (you have at least two problems - 1) An include problem prior to your login code, 2) A connection problem prior to your menu code) so that the many different possibilities can be reduced to just a few and then specific suggestions can be made to pin down the problem further. Seeing the relevant code also allows the code to be eliminated as the cause of the problem, which then suggests which of the next more likely things need to be looked at. Edit2: Here's a possibility for why it behaves differently for you depending on location. You have a remember-me feature in your login logic and you don't actually have to log in when connecting remotely, so the code where the problem is occurring at does not actually get executed. Shorter-answer: Post the relevant code to get the quickest solution. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted February 29, 2012 Share Posted February 29, 2012 Here's another possibility for why code might act flaky under different conditions. Are Register_globals on? Actually, my crystal ball seems to be hinting at an equal = assignment statement vs an == comparison statement as the cause of at least one of the problems. Quote Link to comment Share on other sites More sharing options...
aleX_hill Posted March 1, 2012 Author Share Posted March 1, 2012 Thank you very much for the in depth replies. I will take a look at the code when I get a spare moment and take a look at the things you mentioned. If it doesnt make any difference I will post some code up for more specific troubleshooting. Cheers, Alex Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.