mrMarcus Posted November 24, 2009 Share Posted November 24, 2009 does not populate the database with the image name? or any values at all? what i see right off the bat is that $header isn't being set with the right value. change: $header = $_POST['header']; to: $header = $_FILES['header']['name']; Quote Link to comment https://forums.phpfreaks.com/topic/182734-getting-error-on-submit/page/2/#findComment-964784 Share on other sites More sharing options...
sandbudd Posted November 24, 2009 Author Share Posted November 24, 2009 mrMarcus I changed that at what it should do is populate the database with the image name but now it is uploading the file to the proper folder and in the database it is populating the word "Array" Quote Link to comment https://forums.phpfreaks.com/topic/182734-getting-error-on-submit/page/2/#findComment-964838 Share on other sites More sharing options...
sandbudd Posted November 24, 2009 Author Share Posted November 24, 2009 getting a lot closer... Quote Link to comment https://forums.phpfreaks.com/topic/182734-getting-error-on-submit/page/2/#findComment-964856 Share on other sites More sharing options...
sandbudd Posted November 24, 2009 Author Share Posted November 24, 2009 mrMarcus or anyone around that can help out? Quote Link to comment https://forums.phpfreaks.com/topic/182734-getting-error-on-submit/page/2/#findComment-965015 Share on other sites More sharing options...
mikesta707 Posted November 24, 2009 Share Posted November 24, 2009 that means that you are passing in an array rather than the value at a certain point in the array. it did that for the value of $header? can I see how you define $header in the updated code? Quote Link to comment https://forums.phpfreaks.com/topic/182734-getting-error-on-submit/page/2/#findComment-965016 Share on other sites More sharing options...
sandbudd Posted November 25, 2009 Author Share Posted November 25, 2009 sure here is the entire code.... <?php error_reporting(E_ALL); ini_set('display_errors', '1'); ?> <?php // Connect database. $host=""; // Host name. $db_user=""; // MySQL username. $db_password=""; // MySQL password. $database=""; // Database name. mysql_connect($host,$db_user,$db_password); mysql_select_db($database); // ***** This part will process when you Click on "Submit" button ***** // Check, if you clicked "Submit" button if (isset ($_POST['Submit'])) { if (!empty ($_FILES['header'])) { if (is_uploaded_file ($_FILES['header']['tmp_name'])) { //This is the directory where images will be saved $target = 'images/'.$_FILES['header']['name']; //This gets all the other information from the form $header = $_FILES['header']['name']; //Writes the photo to the server move_uploaded_file ($_FILES['header']['tmp_name'], $target) or die ('File not moved.'); } else die ('File not uploaded.'); } $_POST = array_map ('mysql_real_escape_string', $_POST); $id = $_POST['id']; $header = $_FILES['header']; $header2 = $_POST['header2']; $header3 = $_POST['header3']; $footer = $_POST['footer']; $footer2 = $_POST['footer2']; $footer3 = $_POST['footer3']; // Do update statement. $sql = mysql_query(" update `ads` set `header`='{$header}', `header2`='{$header2}', `header3`='{$header3}', `footer`='{$footer}', `footer2`='{$footer2}', `footer3`='{$footer3}' where `id`='{$id}' ") or trigger_error (mysql_error()); if ($sql) { header("location:display.php"); exit (0); } } else { // ************* End update part ************* // *** Select data to show on text fields in form. *** // Get id parameter (GET method) $id = ((isset ($_GET['id']) && (ctype_digit ($_GET['id']))) ? mysql_real_escape_string ($_GET['id']) : ''); if (!empty ($id)) { // Get records in all columns from table where column id equal in $id and put it in $result. $result = mysql_query(" select * from ads where id='".$id."' "); // Split records in $result by table rows and put them in $row. $row = mysql_fetch_array ($result); // Close database connection. mysql_close(); } ?> <!-- END OF PHP CODES AND START HTML TAGS --> <html> <script type="text/javascript"> <!-- function MM_goToURL() { //v3.0 var i, args=MM_goToURL.arguments; document.MM_returnValue = false; for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'"); } //--> </script> <body> <!-- set this form to POST method and target this form to itself ($PHP_SELF;)--> <form id="form1" name="form1" method="post" action="" enctype="multipart/form-data"> <input type="hidden" name="id" value="<?php echo $id; ?>" /> <input name="header" type="file" id="header" value="<?php echo $row['header']; ?>" size="50" /> <table width="707" border="1" cellpadding="3" cellspacing="0" class="appfields"> <tr> <td width="25%"><span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14">Header</span></td> <td width="25%"> </td> </tr> <tr> <td><span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14">Header 2<br> </span></td> <td><input name="header2" type="file" id="header2" value="<?php echo $row['header2']; ?>"/></td> </tr> <tr> <td><span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14">Header 3<strong><br> </strong></span></td> <td><strong> <input name="header3" type="text" id="header3" value="<?php echo $row['header3']; ?>"/> </strong></td> </tr> <tr> <td><span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14">Footer<strong><br> </strong></span></td> <td><strong> <input name="footer" type="text" id="footer" value="<?php echo $row['footer']; ?>"/> </strong></td> </tr> <tr> <td><span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14">Footer 2<br> </span></td> <td><strong> <input name="footer2" type="text" id="footer2" value="<?php echo $row['footer2']; ?>"/> </strong></td> </tr> <tr> <td><span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14">Footer 3<br> </span></td> <td><strong> <input name="footer3" type="text" id="footer3" value="<?php echo $row['footer3']; ?>"/> </strong></td> </tr> </table> <br> <br> <table width="707" border="0" cellspacing="0" cellpadding="0"> <tr> <td><input type="submit" name="Submit" value="Submit" /></td> <td><div align="right"> <input name="Cancel" type="submit" id="Cancel" onClick="MM_goToURL('parent','display.php');return document.MM_returnValue" value="Cancel"> </div></td> </tr> </table> </form> </body> </html> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/182734-getting-error-on-submit/page/2/#findComment-965155 Share on other sites More sharing options...
mikesta707 Posted November 25, 2009 Share Posted November 25, 2009 this is your problem $header = $_FILES['header']; $_FILES['header'] is an array. It has the file's information. What part of the files info do you want in header? it should be like $header = $_FILES['header']['name']; if you wanted the files name Quote Link to comment https://forums.phpfreaks.com/topic/182734-getting-error-on-submit/page/2/#findComment-965161 Share on other sites More sharing options...
mrMarcus Posted November 25, 2009 Share Posted November 25, 2009 does not populate the database with the image name? or any values at all? what i see right off the bat is that $header isn't being set with the right value. change: $header = $_POST['header']; to: $header = $_FILES['header']['name']; @sandbudd: gotta pay more attention. i gave you that hours ago. Quote Link to comment https://forums.phpfreaks.com/topic/182734-getting-error-on-submit/page/2/#findComment-965163 Share on other sites More sharing options...
sandbudd Posted November 25, 2009 Author Share Posted November 25, 2009 Thanks all I apologize that worked perfect...one more question I ask...I need all the fields to be image uploads would I simply just repeat everything and change to heade2, header3, footer etc... Quote Link to comment https://forums.phpfreaks.com/topic/182734-getting-error-on-submit/page/2/#findComment-965195 Share on other sites More sharing options...
sandbudd Posted November 25, 2009 Author Share Posted November 25, 2009 does anyone know how I would take all the text fields and turn them into file fields...right now it does upload one file to the server and does display in the db? Quote Link to comment https://forums.phpfreaks.com/topic/182734-getting-error-on-submit/page/2/#findComment-965247 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.