PHP == Problem!!

Look at the code below....all it will do if show the mail and compose links.

It seems the ' if($action==inbox) { ' line won't work.... when I comment it out, the query works fine....what can be the matter?

echo '<a href="mail.php?action=compose">Compose</a> | <a href="mail.php?action=inbox">Inbox</a> |
<table cellpadding="1" cellspacing="1" height="300" width="450">
<tr><td align=center valign=top> ';

if($action==inbox) {
$query="SELECT UserTo, UserFrom, Subject, Message, status, mail_id FROM mail WHERE UserTo='$username'";
$result=mysql_query($query);

echo "<table cellpadding=2 cellspacing=1 width=500 valign=top>";
while ($row=mysql_fetch_array($result, MYSQL_ASSOC)) {
echo '<tr><td width=30>Mail</td><td><a href=mail.php?action=view&mail_id=$row[mail_id]>$row[Subject]</a></td><td width=50><a href=mail.php?action=delete&id=$row[mail_id]<center>Delete</a><br></td></tr>';
//mysql_free_result($result);
}
echo "</table>";
}
kornflakeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gileze33Commented:
Hi There.

You need to put the inbox in quotes for this to work, eg. if($action=="inbox") {

Hope this helps.
0
kornflakeAuthor Commented:
Wow...that wa quick...I tried what you said but it still seems not to work, I'm getting the same options..just compose and inbox..I'll include the entire file....and knock your points up if you help me get it going....


<?php
//include ('../header2.php');
//require_once ('../mysql_connect.php');  
include("../dbconn.php");

$username = fearghalm;
$result1=mysql_query("select username from agents WHERE username='$username'") or die ("cant do it");
$row100 = mysql_fetch_array($result1);
?>

| <a href="mail3.php?action=compose">Compose</a> | <a href="mail3.php?action=inbox">Inbox</a> |
<table cellpadding="1" cellspacing="1" height="300" width="450">
<tr><td align=center valign=top>
<?php


if($action=="compose") {
echo "<form action=mail3.php?action=compose2 method=post>";
echo "<table>";
echo "<tr><td>Subject:</td><td><input type=text name=subject size=20 value=$subject></td></tr>";
echo "<tr><td>To:</td><td><input type=text name=to size=20 value=$to></td></tr>";
echo "<tr><td>Message:</td><td><textarea rows=16 cols=45 name=message></text></td></tr>";
echo "<tr><td><button type=submit>Send Mail!</button></td></tr>";
echo "</table>";
echo "</form>";
}

if($action=="compose2") {
$subject or die("Subject Blank");
$message or die("Message Black");
$to or die("To blank");
$date = date(YmdHis);
   
   
$create = "INSERT INTO mail (UserTo, UserFrom, Subject, Message, SentDate, status)
VALUES ('$to','$username','$subject','$message','$date','unread')";
$create2 = mysql_query($create) or die("A letter could not be sent to $to!");
echo("Message Sent to $to!");

}

if($action=="inbox") {
$result=mysql_query("select * from mail where UserTo='$username' ORDER BY SentDate DESC") or die ("cant do it");
echo '<table cellpadding=2 cellspacing=1 width=500 valign=top>';
while ($row=mysql_fetch_array($result)) {
echo '<tr><td width=30>Mail:</td><td><a href=mail3.php?action=veiw&mail_id='.$row['mail_id'].'>$row[Subject]</a></td><td width=50> <a href=mail3.php?action=delete&id=$row[mail_id]><center>Delete</a><br></td></tr>';
}
echo "</table>";
}

if($action=="view") {
$result=mysql_query("select * from mail where UserTo='$username' and mail_id=$mail_id") or die ("cant do it");
$row=mysql_fetch_array($result);
if($row[UserTo]==$username) {
} else {
echo "<font face=verdana><b>This isn't your mail!";
exit;
}
$query="UPDATE mail SET status='read' WHERE UserTo='$username' AND mail_id='$row[mail_id]'";
$query or die("An error occurred resulting that this message has not been marked read.");
echo "<table border = 1 bordercolor = black width = 50% align=center><tr><td>$row[Subject]</td><td>$row[UserFrom]</td></tr><tr><td colspan='2'>$row[Message]<br><a href=mail3.php?action=compose&to=$row[UserFrom]&subject=RE:$row[Subject]>Reply</a></td></tr></table>";
$rs = mysql_query("UPDATE mail SET status='read' WHERE mail_id='$mail_id'");
}

if($action=="delete") {
$query = mysql_query("DELETE FROM mail WHERE mail_id='$id' LIMIT 1");
if($query) {
echo "<font face=verdana>Message Deleted.</font>";
} else {
echo "The message wasnt deleted.";
}
}
?>

0
gileze33Commented:
Can you give me the url to the page? Might help me understand what you problem is.
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

gileze33Commented:
Are you saying that there sould be more items in the menu, or that the rest of the page wont load?
0
gileze33Commented:
If the rest of the page wont load, just change the $action in the if function to $_GET['action']

Hope this helps.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kornflakeAuthor Commented:
ok, I'll test these out and get back to you in a bit....Thanks!
0
kornflakeAuthor Commented:
Great! Got it working...Thanks mate!
0
gileze33Commented:
No problem. Glad to be of assistance.

For future reference, this means that you have register_globals turned off on your server. This means that unlike in the older copies of PHP, you have to state the global that you want to load:

$_GET is from page url
$_POST is from a posted form
$_COOKIE is a cookie value

There are many more, but I cant remember them off hand. If you have Dreamweaver 8, just type $_ in some PHP and it'll tell you what the available options are.

Giles Williams,
CEO, QLE Internet Services.
http://www.qlehosting.com/
http://www.qledesign.com/
http://www.qleis.com/
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.