Im currently having some problems with getting a script to run and im not really too sure why that is tbh
Here is what i want to do.....
I am currently developing a private messaging system which will hopefully, be not to dissimilar to its phpBB
equivalent, now i have actually developed 2, the other works but its features are very limited, on my first one i
could not distinguish between what messages had been read and which had'nt, a couple of other useful features also, unfortunately
i couldnt implement to my satisfaction
the Read_Unread column should work by setting a flag as read on a page as the columns default is Unread so hopefully i can
do this, i cannot really see any downside to doing it this way as it can always be marked as unread if the user wishes
NOW HERES MY PROBLEM
i am having trouble with my database query (i believe)
My Database Connection
SERVER - localhost
USER - malcolmboston
PASSWORD - xxxxxx
The table i am trying to interact with
DATABASE NAME - tees-drug-network
TABLE NAME - private_messaging
Structure Of Table
Recipient
Sender
Subject
Message
Timestamp
Read_Unread
Heres the query
Code: Select all
<?php
$_SESSION['username'] = malcolmboston;
// database variables for connections
$host = "localhost";
$user = "malcolmboston";
$password = "xxxxxx";
$DBname = "tees-drug-network";
$tablename = "private_messaging";
//connection variables completed
// establishing connections
$link = mysql_connect ($host, $user, $password);
//connection established
//the query defined
$query = "SELECT * FROM $tablename WHERE recipient = '".$_SESSION['username']." AND Read_Unread ==unread'";
// select the database
mysql_select_db($DBname);
//getting the data
$result = mysql_query($query);
$data = mysql_fetch_array($result, MYSQL_ASSOC);
//ways of showing the data
//none work
php print $query
<br>
php print $result
<br>
php print $data
<br>see the extra 'colon' (or whatever its called) now i dont believe that is supposedAND Read_Unread ==unread'"
to be there, however, when i remove it or add the matching 'colon' it gives me this
which is this line.......mysql_fetch_array(): supplied argument is not a valid MySQL result resource in <b>PHPDocument3</b> on line <b>20</b><br />
[qoute]$data = mysql_fetch_array($result, MYSQL_ASSOC);[/quote]
i get this message alot in other scripts (if anyone can tell me why i would be forever in your debt!) i have created but have managed to sort them out, however this is my first time at
trying to do "multi-query" and i am merely guessing at the correct syntax as the mysql manual doesnt list any type of query like
this, only very simple ones not including VARS
Now i know this is only going to show me the actual Unread messages for a user (designated by there session_name meaning only that
person can get there e-mail, ive did this before and it works btw) so i was going to do to 2 queries, one retrieving all messages for the
user and then after that retrieving the unread messages and listing them at the top
This doesnt work, btw but u get the idea
Code: Select all
//number of unread messages or even simpler just to see if there are ANY!
$unread_msgs = result from query
//var is now setCode: Select all
<?php
if ($unread_msgs >= 1) {
header ("Location: mail_yes.php");
} else {
header ("Location: mail_no.php");
exit;
}
?>a script for a long time now.
if you need anymore info, dont hesitate to ask
thanks