ChidoriSoul 0 Posted June 28, 2009 Report Share Posted June 28, 2009 I am trying to have a profile where there is a page for each user, and I need the code to echo the link so I can do it.I want it to be like profile.php?id=1, and for ID 2, profile.php?id=2, etc.I just need some help with this. Quote Link to post Share on other sites
ckrudelux 9 Posted June 28, 2009 Report Share Posted June 28, 2009 I am trying to have a profile where there is a page for each user, and I need the code to echo the link so I can do it.I want it to be like profile.php?id=1, and for ID 2, profile.php?id=2, etc.I just need some help with this. if(isset($_GET['id']){$id = mysql_real_escape_string(htmlspecialchars($_GET['id']);$select = mysql_query("SELECT * FROM profiles WHERE profile_id='$id'");$row = mysql_fetch_array($select);//code for profile here}else {echo "Where is no profile here"} Does this help? Quote Link to post Share on other sites
ChidoriSoul 0 Posted June 28, 2009 Author Report Share Posted June 28, 2009 IT does, but what is the htmlspecialchars do, because I don't get what it is, and for the }else {echo "Where is no profile here"}That Quote Link to post Share on other sites
duncan_cowan 0 Posted June 28, 2009 Report Share Posted June 28, 2009 htmlspecialchars is a php function which converts special html characters such as quotes and the '&' sign into their html codes such as '&'this prevents text inputed from a website user from being outputted as code by the webpage.also the:}else {echo "Where is no profile here"}as you can see from the 'else' is what will happen when no id is set in the url ($_GET['id'])ie. 'Where is no profile here' is outputted onto the pageI have a feeling this should be 'There is no profile here' however i may be mistaken and is up to you. Quote Link to post Share on other sites
ChidoriSoul 0 Posted June 29, 2009 Author Report Share Posted June 29, 2009 well, there is an error on the page My Profile Page Quote Link to post Share on other sites
Synook 47 Posted June 29, 2009 Report Share Posted June 29, 2009 What does the code look like? Quote Link to post Share on other sites
ChidoriSoul 0 Posted July 1, 2009 Author Report Share Posted July 1, 2009 (edited) <?php// Connects to your Databasemysql_connect("fdb1.awardspace.com", "chidorisoul_sh", "******") or die(mysql_error());mysql_select_db("chidorisoul_sh") or die(mysql_error());if(isset($_GET['id'])$id = mysql_real_escape_string(htmlspecialchars($_GET['id']);$select = mysql_query("SELECT * FROM profiles WHERE profile_id='$id'");$row = mysql_fetch_array($select);//code for profile here}else {echo "Where is no profile here"}?><!--stuff--> Edited July 1, 2009 by ChidoriSoul Quote Link to post Share on other sites
justsomeguy 1,135 Posted July 1, 2009 Report Share Posted July 1, 2009 Line 7 is missing a closing paren. Quote Link to post Share on other sites
ChidoriSoul 0 Posted July 1, 2009 Author Report Share Posted July 1, 2009 (edited) Ok, then the code is now this <?php// Connects to your Databasemysql_connect("fdb1.awardspace.com", "chidorisoul_sh", "******") or die(mysql_error());mysql_select_db("chidorisoul_sh") or die(mysql_error());if(isset($_GET['id'])$id = mysql_real_escape_string(htmlspecialchars($_GET['id']));$select = mysql_query("SELECT * FROM profiles WHERE profile_id='$id'");$row = mysql_fetch_array($select);//code for profile here}else {echo "Where is no profile here"}?><!--stuff--> The error message is this, thoughParse error: syntax error, unexpected T_VARIABLE in /home/www/tparpg.awardspace.co.uk/profile.php on line 7 Edited July 1, 2009 by ChidoriSoul Quote Link to post Share on other sites
justsomeguy 1,135 Posted July 1, 2009 Report Share Posted July 1, 2009 (edited) Line 6 is also missing a paren. There's another error on the last echo line, and your if statement is missing an opening bracket. Edited July 1, 2009 by justsomeguy Quote Link to post Share on other sites
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.