-1

I have the code below as my query (function):

function add_posts($title, $contents, $category_id){
    $posts_title = msql_real_escape_string($title);
    $posts_content = msql_real_escape_string($contents);
    $category_id = (int)$category_id;
    $sql = "INSERT INTO `posts` (`posts_title`, `posts_content`, `category_id`) VALUES        ('$posts_title', '$posts_content', '$category_id')";
    $result = msql_query($sql)or die(mysql_error());}

And the one following next as my html. When I run it, it doesn't INSERT INTO data and doesn't display any errors.

if ( isset($_POST['posts_title'], $_POST['posts_content'], $_POST['category_id'])){
    $title = trim($_POST['posts_title']);
    $contents = trim($_POST['posts_content']);

    add_posts($title, $contents, $_POST['category_id']);
    $Posts_id = mysql_insert_id();
    header('Location:Adminpage.php?posts_id ={$Posts_id}');
    die();
    }
?>
Jason Sturges
  • 15,855
  • 14
  • 59
  • 80
Kelvin
  • 1
  • 2
  • Do you have [error reporting](http://stackoverflow.com/questions/845021/how-to-get-useful-error-messages-in-php) turned on? Unless you have a non-standard library installed, `msql_real_escape_string()` should product an error. – George Cummins Jun 05 '13 at 21:44
  • review your code...what is `msql_`? – Soumik Das Jun 05 '13 at 21:44

1 Answers1

2

You are using msql_* functions, and then expecting mysql_error to work. I'm going to guess that all of those msql_ should be mysql_.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592