Jump to content

PM System Question


Guteman

Recommended Posts

Hey All,

Im in the middle of creating a private messanging system for my client system, but I have hit an issue. Here is my problem, I have a form and one of the fields is "recipient." Now, what im trying todo is to make sure the recipient(pm) =  login(client). This is what I tried todo.

[code]$checkname = mysql_query("SELECT login FROM clients WHERE login");
$checkname= mysql_fetch_array($checkname);[/code]

[code]else if($checkname != $_POST['recipient'])
{
$error_message .= '<p class="failure">Error: Username does not exist.</p>';
}[/code]

its not working, I think its a problem with my mysql query, can someone help?

Thanks,
Paul G.
Link to comment
https://forums.phpfreaks.com/topic/16508-pm-system-question/
Share on other sites

Let me clarify... I tried this, but still nothing

[code]$checkname = mysql_query("SELECT login FROM clients WHERE login='$_POST[recipient]'");
$checkname= mysql_fetch_array($checkname);

if(strlen($_POST['recipient']) <= 0)
{
$error_message .= '<p class="failure">Error: You did not enter a Recipient.</p>';
}

else if($checkname != $_POST['recipient'])
{
$error_message .= '<p class="failure">Error: Username does not exist.</p>';
}[/code]

I knew it was the while, but I cant figure out what to use.
Link to comment
https://forums.phpfreaks.com/topic/16508-pm-system-question/#findComment-68946
Share on other sites

sorry for spam

Let me use an example

I want to send a message to Guteman, one of my clients. I want to make sure I typed in the right name before the message is sent, or it sends an $error_message.

I want $checkname to become Guteman or any other client I have.

I meant WHERE not while, sorry
Link to comment
https://forums.phpfreaks.com/topic/16508-pm-system-question/#findComment-68948
Share on other sites

can you change
[code]$checkname = mysql_query("SELECT login FROM clients WHERE login='$_POST[recipient]'"); [/code]
to
[code]$checkname = mysql_query("SELECT login FROM clients WHERE login='$_POST[recipient]'") or die ("MySQL query error."); [/code]
?

That way we know wether or not the query is executing
Link to comment
https://forums.phpfreaks.com/topic/16508-pm-system-question/#findComment-68949
Share on other sites

[quote author=nethnet link=topic=102936.msg409311#msg409311 date=1154661065]
$checkname is an array, yet you are treating it as a string in your if statement.  Add a key called 'login' to it.

[code]$checkname['login'][/code]
[/quote]

Hehe I always try to help but I'm never the one who sees the real problem :P
Link to comment
https://forums.phpfreaks.com/topic/16508-pm-system-question/#findComment-68970
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.