Jump to content


Photo

Data Entered in MYSQL only one letter?


  • Please log in to reply
6 replies to this topic

#1 lordphate

lordphate
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts

Posted 02 July 2006 - 05:01 AM

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 :|
<?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'; ?>


#2 Drumminxx

Drumminxx
  • Members
  • PipPipPip
  • Advanced Member
  • 92 posts
  • LocationUSA

Posted 02 July 2006 - 05:09 AM

try changing

$category = $_POST['category']['value'];

to

$category = $_POST['category'];
:: gucci.com ::
:: blockbuster.com ::

--------------------

#3 lordphate

lordphate
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts

Posted 02 July 2006 - 05:28 AM

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?

#4 Drumminxx

Drumminxx
  • Members
  • PipPipPip
  • Advanced Member
  • 92 posts
  • LocationUSA

Posted 02 July 2006 - 05:42 AM

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?


:: gucci.com ::
:: blockbuster.com ::

--------------------

#5 lordphate

lordphate
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts

Posted 02 July 2006 - 05:48 AM

That code was actually for the upload section sorry...thinking ahead...now i can't figure out how to SHOW the categories...


#6 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 02 July 2006 - 06:14 AM

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?

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.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#7 lordphate

lordphate
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts

Posted 02 July 2006 - 12:39 PM

I'm betting that would be pretty hard then eh? It sounds hard :|




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users