I am trying to make a profile system for my website, so that each user has their own profile...
I want to be able to put into my browser:
http://www.jiblob.com/profile?profileid=18 and have the profile for the user with user_id which is 18 to show up show up...
I am new to PHP, and I have only just started to make my own codes, becaus eI think that I am getting to grips with it... I have made this code:
Quote:
<?php
include ('http://www.jiblob.com/header.inc');
$page_title = 'Viewing Profile';
if (isset($profileid) > 0) {
$id = "$profileid";
echo "$id";
// Connect to the Database
// This file contains the database access information. This file also establishes a connection to MySQL and selects the database.
// Set the database access information as constants.
DEFINE ('DB_USER', 'ds');
DEFINE ('DB_PASSWORD', 'dsagffdg');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'dsagfdg');
if ($dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)) { // Make the connnection.
if (!mysql_select_db (DB_NAME)) { // If it can't select the database.
// Handle the error.
my_error_handler (mysql_errno(), 'Could not select the database: ' . mysql_error() );
// Print a message to the user, include the footer, and kill the script.
echo '<p><font color="red">The site is currently experiencing technical difficulties. We apologize for any inconvenience.</font></p>';
include_once ('http://www.jiblob.com/footer.inc');
exit();
} // End of mysql_select_db IF.
} else { // If it couldn't connect to MySQL.
// Print a message to the user, include the footer, and kill the script.
my_error_handler (mysql_errno(), 'Could not connect to the database: ' . mysql_error());
echo '<p><font color="red">The site is currently experiencing technical difficulties. We apologize for any inconvenience.</font></p>';
include_once ('http://www.jiblob.com/footer.inc');
exit();
}
// End of Connection code
$query = "SELECT username, first_name, last_name, email FROM userdata WHERE user_id='$id'";
$result = @mysql_query ($query);
if ($result > 0) {
echo '<table width="98%" border="1">';
echo '<td><font face="verdana" size="3">', $row[0]; '</td>';
echo '</table>';
}
}
?>
|
and It is supposed to show the username. The page does show up, but just doesnt work...
I think it is to do with:
Quote:
|
$query = "SELECT username, first_name, last_name, email FROM userdata WHERE user_id='$id'";
|
and:
Quote:
|
echo '<td><font face="verdana" size="3">', $row[0]; '</td>';
|
Help would be much appriciated :)