Jump to content

Echoing The Link For A Profile


ChidoriSoul

Recommended Posts

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

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

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

<?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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...