0

I saved the values to mysql and I saw spaces like that.

INSERT INTO `names` VALUES (7, 'James Bond            ');

I tried to make it:

INSERT INTO `names` VALUES (7, 'James Bond');

I know make it like that: (But it stripts the space between the words too)

INSERT INTO `names` VALUES (7, 'JamesBond');
Andrew
  • 243
  • 1
  • 10
  • 2
    [`trim`](http://php.net/manual/en/function.trim.php) the value before inserting it. – Jon Jun 18 '13 at 10:27

2 Answers2

3

Use trim()

$variable = trim( $variable );

http://php.net/trim

Ryan
  • 1,356
  • 2
  • 10
  • 18
3

Use TRIM() in your DBMS:

INSERT INTO `names` VALUES (7, TRIM('James Bond            '));

or

trim() in php:

$var = trim('James Bond            ');
BlitZ
  • 12,038
  • 3
  • 49
  • 68