contra10 Posted March 27, 2009 Share Posted March 27, 2009 i'm having trouble updating an image in my db. my code is as follows <?php include('settings.php'); // Make sure the user actually // selected and uploaded a file if(isset($_COOKIE['ID_my_site'])) { $usernamecookie = $_COOKIE['ID_my_site']; } if(is_numeric($_GET['user'])){ $id = $_GET['user']; } $name = mysql_real_escape_string($_POST['usernamecookie']); $idpic = mysql_real_escape_string($_POST['iduser']); if (isset($_POST['submit']) && ($_FILES['image']) && $_FILES['image']['size'] > 0) { // Temporary file name stored on the server $tmpName = $_FILES['image']['tmp_name']; $fileType = $_FILES['image']['type']; // Read the file $fp = fopen($tmpName, 'r'); $data = fread($fp, filesize($tmpName)); $data = addslashes($data); fclose($fp); // Create the query and insert // into our database. $query = "UPDATE `tbl_images` SET `image` = '" . $data . "', `filetype` = '" . $fileType . "' WHERE `userid` = '" . $idpic . "'"; $results = mysql_query($query) or die(mysql_error()); // Print results print "Thank you, your file has been uploaded."; }else{ echo "no photo uploaded"; } // Close our MySQL Link mysql_close($link); ?> <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="changer"> <input name="MAX_FILE_SIZE" value="512000000000" type="hidden"> <input name="image" accept="image/jpeg" type="file"> <tr><td><?php echo "<input type='hidden' name='usernamecookie' value='$usernamecookie'>"?></tr></td> <tr><td><?php echo "<input type='hidden' name='iduser' value='$id'>"?></td> <input value="Submit" type="submit" name="submit"> Quote Link to comment Share on other sites More sharing options...
Maq Posted March 27, 2009 Share Posted March 27, 2009 Do you get any output, errors, or does it just not update? Quote Link to comment Share on other sites More sharing options...
contra10 Posted March 27, 2009 Author Share Posted March 27, 2009 i don't know what i did but its working now...and thing is the page has to be refreshed on profile. i guess because its coming from the db Quote Link to comment Share on other sites More sharing options...
Maq Posted March 27, 2009 Share Posted March 27, 2009 i don't know what i did but its working now.. It was me, I just have that special luck. Quote Link to comment Share on other sites More sharing options...
contra10 Posted April 1, 2009 Author Share Posted April 1, 2009 lol Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.