wsg14
06-09-2008, 12:00 AM
<?php
if($logged['in'] === 0){
header("Location: index.php");
} else {
$query = mysql_query("SELECT * FROM `private_messages` WHERE `to` = '". $sess_username."'");
$pm_count = mysql_num_rows($query);
$today = date("m.d.Y");
$yesterday - mktime(0, 0, 0, date( 'm' ) , date( 'd' ) - 1, date( 'y' ));
$read = mysql_query("SELECT `read` FROM `private_messages` WHERE `to` = '".$sess_username."'");
echo ($today);
while ($display = mysql_fetch_array($query1)){
if($pm_count == 0){
echo 'You do not have any messages at this time.';
} else{
$query1 = mysql_query("SELECT * FROM private_messages WHERE date='".$today."' AND to='".$sess_username."'")or die(mysql_error());
if(mysql_num_rows($query1) > 0){
echo "<b>Today</b><br />";
while($display=mysql_fetch_array($query1)){
if($read === 0){ echo "<b>";
echo "</b>";
echo $display["title"]." - ".$display["from"];
echo "<br />";
} else {
echo "</b>";
echo $display["title"]." - ".$display["from"];
echo "<br />";
}
}
}
$query2 = mysql_query("SELECT * FROM private_messages WHERE date='".$yesterday."' AND to='".$sess_username."'")or die(mysql_error());
if(mysql_num_rows($query2) > 0){
echo "<b>Yesterday</b><br />";
while($display=mysql_fetch_array($query2)){
if($read === 0){ echo "<b>";
echo "</b>";
echo $display["title"]." - ".$display["from"];
echo "<br />";
} else {
echo "</b>";
echo $display["title"]." - ".$display["from"];
echo "<br />";
}
}
}
$query3 = mysql_query("SELECT * FROM private_messages WHERE `date`!='".$today."' AND `date`!='".$yesterday."' AND `to`='".$sess_username."'")or die(mysql_error());
$lastdate="";
while($display=mysql_fetch_array($query3)){
if($display["date"]==$lastdate){
if($read === 0){ echo "<b>";
echo "</b>";
echo $display["title"]." - ".$display["from"];
echo "<br />";
} else {
echo "</b>";
echo $display["title"]." - ".$display["from"];
echo "<br />";
}
}
}
$lastdate=$display["date"];
echo "<b>".$lastdate."</b><br />";
if($read === 0){ echo "<b>";
echo "</b>";
echo $display["title"]." - ".$display["from"];
echo "<br />";
} else {
echo "</b>";
echo $display["title"]." - ".$display["from"];
echo "<br />";
}
}
}
}
?>I've come back to coding PHP, and I'm starting a simple script. I'm having aporblem though, it's not displaying any PM's (there's only 1 in the database) I echoed what the $today variable comes out as, and it says 09.05.2008. I enetered that in the 'date' column for the PM and nothing showed up. Anybody know what's up with it? +rep
EDIT: I'm now getting the following error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'to='Will'' at line 1
Which has to do witht he following code:
$query = mysql_query("SELECT * FROM `private_messages` WHERE `to` = '".$sess_username."'");
if($logged['in'] === 0){
header("Location: index.php");
} else {
$query = mysql_query("SELECT * FROM `private_messages` WHERE `to` = '". $sess_username."'");
$pm_count = mysql_num_rows($query);
$today = date("m.d.Y");
$yesterday - mktime(0, 0, 0, date( 'm' ) , date( 'd' ) - 1, date( 'y' ));
$read = mysql_query("SELECT `read` FROM `private_messages` WHERE `to` = '".$sess_username."'");
echo ($today);
while ($display = mysql_fetch_array($query1)){
if($pm_count == 0){
echo 'You do not have any messages at this time.';
} else{
$query1 = mysql_query("SELECT * FROM private_messages WHERE date='".$today."' AND to='".$sess_username."'")or die(mysql_error());
if(mysql_num_rows($query1) > 0){
echo "<b>Today</b><br />";
while($display=mysql_fetch_array($query1)){
if($read === 0){ echo "<b>";
echo "</b>";
echo $display["title"]." - ".$display["from"];
echo "<br />";
} else {
echo "</b>";
echo $display["title"]." - ".$display["from"];
echo "<br />";
}
}
}
$query2 = mysql_query("SELECT * FROM private_messages WHERE date='".$yesterday."' AND to='".$sess_username."'")or die(mysql_error());
if(mysql_num_rows($query2) > 0){
echo "<b>Yesterday</b><br />";
while($display=mysql_fetch_array($query2)){
if($read === 0){ echo "<b>";
echo "</b>";
echo $display["title"]." - ".$display["from"];
echo "<br />";
} else {
echo "</b>";
echo $display["title"]." - ".$display["from"];
echo "<br />";
}
}
}
$query3 = mysql_query("SELECT * FROM private_messages WHERE `date`!='".$today."' AND `date`!='".$yesterday."' AND `to`='".$sess_username."'")or die(mysql_error());
$lastdate="";
while($display=mysql_fetch_array($query3)){
if($display["date"]==$lastdate){
if($read === 0){ echo "<b>";
echo "</b>";
echo $display["title"]." - ".$display["from"];
echo "<br />";
} else {
echo "</b>";
echo $display["title"]." - ".$display["from"];
echo "<br />";
}
}
}
$lastdate=$display["date"];
echo "<b>".$lastdate."</b><br />";
if($read === 0){ echo "<b>";
echo "</b>";
echo $display["title"]." - ".$display["from"];
echo "<br />";
} else {
echo "</b>";
echo $display["title"]." - ".$display["from"];
echo "<br />";
}
}
}
}
?>I've come back to coding PHP, and I'm starting a simple script. I'm having aporblem though, it's not displaying any PM's (there's only 1 in the database) I echoed what the $today variable comes out as, and it says 09.05.2008. I enetered that in the 'date' column for the PM and nothing showed up. Anybody know what's up with it? +rep
EDIT: I'm now getting the following error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'to='Will'' at line 1
Which has to do witht he following code:
$query = mysql_query("SELECT * FROM `private_messages` WHERE `to` = '".$sess_username."'");