twebman84 Posted May 6, 2009 Share Posted May 6, 2009 I have a page that is designed to query a baseball database and pull the stats for a specific player based on the URL. Here's the code that my question pertains to: //Break URL Up into an array, each element is the text between each / $urlParts = explode('/', $_SERVER[REQUEST_URI]); //Extract player code from URL by selecting the last element $aPlayer = $urlParts[count($urlParts)-1]; //Deal with a trailing slash on the URL if($aPlayer=='') $aPlayer = $urlParts[count($urlParts)-2]; //Connect to Database require('mysql_con.php'); //Query to retrieve bio info for this player $getPlayerInfo = "SELECT playerID, nameFirst, nameLast, nameGiven, birthMonth, birthDay, birthYear, birthCity, birthState, debutMonth, debutDay, debutYear, bats, throws, height, weight, nameNick, deathMonth, deathDay, deathYear, deathCity, deathState, photo FROM TBP_Master WHERE playerID = '$aPlayer';"; //Run Query $playerInfo = mysql_query($getPlayerInfo); And so on... The problem is that there apparently needs to be an entry in my .htaccess file to allow this to work. The URL should end up like this: http://www.thebaseballpage.com/players/stats/PLAYERID (the variable) 'stats' is the name of the file that contains this code. This all worked fine before I lost my old .htaccess file, so I know the code is good. Does anyone know what needs to be in my .htaccess file? Quote Link to comment https://forums.phpfreaks.com/topic/157108-simple-help-with-my-htaccess-file/ Share on other sites More sharing options...
Ken2k7 Posted May 6, 2009 Share Posted May 6, 2009 Yeah you need modrewrite. Read up on it. Quote Link to comment https://forums.phpfreaks.com/topic/157108-simple-help-with-my-htaccess-file/#findComment-827687 Share on other sites More sharing options...
RussellReal Posted May 6, 2009 Share Posted May 6, 2009 is /players/ an actual directory? in which case you'd want to put this htaccess into the /players/ directory RewriteEngine on RewriteRule ^stats/(.*)$ stats.php?player=$1 Quote Link to comment https://forums.phpfreaks.com/topic/157108-simple-help-with-my-htaccess-file/#findComment-827690 Share on other sites More sharing options...
twebman84 Posted May 6, 2009 Author Share Posted May 6, 2009 Yes, 'players' is an actual directory ... I'm going to put an .htaccess file in 'players' with the entry you suggested. Is that correct? Thanks for your time. Quote Link to comment https://forums.phpfreaks.com/topic/157108-simple-help-with-my-htaccess-file/#findComment-827743 Share on other sites More sharing options...
RussellReal Posted May 6, 2009 Share Posted May 6, 2009 yes it is correct Quote Link to comment https://forums.phpfreaks.com/topic/157108-simple-help-with-my-htaccess-file/#findComment-828090 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.