Jump to content

Echoing The Link For A Profile


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

Edited by ChidoriSoul
Link to post
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

Edited by ChidoriSoul
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...