toovey Posted February 7, 2007 Share Posted February 7, 2007 Hello board, I am porting an existing php web application from Windows to Linux. The application uses mysql, and does not appear to depend on any libraries. Between the two servers, there does not appear to be any major differences between php configuration paramaters. So the index.php file has some includes, and those files also have includes. One of them is the mysql username and password information. Another file contains a function. So when I call index.php, it gives warnings on failures to connect to mysql with the username of apache and no password (I am assuming this is the system default, so the include containing the username and pass isnt working.) Also there is a failure because it tries to call the function that I mentioned previously but it can't find it (says undefined function). In the PHP log file, there are no failures on the includes. I changed them to requires just to make sure. So assuming that the requires are working properly (safe to assume), then there must be something wrong with my variable scoping and / or function definition scoping??? Is there any significant difference between win32 and linux that I should know about? Is there any articles I can be pointed to? Thanks in advance for your reponses. Brian Quote Link to comment Share on other sites More sharing options...
Caesar Posted February 7, 2007 Share Posted February 7, 2007 Does your script asume register_globals to be turned on? We would need to see a sample of your functions/code to make any suggestions. Quote Link to comment Share on other sites More sharing options...
toovey Posted February 7, 2007 Author Share Posted February 7, 2007 No register globals is turned off on the windows server. Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted February 7, 2007 Share Posted February 7, 2007 Check the mysql username/password combination. Double check that, if you are using "localhost", it depends on the server that is running it. If mysql is on the same system then "localhost" generally works. If it's in an entirely different area all together normally you have to put the actual information in, instead. Quote Link to comment Share on other sites More sharing options...
toovey Posted February 7, 2007 Author Share Posted February 7, 2007 Im sorry but I dont follow. The mysql login information is included in a file that has those variables defined. Is there something I am missing? Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 7, 2007 Share Posted February 7, 2007 The MySQL server on the linux host might have different values than the windows server for the values: host user password Businessman is stating that you should ensure that you are using the correct values. Quote Link to comment Share on other sites More sharing options...
toovey Posted February 7, 2007 Author Share Posted February 7, 2007 Yea - I imported the mysql database from the win box to the linux box. I set the mysql authentication information in the config file containing it. The issue is that the php program is never including these values, as it tries with the account "apache" with no username, which I am assuming is the default. Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted February 7, 2007 Share Posted February 7, 2007 The "default" usename (the one it starts with) for mysql is "root". Try changing your username (in the php script) to root. If not then show up your login script (username/password blanked out) Your webhost (who is it, what is it) Version of php/mysql/apache With that we can help you narrow down the problem further from there. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 7, 2007 Share Posted February 7, 2007 It sounds like what you were saying is the includes aren't working, or variables aren't passing through all of them. Are you using require() instead of include()? Try that first. Then make sure in any functions the variables are marked global. Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 7, 2007 Share Posted February 7, 2007 "I imported the mysql database from the win box to the linux box." It depends on your definition of import. If you went into phpMyAdmin, picked a database, and created a .sql (or .zip) which you then imported into the linux machine via it's phpMyAdmin, then the user privileges for the MySQL server are not intact. Is this linux box provided via a hosting company? If it is, then the e-mail they sent you when you signed up for their hosting will contain the host, user, and password information for the MySQL server. Quote Link to comment Share on other sites More sharing options...
toovey Posted February 7, 2007 Author Share Posted February 7, 2007 jesirose sorry for msging you. I changed the includes to requires as per my original post. I have register globals turned off though on both servers. So can I still mark them as global? Brian Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 7, 2007 Share Posted February 7, 2007 register_globals being off requires that in order to use a variable which is defined outside of a function, you must mark it global in the function. Quote Link to comment Share on other sites More sharing options...
toovey Posted February 7, 2007 Author Share Posted February 7, 2007 So then is there a difference in the way linux handles this behavior as opposed to windows? This works fine on the win32 installation. I will post the code samples. Quote Link to comment Share on other sites More sharing options...
toovey Posted February 7, 2007 Author Share Posted February 7, 2007 This is the start of my script: <? require("connect.php"); require("include/functions.php"); $today=gmdate("Y-m-d"); $squery="DELETE FROM ticket_bid WHERE expirydate < '$today'"; $sresult=mysql_query($squery); connect.php contains the following: <? session_start(); require ("include/config.inc.php"); //include_once ("include/functions.php"); include_once("include/CryToGraphy.php"); //="http://com22/tixstopsite/"; error_reporting(7); include "include/debug.php"; require ("include/new_connect.inc.php"); $db=mysql_connect($DBSERVER, $USERNAME, $PASSWORD); mysql_select_db($DATABASENAME,$db); mysql_query("delete from tickets where quantity < 1"); echo mysql_error(); include/config.inc.php contains the following: $DBSERVER = "127.0.0.1"; $DATABASENAME = "somedb"; $USERNAME = "root"; $PASSWORD = "password"; include/new_connect.inc.php <? function p_r($arr) { if (debug) {echo "<pre>"; print_r($arr); echo "</pre>";} } /* new connect*/ $config['dbname']=$DATABASENAME; $config['persistent']=0; $_host=$GLOBALS[_SERVER][HTTP_HOST]; p_r($_host); include("mysql.inc.php"); $dbh = new sql; $host_arr=array( 'localhost'=>array(connect=>array($DBSERVER, $USERNAME, $PASSWORD,$USERNAME), title=>'DEV') ); p_r($host_arr); $dbh -> connect('mysql', $host_arr[$_host][connect]); //p_r($dbh); exit; ?> My log is as follows: [client 63.118.15.152] PHP Warning: mysql_connect(): Access denied for user 'apache'@'localhost' (using password: NO) in /var/www/seatline1/include/mysql.inc.php on line 29 [client 63.118.15.152] PHP Warning: mysql_list_tables(): Access denied for user 'apache'@'localhost' (using password: NO) in /var/www/seatline1/include/mysql.inc.php on line 31 [client 63.118.15.152] PHP Warning: mysql_list_tables(): A link to the server could not be established in /var/www/seatline1/include/mysql.inc.php on line 31 [client 63.118.15.152] PHP Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /var/www/seatline1/include/mysql.inc.php on line 41 [client 63.118.15.152] PHP Fatal error: Call to undefined function: find_environmental() in /var/www/seatline1/include/mysql.inc.php on line 310 Quote Link to comment Share on other sites More sharing options...
toovey Posted February 8, 2007 Author Share Posted February 8, 2007 forgot to add mysql.inc.php - will add as an attachment - its the one throwing all the errors.... [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
trq Posted February 8, 2007 Share Posted February 8, 2007 register_globals being off requires that in order to use a variable which is defined outside of a function, you must mark it global in the function. That has nothing to do with register_globals I'm sorry. If register globals was of on windows, leave it off in Linux. It is to do with ENV, GET, POST, COOKIE, and SERVER all becomig global instead of being contained within there allocated arrays. The problem does indeed appear to be with your includes. What are the file permissions of them? Quote Link to comment Share on other sites More sharing options...
toovey Posted February 8, 2007 Author Share Posted February 8, 2007 permissions are good - if the includes were failing though wouldnt you see that in the log files as warnings? Quote Link to comment Share on other sites More sharing options...
trq Posted February 8, 2007 Share Posted February 8, 2007 Permissions are good is not enough infomation. Can we see the output of... ls -l ? Quote Link to comment Share on other sites More sharing options...
toovey Posted February 8, 2007 Author Share Posted February 8, 2007 Thanks for helping out the permissions are attached. ls -Rlah /var/www/seatline1/ > /root/permissions.txt [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
trq Posted February 8, 2007 Share Posted February 8, 2007 Can't you just post them? Im at work. Quote Link to comment Share on other sites More sharing options...
toovey Posted February 8, 2007 Author Share Posted February 8, 2007 There in different subdirectories - posting them in the forum will be huge - its 8600 hundred lines here are the individual files: [root@sls-cd1p1 hotel]# ls -lah /var/www/seatline1/ |grep index.php -rw-r--r-- 1 root root 12K Feb 7 08:18 index.php here is connect.php [tt]-rw-r--r-- 1 root root 3.8K Feb 7 07:40 connect.php,/tt] and here is the include directory: [root@sls-cd1p1 seatline1]# ls -lah /var/www/seatline1/include total 180K drwxr-xr-x 2 root root 4.0K Feb 7 17:48 . drwxr-xr-x 24 root root 4.0K Feb 8 11:58 .. -rw-r--r-- 1 root root 2.3K Aug 13 20:37 calendar.inc.php -rw-r--r-- 1 root root 4.3K Apr 6 2006 common.js -rw-r--r-- 1 root root 951 Feb 6 22:49 config.inc.php -rw-r--r-- 1 root root 11K Apr 6 2006 creditcard.js -rw-r--r-- 1 root root 940 Apr 6 2006 CryToGraphy.php -rw-r--r-- 1 root root 26 Aug 6 2006 debug.php -rw-r--r-- 1 root root 12K Jul 30 2006 functions.php -rw-r--r-- 1 root root 207 Apr 6 2006 imageprocess.php -rw-r--r-- 1 root root 73 Apr 6 2006 index.php -rw-r--r-- 1 root root 1.8K Jul 6 2006 mailfunctions.php -rw-r--r-- 1 root root 12K Aug 6 2006 mysql.inc.php -rw-r--r-- 1 root root 1.6K Feb 6 19:22 new_connect.inc.php -rw-r--r-- 1 root root 2.6K Apr 6 2006 resize1.php -rw-r--r-- 1 root root 3.9K Apr 6 2006 resize.php -rw-r--r-- 1 root root 720 Apr 6 2006 safecode.php -rw-r--r-- 1 root root 613 Apr 6 2006 sendmail.php -rw-r--r-- 1 root root 4.0K Jun 6 2006 timedate.php Quote Link to comment Share on other sites More sharing options...
trq Posted February 8, 2007 Share Posted February 8, 2007 Im pretty sure you'll find they should be owned by (or at least within the group) apache. Quote Link to comment Share on other sites More sharing options...
toovey Posted February 8, 2007 Author Share Posted February 8, 2007 [root@sls-cd1p1 www]# chown -R apache /var/www/seatline1 Same errors: [client 63.118.15.152] PHP Warning: mysql_connect(): Access denied for user 'apache'@'localhost' (using password: NO) in /var/www/seatline1/include/mysql.inc.php on line 29 [client 63.118.15.152] PHP Warning: mysql_list_tables(): Access denied for user 'apache'@'localhost' (using password: NO) in /var/www/seatline1/include/mysql.inc.php on line 31 [client 63.118.15.152] PHP Warning: mysql_list_tables(): A link to the server could not be established in /var/www/seatline1/include/mysql.inc.php on line 31 [client 63.118.15.152] PHP Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /var/www/seatline1/include/mysql.inc.php on line 41 [client 63.118.15.152] PHP Fatal error: Call to undefined function: find_environmental() in /var/www/seatline1/include/mysql.inc.php on line 310 Quote Link to comment Share on other sites More sharing options...
toovey Posted February 8, 2007 Author Share Posted February 8, 2007 *bump* Quote Link to comment Share on other sites More sharing options...
toovey Posted February 9, 2007 Author Share Posted February 9, 2007 *bump* 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.