I didn’t want to keep repeating the same select query, so I wrote this function. But it doesn’t work:
function select($what, $table) {
$query = mysql_query("SELECT $what FROM $table");
}
select(*, products);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
function select($what, $table) { $what = mysql_real_escape_string($what); $table = mysql_real_escape_string($table); return mysql_query("SELECT '$what' FROM `$table`;"); } $query = select('*', 'products');For debugging:
function select($what, $table) { $what = mysql_real_escape_string($what); $table = mysql_real_escape_string($table); $query = mysql_query("SELECT '$what' FROM `$table`;") or die(mysql_error()); return $query; } $query = select('*', 'products');