Phpfr3ak Posted November 8, 2010 Share Posted November 8, 2010 I'm unsure as to why thsi doesnt work.. any clues? $scoretype = mysql_real_escape_string($users['scoretype']); <?php echo $scoretype ?> Quote Link to comment https://forums.phpfreaks.com/topic/218127-echo-variable/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 8, 2010 Share Posted November 8, 2010 Since you forgot to tell us what it does do vs what output you expected, no one here can directly help you. It also appears that those two lines of code are taken out of their actual context, so there could easily be a dozen different problems in the code you did not post that could cause the two lines you did post to not work. Post the actual code that demonstrates the problem and tell us what the actual symptom is. Quote Link to comment https://forums.phpfreaks.com/topic/218127-echo-variable/#findComment-1131863 Share on other sites More sharing options...
Phpfr3ak Posted November 8, 2010 Author Share Posted November 8, 2010 Sorry, the code is to echo a certain aspect from the database that is selected i.e /playerranks.php?ReportType=score would echo the score colum, /playerranks.php?ReportType=cash_Stolen would echo the cash_stolen colum and so on, Sorry for not being so clear. Quote Link to comment https://forums.phpfreaks.com/topic/218127-echo-variable/#findComment-1131868 Share on other sites More sharing options...
arbitter Posted November 8, 2010 Share Posted November 8, 2010 Because there is no ';' ? Quote Link to comment https://forums.phpfreaks.com/topic/218127-echo-variable/#findComment-1131879 Share on other sites More sharing options...
PFMaBiSmAd Posted November 8, 2010 Share Posted November 8, 2010 To reference the value from the url for ?ReportType= xxxxx you would need to use $_GET['ReportType'] in your php code. Quote Link to comment https://forums.phpfreaks.com/topic/218127-echo-variable/#findComment-1131897 Share on other sites More sharing options...
Phpfr3ak Posted November 8, 2010 Author Share Posted November 8, 2010 Hmmm odd i tried: Notice: Undefined index: $ReportType in C:\Program Files\EasyPHP-5.3.3\www\htdocs\playerranks.php on line 60 if i echo $reporttype the actual colum is echo'd, but i cant echo the specific reportype based for the users, Rather odd. <?php $ReportType = mysql_real_escape_string($_GET['ReportType']); ?> <?php echo $users['$ReportType'] ?> Quote Link to comment https://forums.phpfreaks.com/topic/218127-echo-variable/#findComment-1131902 Share on other sites More sharing options...
PFMaBiSmAd Posted November 8, 2010 Share Posted November 8, 2010 Php variables are not replaced with their value when they are enclosed by single-quotes. Unless you are building a string that also contains literal characters in addition to php variables, there's no point in putting any quotes around a php variable. Quote Link to comment https://forums.phpfreaks.com/topic/218127-echo-variable/#findComment-1131908 Share on other sites More sharing options...
Phpfr3ak Posted November 8, 2010 Author Share Posted November 8, 2010 That was it, Thanks for that! Taught me something i didn't know :] Quote Link to comment https://forums.phpfreaks.com/topic/218127-echo-variable/#findComment-1131916 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.