Jump to content


Photo

PM System Question


  • Please log in to reply
10 replies to this topic

#1 Guteman

Guteman
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts
  • LocationWisconsin

Posted 04 August 2006 - 02:34 AM

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.

$checkname = mysql_query("SELECT login FROM clients WHERE login"); 
			$checkname= mysql_fetch_array($checkname);

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

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

Thanks,
Paul G.

#2 bpops

bpops
  • Members
  • PipPipPip
  • Advanced Member
  • 232 posts

Posted 04 August 2006 - 02:36 AM

your code seems a bit incomplete.. I see an "else if" but no "if"..

#3 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 04 August 2006 - 02:38 AM

Your missing part of your WHERE clause. The syntax should be something like...

SELECT fld FROM tbl WHERE fld = 'value';


#4 Guteman

Guteman
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts
  • LocationWisconsin

Posted 04 August 2006 - 02:40 AM

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

$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>';
				}

I knew it was the while, but I cant figure out what to use.

#5 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 04 August 2006 - 02:42 AM

I knew it was the while, but I cant figure out what to use.

What while?

#6 Guteman

Guteman
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts
  • LocationWisconsin

Posted 04 August 2006 - 02:43 AM

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

#7 bpops

bpops
  • Members
  • PipPipPip
  • Advanced Member
  • 232 posts

Posted 04 August 2006 - 02:43 AM

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

That way we know wether or not the query is executing

#8 bpops

bpops
  • Members
  • PipPipPip
  • Advanced Member
  • 232 posts

Posted 04 August 2006 - 02:44 AM

you also might want to try changing
$_POST[recipient]
to
$_POST['recipient']

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

#9 nethnet

nethnet
  • Members
  • PipPipPip
  • Advanced Member
  • 284 posts
  • LocationPhiladelphia, PA, USA

Posted 04 August 2006 - 03:11 AM

$checkname is an array, yet you are treating it as a string in your if statement.  Add a key called 'login' to it.

$checkname['login']

"Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep."  --Scott Adams

Current project: nethnet.com

#10 Guteman

Guteman
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts
  • LocationWisconsin

Posted 04 August 2006 - 03:13 AM

thanks alot.. it worked.

#11 bpops

bpops
  • Members
  • PipPipPip
  • Advanced Member
  • 232 posts

Posted 04 August 2006 - 03:29 AM

$checkname is an array, yet you are treating it as a string in your if statement.  Add a key called 'login' to it.

$checkname['login']


Hehe I always try to help but I'm never the one who sees the real problem :P




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users