u214 Posted April 30, 2011 Share Posted April 30, 2011 Hello guys. I'm so sorry if y'all feel like I'm bothering with this noob threads. I'm making a dynamic stats signature using info my mysql. It currently is working like its supposed to. But i want to have an image of a player's stats of each player. For example. A player types in the URL: www.test.com/stats.php?user=Username Now, when a player accesses that url, the default stats image will be show, and for stats. I want the "Username" to be the query and that gets the info. For example: mysql_query("SELECT * FROM players WHERE user = '$usernamehere' How can i detect the url username though? This is my current set up: mysql_query("SELECT * FROM players WHERE user = 'test' - It's working. But i want to use variable and give that "Username" ( From url ) it's stats. Here's my current code: <?php $imagepath="css/images/dog.JPG"; $image=imagecreatefromjpeg($imagepath); $imgheight=imagesy($image); $color=imagecolorallocate($image, 255, 255, 255); include("config.php"); $result = mysql_query("SELECT * FROM playerinfo WHERE user = 'Test'", $connect); while($myrow = mysql_fetch_row($result)) { // Not working properly. imagestring($image, 5, 50, $imgheight-50, $myrow[0], $color); imagestring($image, 3, 30, $imgheight-30, $myrow[2], $color); } // This line works like it should: //imagestring($image, 5, 50, $imgheight-50, "Using it like this works!", $color); header('Content-Type: image/jpeg'); imagejpeg($image); ?> Quote Link to comment https://forums.phpfreaks.com/topic/235217-giving-a-page-its-unique-id/ Share on other sites More sharing options...
lastkarrde Posted April 30, 2011 Share Posted April 30, 2011 Add the following line before your SQL statement $user = mysql_real_escape_string($_GET['user']); And then alter your SQL statement to read: "SELECT * FROM playerinfo WHERE user = '$user'" Quote Link to comment https://forums.phpfreaks.com/topic/235217-giving-a-page-its-unique-id/#findComment-1208783 Share on other sites More sharing options...
u214 Posted April 30, 2011 Author Share Posted April 30, 2011 Opps, yeah forgot that. Thanks. Any answers to my question though? http://test.com/stats.php?user=NameToDetectHere How exactly would i write a code to detect "NameToDetectHere" then use his name to query and thus getting the stats? Quote Link to comment https://forums.phpfreaks.com/topic/235217-giving-a-page-its-unique-id/#findComment-1208791 Share on other sites More sharing options...
lalnfl Posted April 30, 2011 Share Posted April 30, 2011 You would have to set up like a file directory called Members. When a user would sign up to your site you would create a new folder for that member in the Members directory. Then it would come into work for the application you have here. You would simply pull up the image from the Members/username/profile_pic.jpg for example. Something like that. Quote Link to comment https://forums.phpfreaks.com/topic/235217-giving-a-page-its-unique-id/#findComment-1208792 Share on other sites More sharing options...
u214 Posted April 30, 2011 Author Share Posted April 30, 2011 Thanks for your answer lalnfl, but lastkarrde's way works best. Sorry for kinda "ignoring" that method lastkarrde, i thought it was just a way to escape the string :s. Once again, thank you so much. It works wonders. Cheers mate! Quote Link to comment https://forums.phpfreaks.com/topic/235217-giving-a-page-its-unique-id/#findComment-1208799 Share on other sites More sharing options...
lastkarrde Posted April 30, 2011 Share Posted April 30, 2011 Sure . Happy to help. Quote Link to comment https://forums.phpfreaks.com/topic/235217-giving-a-page-its-unique-id/#findComment-1208834 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.