1

Really simple question which I can't figure out. Code to update table :

$loc = $_POST['sql_id'];
$link = $_POST['link'];
$sql_c = $_POST['name_c'];
$val = $_POST['val'];
$query = "UPDATE $link SET $sql_c='$val' WHERE id='$loc' ";

if ($conn->query($query) === TRUE) {
echo "Success!";
} else {
    echo "Error: " . $conn->error;
}

It returns Success!, but there are no changes in the table. What am I missing here?

Console log from JS side

 (
    [id] => 2
    [link] => Test123
    [name_c] => i1
    [val] => Texx
)

Table name is Test123 with columns id,paid,i1,i2,i3,i4,i5

WKoppel
  • 504
  • 3
  • 15

2 Answers2

1

It should be $_POST['id']; not $_POST['sql_id']; according to your code.

Vincent G
  • 8,547
  • 1
  • 18
  • 36
0

The $conn->query() method returns an object if success or FALSE if an error occurred. Could you paste the result of your $conn->query() call?

So if your query is $result_l = $conn->query("UPDATE event SET length='$i_c' WHERE id='$id' "); just do a var_dump($result_l); and post it here.

codedge
  • 4,754
  • 2
  • 22
  • 38