Jump to content

Recommended Posts

i dont knw why its keep telling me

 

Notice: Undefined variable: lowdownDisplay in C:\wamp\www\bullshit.php on line 112

 

some1 please tell me wot i can do to fix this

 

 

$sql = mysql_query("SELECT id, mem_id, the_lowdown, post_time FROM lowdown_db ORDER BY post_time DESC LIMI 20");
//$lowdownDisplayList = '';

while ($row = mysql_fetch_array($sql)) {
//$lowdownDisplay = '<table width="0%"  border="0" align="center" cellpadding="5"> 
					//<tr>';
$lowdownid = $row["id"];
$uid = $row["mem_id"];
$the_lowdown = $row["the_lowdown"];
$the_date = $row["post_time"];
$the_date = strftime("%b %d, %Y", strtotime($post_time));
///// inner SQL QUERY
$sql_mem_data = mysql_query("SELECT id, firstname, lastname FROM mymembers WHERE id='$uid' LIMIT 1");
$lowdownDisplayList.= '<td><div style="height:80px; overflow:hidden;" > ' .$user_pic. ' </div><a href="profile.php?id=' .$id. '"><br>'.$firstname.' '.$lastname.'</a></td> ';
//$lowdownDisplayList = ''<td><div style="height:80px; overflow:hidden;" > ' .$user_pic. ' </div><a href="profile.php?id=' .$id. '"><br>'.$firstname.' '.$lastname.'</a></td> ';
	while ($row = mysql_fetch_array($sql_mem_data)){
	$uid = $row["id"];
	$ufirstname = $row["firstname"];
	$ufirstname = $row["lastname"];
	$ufirstname = substr($ufirstname,0,10);
	///////display lowdown pic//////////
	$ucheck_pic = "memberFiles/$uid/image01.jpg";
	$udefault_pic = "memberFiles/0/image01.jpg";
	if (file_exists($ucheck_pic)) {
    	$lowdown_pic = "<img src=\"$check_pic\" width=\"40px\" />"; // forces picture to be 100px wide and no more
	} else {
	$lowdown_pic = "<img src=\"$default_pic\" width=\"40px\" />"; // forces default picture to be 100px wide and no more
}

	$lowdownDisplayList.= '
	<table width="95%" align="center" cellpadding="4" bgcolor="#ffffff">
	<tr>
	<td width="7%" height="161" bgcolor="#996600"><a href="profile.php?id=' .$id .'">' .$lowdown_pic . '</a><br/>		</td>
	 <td width="93%"   bgcolor="#CCCCCC" ><a href="profile.php?id=' .$id .'">' .$ufirstname . ' ' .$ulastname . ' </a>
	 • <span style="font-size:10px;"> ' .$post_time . ' </span><br/>
	 ' .$the_lowdown. ' </td>
	</table>';
	}

}
?>

[code/]

Link to comment
https://forums.phpfreaks.com/topic/212928-undefine-variable-ive-tried-everything/
Share on other sites

To avoid these notices, make sure to define variables before trying to to use them.

 

Remember, using a self acting concatenation or operand such as .= or +=  will rely on the said variable's value prior to reassignment. So if said variables value is unset, an undefined variable notice is thrown.

 

.=  <-- is not bad. Just declare the variable first using $myVar = null;

thnx i got that problem solved but the table styll wont loop to take the information out ot the database. i dont knw why im using the same sciprt on another loop and it works fine

 

  <?
   
   $sql_lowdown = mysql_query("SELECT id, mem_id, the_lowdown, post_time FROM lowdown_db WhHERE mem_id='$id' ORDER BY post_time DESC LIMI 20");

while($row = mysql_fetch_array($sql_lowdown)) {

$lowid = $row["id"];
$uid = $row["mem_id"];
$the_lowdown = $row["the_lowdown"];
$the_date = $row["post_time"];
$the_date = strftime("%b %d, %Y", strtotime($post_time));

$LowdownDisplayList.= '
	<table width="95%" align="center" cellpadding="4" bgcolor="#ffffff">
	<tr>
	<td width="7%" height="161" bgcolor="#996600"><a href="profile.php?id=' .$id .'">' .$lowdown_pic . '</a><br/>		</td>
	 <td width="93%"   bgcolor="#CCCCCC" ><a href="profile.php?id=' .$id .'">' .$firstname . ' ' .$lastname . ' </a>
	 • <span style="font-size:10px;"> ' .$post_time . ' </span><br/>
	 ' . $the_lowdown . ' </td>
	</table>';
   }
   
   ?>

in the code that you were showing (you just changed the code in your post) the variable $id is undefined, that will more likely cause that your query

$sql_lowdown = mysql_query("SELECT id, mem_id, the_lowdown, post_time FROM lowdown_db WhHERE mem_id='$id' ORDER BY post_time DESC LIMI 20");

will either fail or not return any value.

 

you must validate that your $id variable effectively has some value and then  rewrite that code in this alternative way:

$sql_lowdown = mysql_query("SELECT id, mem_id, the_lowdown, post_time FROM lowdown_db WhHERE mem_id='$id' ORDER BY post_time DESC LIMI 20") or die("Query Error: " . mysql_error());
if (mysql_num_rows($sql_lowdown) > 0) {
   // The query returned values... therefore here you canb continue the rest of your code
} else { echo "..No records found.."; };

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.