I'm kind of at a loss here. I am trying to set up a website so that all the queries are consolidated in a single document. What i want to be able to do is to just call a variable as the query string.
So I tried:
define("Query_Name", "mySQL_Query", true);
When I go to check my page, I get a lot of errors because variables are missing that are used to help finish the queries. I.e.:
I have a query that will select a row based on a username input by a form. The form only appears on one page, and I only need to use the query when someone wants to login.
So, what is the best way to set up queries that can be re-used over and over, with different variable values? Here's a snippet of what I had that doesn't work:
define("Request_UserPass", "SELECT * FROM `users` WHERE Username = '$username' LIMIT 1", true);
// Front-Page queries
define("Request_Main_Stories", "SELECT * FROM `stories` ORDER BY id DESC LIMIT 5", true);
define("Request_Events_Sidebar", "SELECT * FROM `events` ORDER BY eDate DESC LIMIT 3", true);
define("Request_News_Sidebar", "SELECT * FROM `news` ORDER BY id DESC LIMIT 3", true);
define("Request_Calls_Sidebar", "SELECT * FROM `majorcalls` ORDER BY Date DESC LIMIT 3", true);
// Reading Queries
define("Read_Story", "SELECT * FROM `stories` WHERE id = '".$read_id."' LIMIT 1", true);
define("Read_News", "SELECT * FROM `news` WHERE id = '".$read_id."' LIMIT 1", true);
I only need some to run at certain points. What would be the best way to set this up? Is it possible to actually do what I want, or do I have to write out each query individually when I want to run it?
~Brett