Jump to content

Data Entered in MYSQL only one letter?


lordphate

Recommended Posts

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]
Link to comment
Share on other sites

[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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.