lordphate Posted July 2, 2006 Share Posted July 2, 2006 Okay so i'm trying to set up categories on a "download" page of mine and when the file is uploaded the category selected only comes up as the first letter of the value...any suggestions here's the code :| [code]<?php include 'header.php'; include './library/db.php'; include './library/sessions.php'; include './library/valid.php'; include 'sidebar.php';?><div id="main"><html><head><title>LONGLIVEPS.COM</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css"><!--.box { font-family: Arial, Helvetica, sans-serif; font-size: 12px; border: 1px solid #000000;}--></style></head><body><?// you can change this to any directory you want// as long as php can write to it$uploadDir = './storage/upload/';if(isset($_POST['upload'])){ $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $category = $_POST['category']['value']; // get the file extension first $ext = substr(strrchr($fileName, "."), 1); // generate the random file name $randName = md5(rand() * time()); // and now we have the unique file name for the upload file $filePath = $uploadDir . $randName . '.' . $ext; // move the files to the specified directory // if the upload directory is not writable or // something else went wrong $result will be false $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo "Error uploading file"; include 'footer.php'; exit; } if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); $filePath = addslashes($filePath); $category = addslashes($category); } $query = "INSERT INTO upload (name, size, type, path, uploader, category ) ". "VALUES ('$fileName', '$fileSize', '$fileType', '$filePath', '$member','$category')"; mysql_query($query) or die('Error, query failed : ' . mysql_error()); echo "<br>File uploaded<br>";}?><form action="" method="post" enctype="multipart/form-data" name="uploadform"> <table width="350" border="0" cellpadding="1" cellspacing="1" class="box"> <tr> <td width="246"><input type="hidden" name="MAX_FILE_SIZE" value="4000000000"><input name="userfile" type="file" class="box" id="userfile"> </td> <td width="350" border="0" cellpadding="1" cellspacing="1"> <select name="category" size="5"><option value="movie">Movie</option><option value="hacks">Hacking</option><option value="audio">Music</option><option value="apps">Applications</option><option value="windows">\/\/ ! /\/ |) () \/\/ S</option><option value="papers">White Pepers</option><option value="inone">All in Ones</option></select></td> <td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td> </tr> </table></form></body></html></div> <? include 'footer.php'; ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13431-data-entered-in-mysql-only-one-letter/ Share on other sites More sharing options...
Drumminxx Posted July 2, 2006 Share Posted July 2, 2006 try changing$category = $_POST['category']['value'];to$category = $_POST['category']; Quote Link to comment https://forums.phpfreaks.com/topic/13431-data-entered-in-mysql-only-one-letter/#findComment-51869 Share on other sites More sharing options...
lordphate Posted July 2, 2006 Author Share Posted July 2, 2006 that did the trick...gosh i'm stupid :| here's another question though, how would i create a drop-down menu that has the categories listed and if the user clicks on one it would automatically change to show only that category? Quote Link to comment https://forums.phpfreaks.com/topic/13431-data-entered-in-mysql-only-one-letter/#findComment-51872 Share on other sites More sharing options...
Drumminxx Posted July 2, 2006 Share Posted July 2, 2006 maybe I'm not following you on this one but it should change to show the selected category already.does it reset itself or something? Quote Link to comment https://forums.phpfreaks.com/topic/13431-data-entered-in-mysql-only-one-letter/#findComment-51874 Share on other sites More sharing options...
lordphate Posted July 2, 2006 Author Share Posted July 2, 2006 That code was actually for the upload section sorry...thinking ahead...now i can't figure out how to SHOW the categories... Quote Link to comment https://forums.phpfreaks.com/topic/13431-data-entered-in-mysql-only-one-letter/#findComment-51877 Share on other sites More sharing options...
.josh Posted July 2, 2006 Share Posted July 2, 2006 [quote author=lordphate link=topic=99159.msg390362#msg390362 date=1151818101]that did the trick...gosh i'm stupid :| here's another question though, how would i create a drop-down menu that has the categories listed and if the user clicks on one it would automatically change to show only that category?[/quote]you would need to use ajax for that. php is server side. javascript is client side. ajax is js method that will post the info to a target php script that you can have run a query based on the selection and return the results, and then have js update the selections, without having to reload the whole page. Quote Link to comment https://forums.phpfreaks.com/topic/13431-data-entered-in-mysql-only-one-letter/#findComment-51888 Share on other sites More sharing options...
lordphate Posted July 2, 2006 Author Share Posted July 2, 2006 I'm betting that would be pretty hard then eh? It sounds hard :| Quote Link to comment https://forums.phpfreaks.com/topic/13431-data-entered-in-mysql-only-one-letter/#findComment-51969 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.