I don't actually need that particular variable in my final code--it is just there to illustrate the problem (in fact, that is not a real variable in my code; like I said, I changed the names to protect my job 😉 )--but basically, what I want to do is grab a database-generated identification number that corresponds to a store's (not really a store in my code, but for the purpose of figuring out the problem...) name then use that to grab some information from other tables all in one transaction so I don't have to go back and forth between PHP and SQL Server.
Let's imagine that I have a table named "Stores" that looks something like this:
Name | ID
We Be Toys | 1
Kitchen Junk | 2
The Bike Guy | 3
Cookie House | 4
"ID" is automatically generated for each new entry. The first thing I am doing is putting the ID into an SQL variable then using that to get information from other tables.
The problem does not seem to be the SQL code, though. Everything works fine in Query Analyzer, but when I try to connect to SQL Server via PHP's ODBC functions, I get no results if I am using a SET statement. Other queries (SELECT * FROM Some_Table, etc.) work as expected as long as they do not contain SET statements.
odbc_prepare did not seem to work for me, so I am back to where I started. Is there something I need to escape in there? Backslashes are just passed on to the database engine, so if so, there must be something else I have to do. 😛