Hello, I need help with this. If in my form i put this,

<td><input type="text" name"Example" id="Example"></td>

and my sql what would i put? Mine is,

$insertQuery = "ALTER TABLE atable ADD column '$example' INT";

this is the error shown, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''' INT' at line 1. I tried many ways but cannot put in the correct syntax. Please help, Thanks.

not need to write COLUMN AND QUOTE

$insertQuery = "ALTER TABLE atable ADD  $example INT";

Thank you for your help, but it doesn't work. Now the error become

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INT' at line 1

Try below code. And post output you are getting.

<?
$insertQuery = "ALTER TABLE atable ADD `".$example."` INT";
$result = mysql_query($insertQuery);
if (!$result) {
    die('Invalid query: ' . mysql_error());
}
else
{
	echo 'Successfully executed';
}
?>

They stated,

Incorrect column name ''

what does this mean?

it could happen if your $example is having nothing

where is $example defined?
I think form posted value is not stored properly in $example variable.
post your code where you are assigning value to $example.

<form method="post" action="index.php">
<td><label for="example">example</label></td>
<td><input type="text" name="example" id="example"></td>
<td><input type="submit" value="Register"> </td>

This is html form. I was asking for php code.
Try below code.

<?
if(isset($_POST['example']])
{
    $example = $_POST['example'];
	if($example=="")
	{
		echo "Field name can not be blank.";
		exit;
	}
    $insertQuery = "ALTER TABLE atable ADD `".$example."` INT";
	$result = mysql_query($insertQuery);
	if (!$result)
	{
		die('Invalid query: ' . mysql_error());
	}
	else
	{
		echo 'Successfully altered';
		exit;
	}
}
?>

Sorry, I'm quite new at this. Might not be able to understand what you are asking for. However, I tried to include that and the same error occur.

This is html form. I was asking for php code.
Try below code.

<?
if(isset($_POST['example']])
{
    $example = $_POST['example'];
	if($example=="")
	{
		echo "Field name can not be blank.";
		exit;
	}
    $insertQuery = "ALTER TABLE atable ADD `".$example."` INT";
	$result = mysql_query($insertQuery);
	if (!$result)
	{
		die('Invalid query: ' . mysql_error());
	}
	else
	{
		echo 'Successfully altered';
		exit;
	}
}
?>

When you add this code, what message do you see on screen?

Hey, Thanks a lot for your help. I found out in the end the caps that i put some the first word caps so they cant locate ><

$example does not exist,
since php5 it would be $_POST