0
<?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.

2
  • What error message do you get? Commented Sep 14, 2013 at 18:33
  • According to the title: none? Commented Sep 14, 2013 at 18:33

3 Answers 3

1

query should be

mysql_query("INSERT INTO notlar (`not`) VALUES ('$not')");
Sign up to request clarification or add additional context in comments.

1 Comment

please also change $not = mysql_real_escape_string($_POST["not"]); to avoid bad people dropping your database
1

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.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.