php - Unable to Store Base64 Data in MySql Database -


i trying store base64 string mysql database using php. here code.

<?php //store image $photodata = $_post['photodata'];  //database connection details $db_url = "192.168.1.140"; $db_user_name = "easyblogadmin"; $db_password = "admin"; $db_name = "easyblog";  $con = mysqli_connect($db_url, $db_user_name, $db_password); $sql = "insert temptable (photodata) values('$photodata')";  if(mysqli_connect_errno()){         echo "failed connect database";         echo mysqli_connect_errno();         die();     } else {         //connecting application database         $db_selected = mysqli_select_db($con, $db_name);         if(!$db_selected){             echo "failed connect application database";             die();         } else {             if (!mysqli_query($con,$sql)) {                 die('error: ' . mysqli_error($con));             }             mysqli_close($con);             echo "successfully added photo".strlen($photodata);         }     }?> 

here $photodata base64 encoded string , storing in db. when trying retrieve data db data in string missing. don't understand why happening. can 1 me out.

regards.

chnage sql query below mentioned

$sql = "insert databasename.temptable (photodata) values('$photodata')"; 

also please make sure if encoded value has single quotes,if replace data mentioned below .

$photodata =str_replace("'","\'",$_post['photodata']); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -