# PHP/MySQL - INSERT question

**URL:** <https://forum.kirupa.com/t/php-mysql-insert-question/192439>\
**Category:** programming\
**Created:** [June 28, 2006, 4:52pm UTC](https://forum.kirupa.com/t/php-mysql-insert-question/192439 "2006-06-28T16:52:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![robmcfeters](https://avatars.discourse-cdn.com/v4/letter/r/e36b37/32.png) [@robmcfeters](https://forum.kirupa.com/u/robmcfeters)\
**Post date:** [June 28, 2006, 4:52pm UTC](https://forum.kirupa.com/t/php-mysql-insert-question/192439/1 "2006-06-28T16:52:58Z")

</div>

I’m trying to get this query to work.

```php

$name = $_POST['name'];
$bads = array(".", "/", ",", "&", "-", "@", "#", "%", "*", "(", " ", ")");
$newname = str_replace($bads,"",$name);
$score = $_POST['score'];

$connect = mysql_connect("test", "test", "test");
mysql_select_db(test, $connect) or die(mysql_error());
$query = "INSERT INTO dynamic_scores (" . $newname . ") VALUES ('$score')";
mysql_query($query);

```

However, this query definitely won’t insert a row into the database. If I use a normal column name, instead of setting it to a variable, then it works…but I want to use the variable.

Any ideas?
