So I recently updated my PHP to 7 and now my blog stopped working, I know it has to do with the outdated code, but I can't really figure out a way to update it, any suggestions?
This is my code
<?php
function add_post(){
$title = mysql_real_escape_string($title);
$contents = mysql_real_escape_string($contents);
mysql_query("INSERT INTO `posts` SET
`title` = '{$title}',
`contents` = '{$contents}',
`date_posted`= NOW()");
}
function edit_post($id,$title,$contents)
{
$id = (int)$id;
$title = mysql_real_escape_string($title);
$contents = mysql_real_escape_string($contents);
}
function delete($table, $id){
$table = mysql_real_escape_string($table);
$id = (int)$id;
mysql_query("DELETE FROM `{$table}` WHERE `id`= {$id} ");
}
function get_posts($id = null, $cat_id = null){
$posts = array();
$query = "SELECT
`posts`.`id` AS `post_id` ,
`title`,`contents`,`date_posted`.`name`
FROM `posts`
INNER JOIN `categories` ON `categories`.`id` = `posts`.`cat_id` " ;
if(isset($id)){
$id = (int)$id;
$query .= " WHERE `posts`.`id` = {$id} ";
}
if(isset($cat_id)){
$cat_id = (int)$cat_id;
$query .= " WHERE `cat_id` = {$cat_id} ";
}
$query .= "ORDER BY `post_id` DESC";
return $posts;
}
Thanks for your time.