Syntax Issue

Hello,

I am new to the forum and PHP. I am having a little trouble with the syntax of my Select statement. Here is what I have:


$var = $_POST[“lname”];
$trimmed = trim($var);

$query = “Select
Account_Info.Account_Num,
Account_Info.Owner_Name1,
Account_Info.Owner_Address_Line2,
account_apprl_year.TOT_Val
From Account_Info
INNER JOIN account_apprl_year
ON Account_Info.Account_Num=account_apprl_year.Account_Num
Where Owner_Name1 like “%$trimmed%””


I’m simply trying to search a MySQL database by last name and retrieve the records. I’m catching the last name in the POST and trimming it. Now I would like to use the trimmed variable in my Select statement but it is not working. I can’t see where the problem is. Does my Select statement look like it is formatted properly?

Thanks,
Darin

I’m not a pro, but it would help if you used the forum’s php tag, and then pasted the code in there. That way we can see it better and the formatting doesn’t get changed.

Hi best way to find problem is just echo your select query.

echo $query;
exit;

and see is the variable value is coming properly

because other than that I think you want be able to find the problem

Sponsor our Newsletter | Privacy Policy | Terms of Service