Using PHP variables inside SQL statements?
- by Homer
For some reason I can't pass a var inside a mysql statement. I have a function that can be used for multiple tables. So instead of repeating the code I want to change the table that is selected from like so,
function show_all_records($table_name) {
mysql_query("SELECT * FROM $table_name");
etc, etc...
}
And to call the function I use
show_all_records("some_table")
or
show_all_records("some_other_table")
depending on which table I want to select from at the moment. But it's not working, is this because variables can't be passed through mysql statements?