johne90 Posted December 5, 2009 Share Posted December 5, 2009 I am trying to get my upload script for fancyupload to insert file names and sizes into my database, but I have only been able to insert the first file in the queue. The data is organized like this: $result = array(); $result['time'] = date('r'); $result['addr'] = substr_replace(gethostbyaddr($_SERVER['REMOTE_ADDR']), '******', 0, 6); $result['agent'] = $_SERVER['HTTP_USER_AGENT']; if (count($_GET)) { $result['get'] = $_GET; } if (count($_POST)) { $result['post'] = $_POST; } if (count($_FILES)) { $result['files'] = $_FILES; } I am trying to insert like this: $insert = "INSERT INTO images VALUES ('$id', '$title', '".$id."_".$title."', '".$_FILES["Filedata"]["name"]."', '".$_FILES['Filedata']['size']."', '', '', '0', '$timeadded')"; $runit = mysql_query($insert) or die("error"); Can someone tell me how to get each file to insert? Link to comment https://forums.phpfreaks.com/topic/184104-problem-with-array-database-insertion/ Share on other sites More sharing options...
calmchess Posted December 5, 2009 Share Posted December 5, 2009 you have to serialize the array first then if you query the array you have to unserialize it to use it ......i think its array_serialize and array_unserialize in the doucmentation Link to comment https://forums.phpfreaks.com/topic/184104-problem-with-array-database-insertion/#findComment-971983 Share on other sites More sharing options...
johne90 Posted December 5, 2009 Author Share Posted December 5, 2009 OK, but Im still not sure what to change to get it to insert each image. Link to comment https://forums.phpfreaks.com/topic/184104-problem-with-array-database-insertion/#findComment-972030 Share on other sites More sharing options...
johne90 Posted December 5, 2009 Author Share Posted December 5, 2009 I don't think that would work because I need to pull individual values like name and size to insert. Serialize just seems to put all the variables in the array together. Link to comment https://forums.phpfreaks.com/topic/184104-problem-with-array-database-insertion/#findComment-972043 Share on other sites More sharing options...
johne90 Posted December 6, 2009 Author Share Posted December 6, 2009 Anyone know a way? Link to comment https://forums.phpfreaks.com/topic/184104-problem-with-array-database-insertion/#findComment-972155 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.