...

View Full Version : Why is it saving only 5 characters?



Sing
02-28-2010, 10:48 PM
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?


<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.');
}
}
?>

bdl
02-28-2010, 11:10 PM
What type / length of field is `rares`.`value`? Also, I strongly recommend you change the field name.

masterofollies
03-01-2010, 12:14 AM
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.

Sing
03-01-2010, 05:00 AM
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.

Inigoesdr
03-01-2010, 05:31 AM
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.).

Sing
03-01-2010, 11:46 PM
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

masterofollies
03-02-2010, 12:28 AM
Yeah it has to do with the database.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum