mysql - php mysqli binding parameters -
i'm assuming php inserting single quotes around $id when binding parameters causing query fail. know $id issue because when manually put string in place of first ? query works. problem need query work using variable $id, suggestions on how can achieve this?
if ($stmt = $mysqli->prepare("select count(1) friendships ? = (select id users username = ?) , friendstatus = ?")) { $stmt->bind_param("sss", $id, $username,$friendstatus); $stmt->execute(); $stmt->bind_result($result); $stmt->fetch(); $stmt->close(); }
variable column names not possible prepared statements. in general variable column names not needed made queries. consider using join instead.
Comments
Post a Comment