php - Syntax error, unexpected '' -


i keep getting error whenever try run webpage. i'm not sure causing this; i've tried moving around ' , " bunch of times still getting same error... here line of code says keeps causing it:

$result = sqlsrv_query( $conn, "select *                                  operator                                  username = $_post['login']"                       ); 

also here full error fun:

  parse error: syntax error, unexpected '' (t_encapsed_and_whitespace),                   expecting identifier (t_string)                   or variable (t_variable) or number (t_num_string) 

you using arr['index'] inside query either need concatenate query string else use {} around arr['index']

also need quotes around username='{$_post['login']}'

warning: using $_post[] directly in query without sanitizing or escaping quotes, learn pdo don't have worry these things anymore


Comments