In side a php block I have the following:
$sql2 ="SELECT accountID, account_desc FROM $table_name2 WHERE $type1=accountID";
I can run this query from mySQL and it runs fine however I'm getting a sql syntax error inside the php block. I've tried it with single quotes around the second accountID and same error.
What am I doing wrong?
PHPMySQL Server
Last Comment
jello32
8/22/2022 - Mon
gamebits
What is the syntax error you are getting?
jello32
ASKER
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '='accountID'' at line 1
That doesn't make a sense, because you can use integers with varchars but not vice versa.
In SQL syntax, you don't need quotes around integers, but need them around strings.
Still doesn't make sense, because error you got is like your column name is missing from the query.