Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Oct 2009
    Posts
    61
    Thanks
    2
    Thanked 1 Time in 1 Post

    Why is it saving only 5 characters?

    Hello! I have a script for adding content to my site, but I cannot seen to get the "value" field to save more than 5 characters. What is restricting it?

    PHP Code:
                        <h2>Add Code</h2><br>
                        
                        <?php 
                        $date 
    date("jS M Y");
                        if (!
    $_POST[addrare]){
                        
    ?>
                        
                        <form method="post">
                        <div class="greyBox"><strong>Item Name:</strong> <input name="name" type="text"></div>
                        <div class="greyBox"><strong>Code:</strong> <input name="value" type="text"></div>
                        <div class="greyBox"><strong>Image Name:</strong> <input name="image" type="text"> e.g. http://i47.tinypic.com/blanky.jpg (keep the images 50px by 50px)</div>
                        <div class="greyBox"><strong>Category:</strong> <select name="category">
                        <?php 
                        $getcat 
    mysql_query("SELECT * FROM `categories` ORDER BY `displayorder`");
                        while (
    $cat mysql_fetch_array($getcat)){
                        echo (
    "<option value=\"$cat[id]\">$cat[name]</option>
                        "
    );}
                        
    ?>
                        </select>
                        </div>
                        <input type="submit" name="addrare" value="Add Code">
                        
                        <?php 
                        
    }else{
                        
    $name htmlspecialchars(addslashes($_POST[name])); 
                        
    $value htmlspecialchars(addslashes($_POST[value]));
                        
    $image htmlspecialchars(addslashes($_POST[image]));
                        
    $catid htmlspecialchars(addslashes($_POST[category]));
                        if(
    $name==NULL || $value==NULL || $image==NULL || $catid==NULL) {
                        echo(
    "<strong>You left some fields blank</strong><br>You will be redirected back to the add code page.
                        <meta http-equiv=\"Refresh\" content=\"3; URL=index.php?p=add_rare\">"
    );
                        }else{
                        echo(
    "<strong>$name was successfully added</strong><br>You will be redirected back to the add code page.
                        <meta http-equiv=\"Refresh\" content=\"3; URL=index.php?p=add_rare\">"
    );
                        
    $insertRare "INSERT INTO `rares` ( `name` , `value` , `image` , `catid` , `lastedited` ) VALUES ('".$name."', '".$value."', '".$image."', '".$catid."', '".$date."')";
                        
    mysql_query($insertRare) or die("MySQL Error.");
                        
    $date date("d/m/y - h:ia");
                        
    $insertLog "INSERT INTO `logs` ( `log` , `date` ) VALUES ('<strong>$logged[username]</strong> added code <strong>$name</strong>', '$date')";
                        
    mysql_query($insertLog) or die('MySQL Error.');
                        }
                        }
                        
    ?>

  • #2
    bdl
    bdl is offline
    Regular Coder
    Join Date
    Apr 2007
    Location
    Camarillo, CA US
    Posts
    590
    Thanks
    4
    Thanked 83 Times in 82 Posts
    What type / length of field is `rares`.`value`? Also, I strongly recommend you change the field name.

  • #3
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    In your database, you are limiting it. If you have varchar(5) it will give you 5. Change to 20 and you will get 20. If you want to put a whole lot in it, change it to TEXT.
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?

  • #4
    New Coder
    Join Date
    Oct 2009
    Posts
    61
    Thanks
    2
    Thanked 1 Time in 1 Post
    Quote Originally Posted by masterofollies View Post
    In your database, you are limiting it. If you have varchar(5) it will give you 5. Change to 20 and you will get 20. If you want to put a whole lot in it, change it to TEXT.
    I can't find that in any of my files. Other fields are saving more than 5, only that one won't save more than 5.

  • #5
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Quote Originally Posted by Sing View Post
    I can't find that in any of my files.
    It wouldn't be in a file. It would be in your database structure, which you would need a DB client to view(phpMyAdmin, HeidiSQL, MySQL Administrator, etc.).

  • Users who have thanked Inigoesdr for this post:

    Sing (03-02-2010)

  • #6
    New Coder
    Join Date
    Oct 2009
    Posts
    61
    Thanks
    2
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Inigoesdr View Post
    It wouldn't be in a file. It would be in your database structure, which you would need a DB client to view(phpMyAdmin, HeidiSQL, MySQL Administrator, etc.).
    Thankyou for this! I have successfully located the area in my MySQL

  • #7
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    Yeah it has to do with the database.
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •