ChrisMartino Posted April 19, 2010 Share Posted April 19, 2010 Hey there, Thanks for taking the time to read, I keep getting a parse error, I'm not sure why though the code seems solid, Here it is: public function IsValidClient($username) { $CheckName = mysql_real_escape_string($username); $CheckClient = mysql_query("SELECT * FROM Clients WHERE Username = '".$CheckName."'"); if(mysql_num_rows($CheckClient) == 1) { return true; } else { return echo("Error: The control panel returned a error. (ERROR: #02)"); } } The line with the error is were it returns a echo statement. :/ Link to comment https://forums.phpfreaks.com/topic/199023-parse-error-parse-error/ Share on other sites More sharing options...
aeroswat Posted April 19, 2010 Share Posted April 19, 2010 Why would you return echo? Link to comment https://forums.phpfreaks.com/topic/199023-parse-error-parse-error/#findComment-1044663 Share on other sites More sharing options...
ChrisMartino Posted April 19, 2010 Author Share Posted April 19, 2010 Why would you return echo? because i want too? Link to comment https://forums.phpfreaks.com/topic/199023-parse-error-parse-error/#findComment-1044766 Share on other sites More sharing options...
seventheyejosh Posted April 19, 2010 Share Posted April 19, 2010 Just return the string, don't echo it. Also, is you function in a class object? You don't need public if it isn't. Also, try a syntax highlighting editor, like komodo.. It makes these things very easy to diagnose. Link to comment https://forums.phpfreaks.com/topic/199023-parse-error-parse-error/#findComment-1044769 Share on other sites More sharing options...
dotMoe Posted April 19, 2010 Share Posted April 19, 2010 public function IsValidClient($username) { $CheckName = mysql_real_escape_string($username); $CheckClient = mysql_query("SELECT * FROM Clients WHERE Username = '".$CheckName."'"); if(mysql_num_rows($CheckClient) == 1) { return true; } else { return "Error: The control panel returned a error. (ERROR: #02)"; } } $status = IsValidClient($username); if($status != TRUE ) { die($status); } Link to comment https://forums.phpfreaks.com/topic/199023-parse-error-parse-error/#findComment-1044779 Share on other sites More sharing options...
coldwater80 Posted April 19, 2010 Share Posted April 19, 2010 i guess the problem is here you should replace " with ' like below $CheckClient = mysql_query('SELECT * FROM Clients WHERE Username = "'.$CheckName.' " '); actually if you use STOPFTP it will be easier for you to try these kind of problems. http://www.stopftp.com Link to comment https://forums.phpfreaks.com/topic/199023-parse-error-parse-error/#findComment-1044824 Share on other sites More sharing options...
aeroswat Posted April 19, 2010 Share Posted April 19, 2010 i guess the problem is here you should replace " with ' like below $CheckClient = mysql_query('SELECT * FROM Clients WHERE Username = "'.$CheckName.' " '); actually if you use STOPFTP it will be easier for you to try these kind of problems. http://www.stopftp.com What he has should work. He never mentioned any other problems tho or if he still is having the problem. He just posted the edited code so we have no idea what's going on. Link to comment https://forums.phpfreaks.com/topic/199023-parse-error-parse-error/#findComment-1044829 Share on other sites More sharing options...
seventheyejosh Posted April 19, 2010 Share Posted April 19, 2010 The only problem, other than the fact that if it is not a class function, it shouldn't be public, is you can't return an echo! Link to comment https://forums.phpfreaks.com/topic/199023-parse-error-parse-error/#findComment-1044832 Share on other sites More sharing options...
aeroswat Posted April 19, 2010 Share Posted April 19, 2010 The only problem, other than the fact that if it is not a class function, it shouldn't be public, is you can't return an echo! i tried to tell him but he got butt hurt Link to comment https://forums.phpfreaks.com/topic/199023-parse-error-parse-error/#findComment-1044837 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.