0

Running a SQL query from the following code:

<php
if(sizeof($_POST['addcandidate'])){
		foreach($_POST['addcandidate'] as $id){
		$name= mysql_query("SELECT LastName FROM candidate WHERE Candidate_ID= '$id'");
		while($rowz= mysql_fetch_assoc($name)){
		$candidatename= $rowz['LastName'];
		$alter= "ALTER TABLE '$votertable' ADD '$candidatename' int";
		mysql_query($alter) or die(mysql_error());
		}
		}	
	}
?>

I return Im getting:
#1064 - 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 ''SuperHeros_Votes' ADD 'Butters' int' at line 1

I thought originally it might have been an issue unknown to me since its coming from an array, however, I copied and paste:

ALTER TABLE 'SuperHeros_Votes' ADD 'Butters' int

into phpMyAdmin and got the same result.

1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Exploded Fiber
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.