Guteman Posted August 4, 2006 Share Posted August 4, 2006 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 More sharing options...
bpops Posted August 4, 2006 Share Posted August 4, 2006 your code seems a bit incomplete.. I see an "else if" but no "if".. Link to comment https://forums.phpfreaks.com/topic/16508-pm-system-question/#findComment-68941 Share on other sites More sharing options...
trq Posted August 4, 2006 Share Posted August 4, 2006 Your missing part of your WHERE clause. The syntax should be something like...[code]SELECT fld FROM tbl WHERE fld = 'value';[/code] Link to comment https://forums.phpfreaks.com/topic/16508-pm-system-question/#findComment-68944 Share on other sites More sharing options...
Guteman Posted August 4, 2006 Author Share Posted August 4, 2006 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 More sharing options...
trq Posted August 4, 2006 Share Posted August 4, 2006 [quote]I knew it was the while, but I cant figure out what to use.[/quote]What while? Link to comment https://forums.phpfreaks.com/topic/16508-pm-system-question/#findComment-68947 Share on other sites More sharing options...
Guteman Posted August 4, 2006 Author Share Posted August 4, 2006 sorry for spamLet me use an exampleI 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 More sharing options...
bpops Posted August 4, 2006 Share Posted August 4, 2006 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 More sharing options...
bpops Posted August 4, 2006 Share Posted August 4, 2006 you also might want to try changing$_POST[recipient] to $_POST['recipient']i dunno if those quotes matter a whole lot or not. Link to comment https://forums.phpfreaks.com/topic/16508-pm-system-question/#findComment-68951 Share on other sites More sharing options...
nethnet Posted August 4, 2006 Share Posted August 4, 2006 $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] Link to comment https://forums.phpfreaks.com/topic/16508-pm-system-question/#findComment-68962 Share on other sites More sharing options...
Guteman Posted August 4, 2006 Author Share Posted August 4, 2006 thanks alot.. it worked. Link to comment https://forums.phpfreaks.com/topic/16508-pm-system-question/#findComment-68964 Share on other sites More sharing options...
bpops Posted August 4, 2006 Share Posted August 4, 2006 [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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.