How to make sure there is no error in this line?

$result = mysql_query ("INSERT INTO article (title,full,short,time,cat) VALUES ('$title','$full','$short','$time','$rescat["id"]')"); 

Error itself

Parse error: syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in ...

Most likely, he swears at $rescat["id"] , but how to make sure that he does not swear at her? Like and in single quotes prescribed ...

    4 answers 4

     $result = mysql_query ("INSERT INTO article (title,full,short,time,cat) VALUES ('$title','$full','$short','$time','{$rescat['id']}')"); 

      You can do that.

        $result = mysql_query ("INSERT INTO article (title,full,short,time,cat) VALUES ('$title','$full','$short','$time','".$rescat["id"]."')"); 

        or even easier

          $result = mysql_query ("INSERT INTO article (title,full,short,time,cat) VALUES ('$title','$full','$short','$time','$rescat[id]')"); 

        You can skip quotes in arrays in arrays; this will not be an error and will read as it should Only if the variable is involved in the address of the array, then they rule your options)

        • one
          get used to writing correctly. - Artem

        Already quite a while I forced myself to always write in the format

         $result = mysql_query ("INSERT INTO article (title,full,short,time,cat) VALUES ('".$title."','".$full."','".$short."','".$time."','".$rescat['id']."')"); 

        I advise you too.