Jump to content

Archived

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

Guteman

PM System Question

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.

Share this post


Link to post
Share on other sites
your code seems a bit incomplete.. I see an "else if" but no "if"..

Share this post


Link to post
Share on other sites
Your missing part of your WHERE clause. The syntax should be something like...

[code]
SELECT fld FROM tbl WHERE fld = 'value';
[/code]

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
[quote]I knew it was the while, but I cant figure out what to use.[/quote]
What while?

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
you also might want to try changing
$_POST[recipient]
to
$_POST['recipient']

i dunno if those quotes matter a whole lot or not.

Share this post


Link to post
Share on other sites
$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]

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

×

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.