Jump to content

Recommended Posts

when i go to my inbox i get this errors

 

Notice: Undefined index: from_user in /home/ecabrera/public_html/inbox.php on line 34

 

$msg_from_user = $row['from_user'];

 

 

 

 

 

Notice: Undefined variable: num in /home/ecabrera/public_html/inbox.php on line 71

 

 

if ($num == 0){

 

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/ecabrera/public_html/inbox.php on line 107

 

$numrows = mysql_num_rows($query);

 

 

heres the whole code

 

<?php require('styles/top.php'); ?>
<title>Inbox </title>
<div id='full'>
<?php
if ($username){
echo "<a href='create_message.php'>Create Message</a>
<div id='box'>
  <b class='corners'>
  <b class='corners1'><b></b></b>
  <b class='corners2'><b></b></b>
  <b class='corners3'></b>
  <b class='corners4'></b>
  <b class='corners5'></b></b>
  <div class='cornersfg'>
	<div id='top'>Inbox for $username</div>
	<div id='bottom' style='padding: 10px;'>";
	////////////////////////////////////////////////////////////////////////
	require('scripts/connect.php');
	$query = mysql_query("SELECT * FROM messages WHERE to_user='$username' ORDER BY id DESC");
	$numrows = mysql_num_rows($query);
	if ($numrows > 0){
		echo "<form action='delete_message.php' method='POST'>";
		echo "<div id='messages'>
		<div id='leftside'><input type='checkbox' name='selectall'><input type='submit' name='deleteinbox' value='Delete' class='button'></div>
		<div id='rightside'>Date</div>
		<div id='center'>Subject and Message</div>
		<div style='clear: both;'></div>
		</div>";

		while($row = mysql_fetch_assoc($query)){
			$msg_id = $row['id'];
			$msg_to_user = $row['to_user'];
			$msg_to_id = $row['to_id'];
			$msg_from_user = $row['from_user'];
			$msg_from_id = $row['from_id'];
			$msg_subject = $row['subject'];
			$msg_content = $row['content'];
			$msg_date = $row['date'];
			$msg_from_delete = $row['from_delete'];
			$msg_to_delete = $row['to_delete'];

			if (!$msg_to_delete){
				echo "<div id='messages'>";
				echo "<div id='leftside'>
				<input type='checkbox' name='cb$msg_id' value='$msg_id'>
				<a href='profile.php?id=$msg_from_id' target='_blank'>$msg_from_user</a>
				</div>";
				echo "<div id='rightside'>$msg_date</div>";

				echo "<div id='center'>
				<span class='toggle'><a href='#'>$msg_subject</a></span>
				<div class='hiddenDiv'>
				<br>$msg_content<br><br>
				<span class='toggle'><a href='#'>REPLY</a></span>
				<div class='hiddenDiv'>
				<form action='reply.php' method='POST'>
					<input type='hidden' value='$msg_id' name='replyid'>
					<input type='text' name='replysubject' style='width: 300px;' class='text-box' value='RE: $msg_subject'><br>
					<textarea name='replycontent' style='width: 298px;' rows='5'></textarea><br><br>
					<input type='submit' name='replybutton' class='button' value='Reply'>
				</form>
				</div>
				</div>
				</div>";

				echo "<div style='clear: both;'></div>";
				echo "</div>";
				$num += 1;
			}
		}
		if ($num == 0){
			echo "You have no messages in your inbox.";
		}
		echo "</form>";
	}
	else
		echo "You have no messages in your inbox.";
	////////////////////////////////////////////////////////////////////////
echo "</div>
  </div>
  <b class='corners'>
  <b class='corners5'></b>
  <b class='corners4'></b>
  <b class='corners3'></b>
  <b class='corners2'><b></b></b>
  <b class='corners1'><b></b></b></b>
</div>";

/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////

echo "<div id='box'>
  <b class='corners'>
  <b class='corners1'><b></b></b>
  <b class='corners2'><b></b></b>
  <b class='corners3'></b>
  <b class='corners4'></b>
  <b class='corners5'></b></b>
  <div class='cornersfg'>
	<div id='top'>Outbox for $username</div>
	<div id='bottom' style='padding: 10px;'>";
	////////////////////////////////////////////////////////////////////////
	require('scripts/connect.php');
	$query = mysql_query("SELECT * FROM messages WHERE from_user='$username' ORDER BY id DESC");
	$numrows = mysql_num_rows($query);
	if ($numrows > 0){
		echo "<form action='delete_message.php' method='POST'>";
		echo "<div id='messages'>
		<div id='leftside'><input type='checkbox' name='selectall'><input type='submit' name='deleteoutbox' value='Delete' class='button'></div>
		<div id='rightside'>Date</div>
		<div id='center'>Subject and Message</div>
		<div style='clear: both;'></div>
		</div>";

		while($row = mysql_fetch_assoc($query)){
			$msg_id = $row['id'];
			$msg_to_user = $row['to_user'];
			$msg_to_id = $row['to_id'];
			$msg_from_user = $row['from_user'];
			$msg_from_id = $row['from_id'];
			$msg_subject = $row['subject'];
			$msg_content = $row['content'];
			$msg_date = $row['date'];
			$msg_from_delete = $row['from_delete'];
			$msg_to_delete = $row['to_delete'];

			if (!$msg_from_delete){
				echo "<div id='messages'>";
				echo "<div id='leftside'>
				<input type='checkbox' name='cb$msg_id' value='$msg_id'>
				<a href='profile.php?id=$msg_from_id' target='_blank'>$msg_from_user</a>
				</div>";
				echo "<div id='rightside'>$msg_date</div>";

				echo "<div id='center'>
				<span class='toggle'><a href='#'>$msg_subject</a></span>
				<div class='hiddenDiv'>
				<br>$msg_content<br><br>
				</div>
				</div>";

				echo "<div style='clear: both;'></div>";
				echo "</div>";
				$num += 1;
			}
		}
		if ($num == 0){
			echo "You have no messages in your outbox.";
		}
		echo "</form>";
	}
	else
		echo "You have no messages in your outbox.";
	////////////////////////////////////////////////////////////////////////
echo "</div>
  </div>
  <b class='corners'>
  <b class='corners5'></b>
  <b class='corners4'></b>
  <b class='corners3'></b>
  <b class='corners2'><b></b></b>
  <b class='corners1'><b></b></b></b>
</div>";

echo "</div>";
}
else
echo "<center><h2><font color='red'>You must be logged in to view this page.</font></h2></center>";
require('styles/bottom.php'); ?>

Link to comment
https://forums.phpfreaks.com/topic/244803-errors/
Share on other sites

before the while loop create the $num variable.

$num = 0;

 

add or die(mysql_error()) to your query, something isn't right in that...

$query = mysql_query("SELECT * FROM messages WHERE to_user='$username' ORDER BY id DESC") or die(mysql_error());

 

double check 'from_user' is the name of the column you're after.

Link to comment
https://forums.phpfreaks.com/topic/244803-errors/#findComment-1257472
Share on other sites

ok i fix the two of them but i i couldint fix the other one

 

 

Notice: Undefined index: from_user in /home/ecabrera/public_html/inbox.php on line 36

 

$msg_from_user = $row['from_user'];

 

 

 

Notice: Undefined index: from_user in /home/ecabrera/public_html/inbox.php on line 123

 

	$msg_from_user = $row['from_user'];

Link to comment
https://forums.phpfreaks.com/topic/244803-errors/#findComment-1257477
Share on other sites

when i add that i got this

 

array(10) { ["id"]=> string(1) "1" ["to_user"]=> string(9) "ecabrera9" ["to_id"]=> string(1) "2" ["from__user"]=> string( "ecabrera" ["from_id"]=> string(1) "1" ["subject"]=> string(4) "test" ["content"]=> string(14) "hey fgjblrftjg" ["date"]=> string(12) "Aug 14, 2011" ["from_delete"]=> string(1) "0" ["to_delete"]=> string(1) "0" } 

Link to comment
https://forums.phpfreaks.com/topic/244803-errors/#findComment-1257493
Share on other sites

change this...

$msg_from_user = $row['from_user'];

to this...

$msg_from_user = $row['from__user'];

 

As you can see in the var_dump results, from__user has two underscores in it. So either change that in your code to two underscores, or change your table field to one underscore.

Link to comment
https://forums.phpfreaks.com/topic/244803-errors/#findComment-1257495
Share on other sites

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.