ChidoriSoul Posted June 28, 2009 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. Link to comment Share on other sites More sharing options...
ckrudelux Posted June 28, 2009 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? Link to comment Share on other sites More sharing options...
ChidoriSoul Posted June 28, 2009 Author 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 Link to comment Share on other sites More sharing options...
duncan_cowan Posted June 28, 2009 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. Link to comment Share on other sites More sharing options...
ChidoriSoul Posted June 29, 2009 Author Share Posted June 29, 2009 well, there is an error on the page My Profile Page Link to comment Share on other sites More sharing options...
Synook Posted June 29, 2009 Share Posted June 29, 2009 What does the code look like? Link to comment Share on other sites More sharing options...
ChidoriSoul Posted July 1, 2009 Author Share Posted July 1, 2009 <?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--> Link to comment Share on other sites More sharing options...
justsomeguy Posted July 1, 2009 Share Posted July 1, 2009 Line 7 is missing a closing paren. Link to comment Share on other sites More sharing options...
ChidoriSoul Posted July 1, 2009 Author Share Posted July 1, 2009 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 Link to comment Share on other sites More sharing options...
justsomeguy Posted July 1, 2009 Share Posted July 1, 2009 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.