karatekid36 Posted May 17, 2007 Share Posted May 17, 2007 Hello Everyone! I am having trouble putting the pledge_class variable into my ap_uploads table. I am not sure why. Any assistance on this matter would be greatly appreciated. <?php session_name ('YourVisitID'); session_start(); // Start the session. // If no session value is present, redirect the user. if (!isset($_SESSION['user_id'])) { // Start defining the URL. $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); // Check for a trailing slash. if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) { $url = substr ($url, 0, -1); // Chop off the slash. } $url .= '/index.php'; // Add the page. header("Location: $url"); exit(); // Quit the script. } $page_title = 'Upload Awards or Paddles'; include('./includes/header.html'); $counter = 1; if(isset($_POST['submitted'])) { require_once('./includes/mysql_connect.php'); for($i = 0; $i < $counter; $i++) { $filename = 'upload' . $i; $description = 'description' . $i; if(isset($_FILES[$filename]) && ($_FILES[$filename]['error'] !=4)) { if(!empty($_POST[$description])) { $d = "'" . escape_data($_POST[$description]) . "'"; } else { $d = 'NULL'; } $query = "INSERT INTO ap_uploads (pledge_class, file_name, file_size, file_type, description) VALUES (pledge_class, '{$_FILES[$filename]['name']}', '{$_FILES[$filename]['size']}', '{$_FILES[$filename]['type']}', $d)"; $result = mysql_query ($query); if($result) { $upload_id = mysql_insert_id(); if(move_uploaded_file($_FILES[$filename]['tmp_name'], "awards_paddles_img/$upload_id")) { echo '<p>File number ' . ($i + 1) . ' has been uploaded!</p>'; } else { echo '<p><font color="red">File number ' . ($i +1) . 'could not be moved.</font></p>'; $query = "DELETE FROM ap_uploads WHERE upload_id = $upload_id"; $result = mysql_query($query); } } else { echo '<p><font color="red"> Your submission could not be processed due to a system error.</font></p>'; } } } mysql_close(); } ?> <form enctype="multipart/form-data" action="upload_ap_images.php" method="post"> <fieldset><legend>Fill out the form to upload the image:</legend> <input type="hidden" name="MAX_FILE_SIZE" value="524288" /> <br /> <p><b>Please Make Sure That There Are No Spaces In The File Name.</b></p> <p>For Example, the filename picture 1.jpeg is not correct. The filename picture1.jpeg or picture_1.jpeg is correct.</p> <br /> <?php for ($i = 0; $i < $counter; $i++) { ?><p>Pledge Class:<?php // Make the pledge class array. $pledgeclass = array (1 => 'FF', 'Alpha', 'Beta', 'Gamma', 'Delta', 'Epsilon', 'Zeta', 'Eta', 'Theta', 'Iota', 'Kappa', 'Lambda', 'Mu', 'Nu', 'Xi', 'Omicron', 'Pi', 'Rho', 'Sigma', 'Tau', 'Upsilon', 'Phi', 'Chi', 'Psi', 'Omega'); // Make the pledge class pull-down menu. echo '<select name="pledge_class">'; echo "<option value=\"\">Select Pledge Class</option>\n"; foreach ($pledgeclass as $key => $value) { echo "<option value=\"$value\">$value</option>\n"; } echo '</select>'; ?></p><?php echo ' <p><b>File:</b> <input type="file" name="upload' . $i . '" /></p> <p><b>Description:</b><br /> <textarea name="description' . $i . '" cols="40" rows="5"></textarea></p><br /> '; } ?> </fieldset> <input type="hidden" name="submitted" value="TRUE" /> <div align="center"><input type="submit" name="submit" value="Upload Images" /></div> </form> <?php include ('./includes/footer.html'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/51845-having-issues-entering-a-value-into-a-table/ Share on other sites More sharing options...
MadTechie Posted May 17, 2007 Share Posted May 17, 2007 the problem being ? trouble.. means what exactly it not displaying in a fuzzy green text.. what do you mean by trouble! Quote Link to comment https://forums.phpfreaks.com/topic/51845-having-issues-entering-a-value-into-a-table/#findComment-255498 Share on other sites More sharing options...
karatekid36 Posted May 17, 2007 Author Share Posted May 17, 2007 the pledge_class variable that is being selected from the pull down menu is not being inserted into the table when I submit the form with the current SQL query. Quote Link to comment https://forums.phpfreaks.com/topic/51845-having-issues-entering-a-value-into-a-table/#findComment-255499 Share on other sites More sharing options...
MadTechie Posted May 17, 2007 Share Posted May 17, 2007 error ? what happends when you echo $query; Quote Link to comment https://forums.phpfreaks.com/topic/51845-having-issues-entering-a-value-into-a-table/#findComment-255509 Share on other sites More sharing options...
karatekid36 Posted May 17, 2007 Author Share Posted May 17, 2007 to be honest, I think the problem i due to the fact that the pledge_class variable is not being properly defined so that it can be entered into the table with this query. I need help with that. Everything else works 100% perfectly, but this pull down menu value is not being inserted into the table. Quote Link to comment https://forums.phpfreaks.com/topic/51845-having-issues-entering-a-value-into-a-table/#findComment-255514 Share on other sites More sharing options...
MadTechie Posted May 17, 2007 Share Posted May 17, 2007 add some error handlering $result = mysql_query ($query) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/51845-having-issues-entering-a-value-into-a-table/#findComment-255515 Share on other sites More sharing options...
MadTechie Posted May 17, 2007 Share Posted May 17, 2007 OK.. lets play guess the error.. EDIT: Good luck break rules means i fail to help No TRIPLE POSTS Quote Link to comment https://forums.phpfreaks.com/topic/51845-having-issues-entering-a-value-into-a-table/#findComment-255518 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.