Missing text

when i insert a value only three letters save in a DB i wonder why.

here is my code.


<?php 
   echo "<td>";
	echo "<select name='subcat'>";
	while($row=mssql_fetch_array($subcat)){
	echo "<option value=$row[SubCat]>$row[SubCat]</option>";
	}echo "</select>";
   echo "</td>";
?>

and this is my insert code.


if(trim($_POST['desc'])<> ""){
header('location:viewticketuser.php');

insert(trim($_POST['cat']),trim($_POST['subcat']),trim($_POST['desc']),trim($_SESSION['username']),trim($image1),trim($image2),trim($image3),trim($_SESSION['email']),trim($_SESSION['Dept']),trim($_POST['stat']),$con); 


}else{
echo'Enter a Description';

}

function insert($cat,$subcat,$message,$uname,$image1,$image2,$image3,$mail,$Dept,$Stat,$con)
{

mssql_query("sp_ticket @cat='$cat',@subcat='$subcat',@desc='$message',@uname='$uname',@img1='$image1',@img2='$image2',@img3='$image3',@email='$mail',@dept='$Dept',@Stat='$Stat'");
		mssql_close($con);
	
}

Is the db column setup correctly? Its not limited to 3 characters for some reason is it?

I don’t see any problems with your code that should cause you to lose letters unless the column you are inserting to has a set length of 3… or if there are 3 letters than a space, have you tried enclosing the value in the form with quotes IE


<option value=\\"$row[SubCat]\\">$row[SubCat]</option>

i can connect correctly…i save other data precisely
i set the data to varchar(50).
that’s why i don’t know it only save 3 letters…??

this is my whole script


<?
session_start();
if(isset( $_SESSION['username']));
echo "Welcome $_SESSION[username].<br>";

include_once("conn.php");
$q="Select * from tblCat";
$cat=mssql_query($q)or die (mssql_error());

$scat="Select * from tblSubcat";
$subcat=mssql_query($scat)or die (mssql_error());

?>

<HTML>
<HEAD>
<TITLE>Create Ticket</TITLE>
<script type="text/javascript">
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit);
else
countfield.value = maxlimit - field.value.length;
}
</script>
</HEAD>
<body>



<FORM METHOD="post" enctype="multipart/form-data" ACTION='inserticket.php' >
<input type='hidden' value='Open' name='stat'>
		<td> User Name : </td>
				<td><?php echo"<label for='uname'>". $_SESSION['username']."</label>"?></td>
		<tr><br>
			<td> Email Address : </td>
			<th align=left><?php echo"<label for='dept'>". $_SESSION['email']."</label>"?></th>
		</tr><br>
		<tr>
			<td>Department : </td>
			<th align=left><?php echo"<label for='dept'>". $_SESSION['Dept']."</label>"?></th>
		</tr><br>
		<td> Category : </td>
			<?php
			echo "<td>";
				echo "<select name='cat'>";
				while($row=mssql_fetch_array($cat)){
				echo "<option value=$row[CatName]>$row[CatName]</option>";
				}echo "</select>";
			echo"</td>";
			?>
		<br>
		<tr>
			<td> Sub-Category : </td>
			<?php 
			echo "<td>";
					echo "<select name='subcat'>";
					while($row=mssql_fetch_array($subcat)){
					echo "<option  value=$row[SubCat]>$row[SubCat]</option>";
					}echo "</select>";
			echo "</td>";
			?>
		</tr>	
		<br>
		</tr>

			<tr>
				<td>Up Load Image</td><br>
				<td>
					<input type='file' name='images[1]'>
					<label for='filesize'>Maximum of 2Mb</label>
				</td>
			</tr>
			<br>
			<tr>
				
				<td>
					<input type='file' name='images[2]' >
				</td>
				</td>
			</tr>
			<br>
			<tr>
				<td>
					<input type='file' name='images[3]'>
				</td>
			</tr>
	<br>
		<tr>	
				<td><font size="1" face="arial, helvetica, sans-serif"> ( You may enter up to 125 characters. )
				</br> 
				<textarea name='desc' wrap='physical' cols='28' rows='4 'onKeyDown="textCounter(this.form.desc,this.form.remLen,125);" onKeyUp="textCounter(this.form.desc,this.form.remLen,125);"></textarea> 
				<br>
				<input readonly type='text' name='remLen' size='3' maxlength='3' value="125"> characters left</font>
				</td>
		</tr>
		<br>	
		<INPUT TYPE="submit" NAME="ticket" VALUE="Submit">
		<INPUT TYPE="reset" NAME="submit" VALUE='Reset'>
</FORM>
  
</body>

</HTML>



this is the script for the insert.


<?php
session_start();
include_once("conn.php");
$ran=rand();

while(list($key,$value) = each($_FILES["images"]["name"])){
if (($_FILES["images"]["size"][$key] < 200000))
{
	
	$filename = $value;
	$add = "upload/$filename";
	$imagename=($_FILES['images']['name'][$key]);
	if(!empty($value)) 
	{ 

	if(copy($_FILES[images][tmp_name][$key],$add)) 
	chmod("$add",0777);
	}
	
	$i = $i+1;
	$img[$i]=($_FILES['images']['name'][$key]);
	
}
}

$image1=trim($img[1]);
$image2=trim($img[2]);
$image3=trim($img[3]);

if(trim($_POST['desc'])<> ""){
header('location:viewticketuser.php');

insert(trim($_POST['cat']),trim($_POST['subcat']),trim($_POST['desc']),trim($_SESSION['username']),trim($image1),trim($image2),trim($image3),trim($_SESSION['email']),trim($_SESSION['Dept']),trim($_POST['stat']),$con); 


}else{
echo'Enter a Description';

}

function insert($cat,$subcat,$message,$uname,$image1,$image2,$image3,$mail,$Dept,$Stat,$con)
{

mssql_query("sp_ticket @cat='$cat',@subcat='$subcat',@desc='$message',@uname='$uname',@img1='$image1',@img2='$image2',@img3='$image3',@email='$mail',@dept='$Dept',@Stat='$Stat'");
		mssql_close($con);
	
}


Try what Derokorian suggested and make sure your html is correctly formatted before submitting the form.

Temporarily add this line at the top of your script for the insert and inspect the output closely:


var_dump($_POST);