0

Been working on a small project for myself and have gotten lost in this part

if(empty($_REQUEST['ID'])) {
    echo "tuks";
} else {
    $id = $_REQUEST["ID"];
    $sql = "DELETE FROM list WHERE ID = $id";
}

Upon form submit, I'm getting the following error:

Notice: Array to string conversion

Searched a couple of threads with no luck.

chris85
  • 23,846
  • 7
  • 34
  • 51
AlexA
  • 13
  • 2
  • Apparently `$_REQUEST['ID']` is an array, despite your expectation that it's a string. It's not obvious from this code how that happened, though. – Don't Panic Oct 25 '17 at 20:22
  • run `var_dump($_REQUEST["ID"]);` –  Oct 25 '17 at 20:23
  • array(1) { [0]=> string(17) – AlexA Oct 25 '17 at 20:28
  • then `$_REQUEST["ID"][0]` is probably the string you want. i dont like using request, as you dont know which of ( $_GET, $_POST and $_COOKIE. ) is the source, better to use $_GET or $_POST or $_COOKIE instead –  Oct 25 '17 at 20:30
  • The error has already occurred in code previous to the code you're showing here. Figure out how you're assigning values to `$_REQUEST['ID']`. Is this input from a form, or something else? – Don't Panic Oct 25 '17 at 20:31

0 Answers0