-2

My data is not fully getting inserted into database

function()
{
    $a='abcd(a,b,c,d,e)';
    $sql="Insert into tablename(fieldname) Values('".$a."')";
    $res=mysql_query($sql);
}

Value is getting into the database but not fully i.e abcd(a.

OlivierH
  • 3,875
  • 1
  • 19
  • 32
  • so you want to insert abcd(a,b,c,d,e) into one column? try escaping the string? – Liam Sorsby Dec 17 '13 at 13:21
  • 3
    You are using [an **obsolete** database API](http://stackoverflow.com/q/12859942/19068) and should use a [modern replacement](http://php.net/manual/en/mysqlinfo.api.choosing.php). – Quentin Dec 17 '13 at 13:22
  • 3
    What is the type of your column ? You must have something like varchar(6), where 6 is the maximum length of the string. Increase it. – OlivierH Dec 17 '13 at 13:23
  • That code shouldn't give that result (OlivierH has identified a way that it could, but the code still appears to be very placeholdery so the rest of this comment still applies). Have you produced a simplified test case and not confirmed that it still demonstrates the problem? – Quentin Dec 17 '13 at 13:23

1 Answers1

1

The column in your datase is not large enough to hold the data you are trying to insert.

You would probably have noticed this if you had included the structure in your question (hint, next time do incllude the structure).

symcbean
  • 47,736
  • 6
  • 59
  • 94