Julian Posted August 20, 2009 Share Posted August 20, 2009 Hi guys... Have this code: <?php error_reporting(0); define ( 'FILE_UPLOAD_DIR', '/path_to/documentos/' ); $fileObject = $_FILES ['Filedata']; $fileSize = ( double ) $fileObject ['size']; $fileName = $fileObject ['name']; $fileType = strtolower ( pathinfo ( $fileName, PATHINFO_EXTENSION ) ); $fileTempPath = $fileObject ['tmp_name']; $fileUploadPath = rtrim ( FILE_UPLOAD_DIR, '/' ) . '/' . basename ( $fileName ); if (move_uploaded_file ( $fileTempPath, $fileUploadPath )) { echo "OK"; } else { die ( "Ocurrió un error al intentar cargar el archivo" ); } ?> It works with a flash uploader that waits until the "OK" to finish. After it finishes I need to continue with mysql inserts. The code works, but it doesn't finish because the other part of the code is executing. How can I make the other part of the code wait until the first part finishes? Here's the other part of the code: if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE noticias SET tipo=%s, titulo=%s, id_miembro=%s, dia=%s, mes=%s, ano=%s, status=%s, bajada=%s, principal=%s, secundario=%s, comentarios=%s, pie1=%s, pie2=%s, pie3=%s, video1=%s, pie4=%s, video2=%s, pie5=%s, audio1=%s, pie6=%s, audio2=%s, pie7=%s, documento=%s, tags=%s, title_eng=%s, keywords=%s, description=%s, belice=%s, costarica=%s, elsalvador=%s, guatemala=%s, honduras=%s, nicaragua=%s, panama=%s WHERE id_noticia=%s", GetSQLValueString($_POST['tipo'], "int"), GetSQLValueString($_POST['titulo'], "text"), GetSQLValueString($_POST['id_miembro'], "int"), GetSQLValueString($_POST['dia'], "int"), GetSQLValueString($_POST['mes'], "text"), GetSQLValueString($_POST['ano'], "int"), GetSQLValueString(isset($_POST['status']) ? "true" : "", "defined","1","0"), GetSQLValueString($_POST['bajada'], "text"), GetSQLValueString($_POST['principal'], "text"), GetSQLValueString($_POST['secundario'], "text"), GetSQLValueString(isset($_POST['comentarios']) ? "true" : "", "defined","1","0"), GetSQLValueString($_POST['pie1'], "text"), GetSQLValueString($_POST['pie2'], "text"), GetSQLValueString($_POST['pie3'], "text"), GetSQLValueString($file_new_name1, "text"), GetSQLValueString($_POST['pie4'], "text"), GetSQLValueString($file_new_name2, "text"), GetSQLValueString($_POST['pie5'], "text"), GetSQLValueString($file_new_name3, "text"), GetSQLValueString($_POST['pie6'], "text"), GetSQLValueString($file_new_name4, "text"), GetSQLValueString($_POST['pie7'], "text"), GetSQLValueString($file_new_name5, "text"), GetSQLValueString($_POST['tags'], "text"), GetSQLValueString($_POST['title_eng'], "text"), GetSQLValueString($_POST['keywords'], "text"), GetSQLValueString($_POST['description'], "text"), GetSQLValueString(isset($_POST['belice']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['costarica']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['elsalvador']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['guatemala']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['honduras']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['nicaragua']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['panama']) ? "true" : "", "defined","1","0"), GetSQLValueString($_POST['id_noticia'], "int")); mysql_select_db($database_rcpc, $rcpc); $Result1 = mysql_query($updateSQL, $rcpc) or die(mysql_error()); $updateGoTo = "list.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } Quote Link to comment https://forums.phpfreaks.com/topic/171204-solved-how-to-wait-for-code-to-execute-completely-then-proceed/ 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.