I have a challenge getting a query i saved into the database. On my project, i want to save mysql update query in the database, and when another action is run on a different page, i get that query and pass it through my function and it runs. However after getting it its empty. Below is what i have done so far.
//Saving the query in database
$query = array();
$query['approved'] = "UPDATE payment SET pm_status = 'Approved' WHERE id = '69'";
$query['approved2'] = "UPDATE member SET pay_date = NOW())";
//i den serialize and addslashes so it can be saved in the database
$tosave = addslashes(serialize($query));
$sql = "INSERT INTO trans (saved_query) VALUES ($tosave)";
// I den save $tosave into the database, which i checked and it was saved. On the page i want to use it, each time i get the value and unserialize, it returns as empty e.g after selecting the value to a row
$toprocess = unserialize($query['saved_query']);
echo $toprocess['approved'];
it returns an empty value, and when i run it in a query it doesn't run.
but if i echo directly without unserializing, it dispplays the values in it
echo $query['saved_query'];
Pls help incase i am missing something here. Thanks
I am not preventing an sql injection. I had dont that already. I just want to run the sql saved into the database. This is different to the answers in the prevention of mysql injection. Thanks