Image not being inserted into mysql database from php -


i trying insert image mysql database php. using following code so.

$file=  file_get_contents($_files['file']['tmp_name']); $id=$_session['id']; $sql="update  mainadmin set photo='$file' id='$id'"; mysql_query($sql); $_session['photo']=$file; 

but image not being inserted mysql database. being stored in session variable , shown properly. when going image database saw previous image still stored , no update taken place in database. can me find mistake

i found solution problem. here updated code. using addslashes() method solved problem

    $file=  file_get_contents($_files['file']['tmp_name']);     $filei=addslashes($file) ;     $id=$_session['id'];     $sql="update  mainadmin set photo='$filei' id='$id'";     mysql_query($sql);     $_session['photo']=$file; 

Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -