Hi all,
so fifteen days without having to ask questions ! Yeeeaaah !!
And now I'm stuck again...
As you know by now I'm trying to build a membership system - if you feel like joining up it's free and it's here:
[url]http://%20www.shutterbugclub.com[/url]
it's going OK but now I'm stumbling over the member profile page. Code below. The page displays OK, shows the default member picture (an avatar) and the member info. But I get these errors: (line numbers plus one on code below).
Notice: Undefined index: id in /Sites/com/shutterbugclub/www/profile.php on line 25
Notice: Undefined index: bio_body in /Sites/com/shutterbugclub/www/profile.php on line 52
Notice: Undefined index: blab_field in /Sites/com/shutterbugclub/www/profile.php on line 78
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /Sites/com/shutterbugclub/www/profile.php on line 134
All and any help / advice much appreciated.
Best wishes
Monty
Code: Select all
<?php
session_start();
// Connect to database
//include_once "scripts/connect_to_mysql.php";
$host = "localhost";
$user="blahblahblah";
$password="blahblahblah";
$database="blahblahblah";
$connection = mysql_connect($host, $user,$password)
or die ("Couldn't connect to server.");
$db = mysql_select_db($database, $connection)
or die ("Couldn't select the database.");
// Now let's initialize vars to be printed to page in the HTML section so our script does not return errors
// they must be initialized in some server environments
$id = "";
$firstname = "";
$lastname = "";
$bio_body = "";
$website = "";
$youtube = "";
$user_pic = "";
$blabberDisplayList = "";
// If coming from category page
if ($_GET['id']) {
$id = $_GET['id'];
} else if (isset($_SESSION['id'])) {
$id = $_SESSION['id'];
} else {
include_once "index.php";
exit();
}
$id = mysql_real_escape_string($id);
$id = eregi_replace("`", "", $id);
$sql = mysql_query("SELECT * FROM myMembers WHERE id='$id'");
while($row = mysql_fetch_array($sql)){
$firstname = $row["firstname"];
$lastname = $row["lastname"];
$email = $row["email"];
//$email = "<a href=\"mailto:$email\"><u><font color=\"#006600\">Mail</font></u></a>";
$sign_up_date = $row["sign_up_date"];
$sign_up_date = strftime("%b %d, %Y", strtotime($sign_up_date));
$last_log_date = $row["last_log_date"];
$last_log_date = strftime("%b %d, %Y", strtotime($last_log_date));
$bio_body = $row["bio_body"];
$website = $row["website"];
$youtube = $row["youtube"];
/////// Mechanism to Display Pic. See if they have uploaded a pic or not //////////////////////////
$check_pic = "members/$id/image01.jpg";
$default_pic = "members/0/image01.jpg";
if (file_exists($check_pic)) {
$user_pic = "<img src=\"$check_pic\" width=\"200px\" />"; // forces picture to be 100px wide and no more
} else {
$user_pic = "<img src=\"$default_pic\" width=\"200px\" />"; // forces default picture to be 100px wide and no more
}
/////// Mechanism to Display Youtube Channel or not //////////////////////////
if ($youtube == "") {
$youtubeChannel = "<br />This user has no YouTube channel yet.";
} else {
$youtubeChannel = ' <script src="http://www.gmodules.com/ig/ifr?url=http://www.google.com/ig/modules/youtube.xml&up_channel=' . $youtube . '&synd=open&w=290&h=370&title=&border=%23ffffff%7C3px%2C1px+solid+%23999999&output=js"></script> '; // forces default picture to be 100px wide and no more
}
} // close while loop
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$style_sheet = "default";
?>
<?php
// Place Blab post into database
$blab_outout_msg = "";
if ($_POST['blab_field'] != ""){
// Delete any blabs over 20 for this member
$sqlDeleteBlabs = mysql_query("SELECT * FROM blabbing WHERE mem_id='$id' ORDER BY blab_date DESC LIMIT 50");
$bi = 1;
while ($row = mysql_fetch_array($sqlDeleteBlabs)) {
$blad_id = $row["id"];
if ($bi > 20) {
$deleteBlabs = mysql_query("DELETE FROM blabbing WHERE id='$blad_id'");
}
$bi++;
}
// End Delete any blabs over 20 for this member
$blab_field = $_POST['blab_field'];
$blab_field = stripslashes($blab_field);
$blab_field = strip_tags($blab_field);
$blab_field = mysql_real_escape_string($blab_field);
$blab_field = eregi_replace("'", "'", $blab_field);
$sql = mysql_query("INSERT INTO blabbing (mem_id, the_blab, blab_date)
VALUES('$id','$blab_field', now())")
or die (mysql_error());
$blab_outout_msg = "Your Blab has been posted!";
}
?>
<?php
$the_blab_form = "";
if (isset($_SESSION['id'])) {
if ($_SESSION['id'] == $id){
$the_blab_form = '
' . $blab_outout_msg . '
<form action="profile.php" method="post" enctype="multipart/form-data" name="blab_from">
<textarea name="blab_field" rows="3" style="width:97%;"></textarea>
Blab away (220 char max) <input name="submit" type="submit" value="submit" />
</form>';
}
}
?>
<?php
$sql_blabs = mysql_query("SELECT id, mem_id, the_blab, blab_date FROM blabbing WHERE mem_id='$id' ORDER BY blab_date DESC LIMIT 20");
while($row = mysql_fetch_array($sql_blabs)){
$blabid = $row["id"];
$uid = $row["mem_id"];
$the_blab = $row["the_blab"];
$blab_date = $row["blab_date"];
$blab_date = strftime("%b %d, %Y, %Y %I:%M:%S %p", strtotime($blab_date));
$blabberDisplayList .= '
<table width="100%" align="center" cellpadding="4" bgcolor="#A6D2FF">
<tr>
<td width="93%" bgcolor="#D9ECFF"><span style="font-size:10px; font-weight:bold; color:#A6A6A6;">' . $blab_date . '</span><br />
' . $the_blab . '</td>
</tr>
</table>';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="Description" content="Profile for <?php print "$firstname $lastname"; ?>" />
<meta name="Keywords" content="<?php print "$firstname, $lastname"; ?>" />
<meta name="rating" content="General" />
<meta name="ROBOTS" content="All" />
<title>Site Profile for <?php print "$firstname $lastname"; ?></title>
<link href="style_profiles/<?php print "$style_sheet"; ?>.css" rel="stylesheet" type="text/css" />
<link rel="icon" href="http://www.yourdomain.com/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="http://www.yourdomain.com/favicon.ico" type="image/x-icon" />
</head>
<body>
<?php include_once "header_template.php"; ?>
<table width="950" align="center">
<tr>
<td width="758"><br />
<table width="90%" border="0" align="center" cellpadding="6">
<tr>
<td width="48%" valign="top">
<?php print "$firstname $lastname"; ?>
<br />
<?php print "$user_pic"; ?>
<br />
Member Since: <?php print "$sign_up_date"; ?>
<br />
<?php print "$youtubeChannel"; ?>
</td>
<td width="52%" valign="top">
<br />
<strong><u><?php print "$firstname $lastname"; ?>'s Blabs:</u></strong>
<br />
<?php print "$the_blab_form"; ?>
<div style="width:100%; height:180px; overflow:auto; overflow-x:hidden;">
<?php print "$blabberDisplayList"; ?>
</div>
<br />
<br />
<strong><u><?php print "$firstname $lastname"; ?>'s Location Details:</u></strong>
<br />
<br />
<strong><u>About <?php print "$firstname $lastname"; ?></u></strong>
<br />
<?php print "$bio_body"; ?>
<br />
</td>
</tr>
<tr>
<td colspan="2" valign="top"> </td>
</tr>
</table>
<p><br />
<br />
</p>
<p> </p>
<p><br />
<br />
<br />
<br />
<br />
</p></td>
<td width="180" valign="top"><?php include_once "right_AD_template.php"; ?></td>
</tr>
</table>
<?php include_once "footer_template.php"; ?>
</body>
</html>