before I get into my issue I just wanted to say I took Temor's advice and I completely scrapped the old code (that I used from a tutorial online somewhere) and am using a totally new one built from scrap. I decided to get some professional help and picked up a friend named Tim who's been helping me code the pages. The site is coming along extremely well and we fixed the (linking to the profile page) issue that we had a while back. Check it out when you're not busy eh?
Ok so now I am putting together a pm system for users to interact among each other without the whole world knowing.Of course I am here because everything is not coming along like milk and honey.
Here is the code I am working with.
<?php if($profileOwner):?>
<div id="view4" class="tabcontent">
<h3><table width="800" border="0"> </h3>
<tr>
<td> See who's trying to message you.</td>
</tr>
</table>
<table width="800" border="0">
<tr>
<td><?php require_once"inbox.php"; ?></td>
</tr>
</table>
<br>
<?php
require_once"dbconnect.php";
mysql_connect("secret launch code");
$sql ="SELECT * FROM pm_inbox WHERE userid ='$pid' ORDER by id DESC";
$result = mysql_query($sql);
$count = $mysql_num_rows($result);
?>
</table>
<table width="800" border="0">
<form name-"form1" method="post" action="inbox.php">
<tr>
<td width="41" align ="center">#</td>
<td width="490">Title</td>
<td width="255">From</td>
</tr>
<?php
while($rows = mysql_fetch_array($result)){
?>
<?php if ($rows['viewed'] == 0) { // show messages in bold ?>
<tr>
<td width="41" align="center"> <input type="checkbox" id="checkbox[]" value="<?php echo $rows['id']; ?>" /> </td>
<td width="490"><a href"pm_view_in.php?in=>?php $rows echo $rows['id']; ?>"><b><?php echo $rows['title']; ?> </b> </a></td>
<td width="255"><?php echo $rows['from_username']; ?></td>
</tr>
<?php } else if ($rows['viewed'] == 1) { ?>
<tr>
<td width="41" align="center"> <input type="checkbox" id="checkbox[]" value="<?php echo $rows['id']; ?>" /></td>
<td width="490"><a href"pm_view_in.php?in=>?php $rows echo $rows['id']; ?>"><?php echo $rows['title']; ?></a></td>
<td width="255"><?php echo $rows['from_username']; ?></td>
</tr>
<?php } ?>
<?php } ?>
<tr>
<td colspan="3" align="center"> </td> <?php if (inboxMessages > 0) { ?> <input type="submit" name="delete" id="delete" value="delete selected messages" /> <?php } else { Print "There are no messages in your inbox";} ?> </td>
</table>
</h3>
</div>
<?php endif;?>
Code for the inbox.php<?php
session_start();
require_once 'dbconnect.php';
$sqlCommand = "SELECT id_user, username FROM fgusers3 WHERE username='" . $_SESSION['username'] . "'";
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error());
while ($row = mysqli_fetch_array($query)) {
$pid = $row["id_user"];
$username = $row["username"];
}
mysqli_free_result($query);
// check for new messages
$sqlCommand = "SELECT COUNT(id) AS numbers FROM pm_inbox WHERE userid='$pid' AND viewed='0'";
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error());
$result = mysqli_fetch_assoc($query);
$inboxMessagesNew = $result['numbers'];
// check for all messages in the inbox
$sqlCommand = "SELECT COUNT(id) AS numbers FROM pm_inbox WHERE userid='$pid'";
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error());
$result = mysqli_fetch_assoc($query);
$inboxMessagesTotal = $result['numbers'];
// check for all messages in the outbox
$sqlCommand = "SELECT COUNT(id) AS numbers FROM pm_outbox WHERE userid='$pid'";
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error());
$result = mysqli_fetch_assoc($query);
$outboxMessages = $result['numbers'];
?>
<?php if (!$_SESSION['username']) { ?>
Private Messenger System: <a href="pm_inbox.php">Inbox</a> <?php if ($inboxMessagesNew > 0) { print "<b>(".$inboxMessagesNew.")</b>"; } else{} ?> <?php print $inboxMessagesTotal; ?>, <a href="pm_outbox.php">Outbox</a> <?php print $outboxMessages; ?>, <a href="pm_send.php">Send New Message</a> <?php } else { print "You must be logged in first"; }?>
The error: Fatal error: Function name must be a string in /home/content/66/9481266/html/source/testing.php on line 324line 324 refers to
$count = $mysql_num_rows($result);