"', '" . $lname . "')"; So now the ' character ends the string literal before the programmer was expecting it.