php - images upload when "insert" is used, but doesnt when "update" is used -


$image= addslashes($_files['image']['tmp_name']); $name= addslashes($_files['image']['name']);  $image= file_get_contents($image); $image= base64_encode($image); $studentid = 1; $con=mysql_connect("localhost","root","root");  mysql_select_db("secure_login",$con); $qry="insert images (name,image,studentid) values ('$name','$image','$studentid')"; $result=mysql_query($qry,$con); 

here, i've tried insert images mysql. when change insert query update, whole code falls apart , can't fix it.

i know basic syntax:

$qry="update images set name = $name, image = $image, studentid=$studentid"; 

but doesn't work.

you insert new row in table. update existing row. so, whe run update query have specify row updating. can't replace insert update. update code with:

$qry="update images set name = '$name', image = '$image', studentid='$studentid' id='$rowid'"; 

also note in query should wrap values '' sure on how mysql handle them.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -