Julian Posted August 21, 2009 Share Posted August 21, 2009 Hello! I have this code to upload files, and I want to store the file names into the database, so far I have: $news = ($HTTP_GET_VARS['id_noticia']); foreach ($_FILES as $fieldName => $file) { move_uploaded_file($file['tmp_name'], "../../images/documentos/" . $file['name']); mysql_select_db($database_rcpc, $rcpc); $updateSQL = "INSERT INTO documentos (id_noticia, nombre) VALUES (".$news.",".$file['name'].")"; $update = mysql_query($updateSQL); } Files upload fine. Script to connect to db is fine also, but for some reason is not inserting... any hint? Thanks Link to comment https://forums.phpfreaks.com/topic/171343-help-with-simple-insert/ Share on other sites More sharing options...
Aravinthan Posted August 21, 2009 Share Posted August 21, 2009 Did you try echoin: $news to see if it echos something? Link to comment https://forums.phpfreaks.com/topic/171343-help-with-simple-insert/#findComment-903601 Share on other sites More sharing options...
Aravinthan Posted August 21, 2009 Share Posted August 21, 2009 Also, when you say it is not working... Do you get an error? Or it just doesnt insert the details? Link to comment https://forums.phpfreaks.com/topic/171343-help-with-simple-insert/#findComment-903613 Share on other sites More sharing options...
Julian Posted August 21, 2009 Author Share Posted August 21, 2009 It not inserting the data, and yes I'm obtaining a variable with $news Link to comment https://forums.phpfreaks.com/topic/171343-help-with-simple-insert/#findComment-903614 Share on other sites More sharing options...
Aravinthan Posted August 21, 2009 Share Posted August 21, 2009 OK I got some questions, $news was sent via a form right? If so, Maybe trying sending it via $_Post: $news = $_POST['id_noticia']; And also, Try running this: $updateSQL = "INSERT INTO documentos (id_noticia) VALUES ('Test')"; Just to see... Link to comment https://forums.phpfreaks.com/topic/171343-help-with-simple-insert/#findComment-903621 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.