Click here to Skip to main content
14,971,553 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have problem when store html list box value in mysql database using php. When I use space, the words after the space are truncating. Please help to fix the problem

I used this code for list box to display the value dynamically
PHP
<select name="DEPT" id="DEPT">
          <option>Select</option>
          ".$deptname."</option>";
      }
      ?>
        </select>
And I used this code for store to the table

PHP
$dept=$_POST['DEPT'];

$query="insert into employee values('".$empid."','".$ename."','".$addr."','".$cno."','".$gen."','".$mstatus."','".$bgroup."','".$dob."','".$age."','".$emailid."','".$pfaccno."','".$natio."','".$reli."','".$quali."','".$dept."','".$desig."','".$doj."','".$abranch."')";
            mysql_query($query);

But when it store to the table only first word is store into the table, remaining words are truncating

for example if the value is "Department of Computer Application" then only "Department" is storing "of Computer Application" is truncating.
Posted
Updated 30-Dec-13 2:17am
v2
Comments
Peter Leow 28-Dec-13 10:17am
   
Help what? Please edit your question to include code.
PrajeeshPP 28-Dec-13 12:58pm
   
i used this code for list box to display the value dynamically

<select name="DEPT" id="DEPT">
<option>Select</option>
".$deptname."</option>";
}
?>
</select>


and i used this code for store to the table


$dept=$_POST['DEPT'];

$query="insert into employee values('".$empid."','".$ename."','".$addr."','".$cno."','".$gen."','".$mstatus."','".$bgroup."','".$dob."','".$age."','".$emailid."','".$pfaccno."','".$natio."','".$reli."','".$quali."','".$dept."','".$desig."','".$doj."','".$abranch."')";
mysql_query($query);


but when it store to the table only first word is store into the table, remaining words are truncating

for example if the value is "Department of Computer Application" then only "Department" is storing "of Computer Application" is truncating
Peter Leow 28-Dec-13 14:34pm
   
You should put your new input in the question for members to view and respond, not to reply to my comment. Please use the edit button to do it.
Btw, I can see that your select list box is not correctly constructed, you may want to show more complete code, please show it in the question space, not to reply to my comment. Thanks.
PrajeeshPP 28-Dec-13 23:23pm
   
Sir, I fix the problem..
I forgot use '(quotes) for the value attribute..
ZurdoDev 31-Dec-13 12:08pm
   
I don't know php but you'll need to encode your values.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900