atholon Posted December 20, 2008 Share Posted December 20, 2008 hey there, So I have been using an older version of PHP and mySQL and I tried uploading my site to a server with PHP5 and the newest version of mySQL...it seems like the link isn't being carried over to the other pages unless I specify it. Is this just due to the php version? I had just been using a config file for the default link and I've used that to determin the connection. On the actual server it won't let me. Quote Link to comment Share on other sites More sharing options...
redarrow Posted December 20, 2008 Share Posted December 20, 2008 interesting sometimes you need to put a / foward slash in front of the /diretory_file_name.php <?php include("/database_connection.php"); ?> no it not a php5 thing it a server config setting. as you can see if you can include a file using the following method your need to also change all your link settings Quote Link to comment Share on other sites More sharing options...
xtopolis Posted December 20, 2008 Share Posted December 20, 2008 http://us3.php.net/manual/en/faq.migration5.php What errors are you getting? Quote Link to comment Share on other sites More sharing options...
atholon Posted December 20, 2008 Author Share Posted December 20, 2008 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/digitalh/public_html/includes/GetUserInfo.php on line 14 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/digitalh/public_html/includes/MasterPage.php on line 21 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/digitalh/public_html/index.php on line 36 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/digitalh/public_html/index.php on line 37 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/digitalh/public_html/index.php on line 54 Thing is that they are valid....I checked them in SQL. I am not having issues with the require .... it works on my dev machine but not my webserver . My site is www.digitalhelpfiles.com Quote Link to comment Share on other sites More sharing options...
xtopolis Posted December 20, 2008 Share Posted December 20, 2008 So that points to an invalid query(but you said they were ok), or being unable to connect to the database. What if you add or die() to your mysql_connect method? mysql_connect('host','user','pass') or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
atholon Posted December 20, 2008 Author Share Posted December 20, 2008 When I do that in the config file nothing happens. When I do a die in these other files with the warnings, it says no database has been selected for those queries. The query worked when I installed using my install script... but none of those other pages that are rendered together with my config.php file take it. The way it is set up is like this: index.php requires MasterPage MasterPage requires site_common.php SiteCommon requires many different pages...the first of which is the config.php some of those pages are strictly classes as well. GetUserInfo.php is required in site_common.php Quote Link to comment Share on other sites More sharing options...
trq Posted December 20, 2008 Share Posted December 20, 2008 You might want to actually post some relevent code. Quote Link to comment Share on other sites More sharing options...
atholon Posted December 20, 2008 Author Share Posted December 20, 2008 GetUserInfo.php: <?php class GetUserInfo { var $permission; function GetUserInfo($userName) { $baseQuery = mysql_query("SELECT * FROM `staff` WHERE `name`='$userName'", $GLOBALS['connect']); $getStaffInfo = mysql_fetch_array($baseQuery); $position = $getStaffInfo["position"]; $getPosition = mysql_fetch_array(mysql_query("SELECT * FROM `position` WHERE `sid`='$position'")); // Line with warning $this->permission = $getPosition["permission"]; } } ?> Quote Link to comment Share on other sites More sharing options...
redarrow Posted December 20, 2008 Share Posted December 20, 2008 $GLOBALS['connect'] <<<< missing i think...... Quote Link to comment Share on other sites More sharing options...
atholon Posted December 20, 2008 Author Share Posted December 20, 2008 Nope, that is in the config file. Quote Link to comment Share on other sites More sharing options...
redarrow Posted December 20, 2008 Share Posted December 20, 2008 $getPosition = mysql_fetch_array(mysql_query("SELECT * FROM `position` WHERE `sid`='$position',$GLOBALS['connect']")); // Line with warning Quote Link to comment Share on other sites More sharing options...
atholon Posted December 20, 2008 Author Share Posted December 20, 2008 Right...BUT....according to PHP documentation, you do not need to do that. The MySQL connection. If the link identifier is not specified, the last link opened by mysql_connect() is assumed. If no such link is found, it will try to create one as if mysql_connect() was called with no arguments. If by chance no connection is found or established, an E_WARNING level error is generated. Quote Link to comment Share on other sites More sharing options...
trq Posted December 20, 2008 Share Posted December 20, 2008 You should at least attempt some error handling within this GetUserInfo() method. Quote Link to comment Share on other sites More sharing options...
atholon Posted December 20, 2008 Author Share Posted December 20, 2008 I will but I need to figure out a better way to do this or find out what is wrong. I can either do globals like I did above or I can just make a class that handles the queries for me. Quote Link to comment Share on other sites More sharing options...
atholon Posted December 20, 2008 Author Share Posted December 20, 2008 Here is a little bit better version: <?php class GetUserInfo { var $permission; function GetUserInfo($userName) { $this->permission = 0; if(isset($userName)) { $baseQuery = mysql_query("SELECT * FROM `staff` WHERE `name`='$userName'") or die ("<br />Error in MySQL-query: ".mysql_error()); if (mysql_num_rows($baseQuery) > 0) { $getStaffInfo = mysql_fetch_array($baseQuery); $position = $getStaffInfo["position"]; $positionQuery = mysql_query("SELECT * FROM `position` WHERE `sid`='$position'") or die ("<br />Error in MySQL-query: ".mysql_error()); if (mysql_num_rows($positionQuery) > 0) { $getPosition = mysql_fetch_array($positionQuery); $this->permission = $getPosition["permission"]; } // End position query } // End check for staff query } // End check for user name } // End GetUserInfo() } // End of class ?> 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.