Mert Mesut Demir
Mert Mesut Demir

Reputation: 1

MySQL save error without error

<?php
include("pass.php"); 
session_start();

if(isset($_SESSION["login"])) {
    require_once ('connect.php');

    $not = $_POST["not"];

    if($not=="") {
        header("location:mybbeklents/admin/dashboard.php?cmd=1");
    } else {
        mysql_query("INSERT INTO notlar (not,) VALUES ('$not')");
        header("location:mybbeklents/admin/dashboard.php?cmd=2");
    }
}
?>

This code doesn't work. They don't get saved into MySQL.

Upvotes: 0

Views: 61

Answers (3)

herrjeh42
herrjeh42

Reputation: 2793

Change

$not = mysql_real_escape_string($_POST["not"]);

and

mysql_query("INSERT INTO notlar (not) VALUES ('$not')");

If this works, take your time and read a bit on sql injection and the outdated mysql extension. It is really easy to drop your database the way your code looks right now. You can solve both issues in your code using PDO. you'll find more information on PDO here: http://www.phptherightway.com/#security

Upvotes: 0

dialogik
dialogik

Reputation: 9552

Try

mysql_query("INSERT INTO notlar (`not`) VALUES ('$not')")
OR die('MySQL error: '.mysql-error());

That echoes the error, if any occurs.

Note: Your query in insecure. Use mysqli or PHP PDO or at least unescape your variables before passing them to the query.

Upvotes: 1

Jasmin Mistry
Jasmin Mistry

Reputation: 1476

query should be

mysql_query("INSERT INTO notlar (`not`) VALUES ('$not')");

Upvotes: 1

Related Questions