<?
// Connection Array
$mysql = array(
'dbserver' => "localhost",
'database' => "",
'username' => "",
'password' => "");
// Connect To Database
$con = mysql_connect($mysql['database'], $mysql['username'], $mysql['password']) or die(mysql_error());
mysql_query("SET CHARACTER SET utf8");
// Sanitize Input
function anti_inject($input) {
$input = preg_replace("/[^a-zA-Z0-9]/", "", $input);
return $input;
}
// Execute Code
$action = anti_inject($_POST['action']);
switch ($action) {
case 1:
$query = "SELECT * FROM series";
break;
case 2:
$query = "SELECT * FROM something";
break;
}
$sth = mysql_query($query);
if (mysql_errno()) {
header("HTTP/1.1 500 Internal Server Error");
echo $query.'\n';
echo mysql_error();
} else {
$rows = array();
while($r = mysql_fetch_assoc($sth)) {
$rows[] = $r;
}
print json_encode($rows);
}
?>