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 Quote 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? Quote 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? Quote 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 Quote 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... Quote Link to comment https://forums.phpfreaks.com/topic/171343-help-with-simple-insert/#findComment-903621 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.