$serv = "xxx"; $user = "xxx"; $pass = "xxx"; $db = "xxx"; $imgloc = "../images/bg.jpg"; $image = fopen($imgloc, 'rb'); $imageContent = fread($image, filesize($imgloc)); $conn = new mysqli($serv, $user, $pass, $db); $sql = "INSERT INTO `image`(`advert_id`,`img`) VALUES('1','" . $imageContent . "');"; $conn->query($sql);
I'm using the above code to try to insert binary into my MySQL database but nothing is being sent to the database. The $imageContent just appears in the database as null but if I echo $imageContent it seems to show binary data.
advert_id is just a int field and img is a BLOB