Question bout how best to implement categories in MySQL

Lets see what happens if we change it around to this:


//insert tags into table  
$sqlTag = 'INSERT INTO Tags (id, Tags) VALUES (:o_id, :tags)';  
try {      
    //run query  
    foreach ($tag as $thetag)   
    {
    	$stmtTag = $dbcon->prepare($sqlTag); 
    	echo "Binding :o_id and {$o_id}<br />\
";
    	$stmtTag->bindValue('o_id', $o_id);
    	echo "Binding :tags and {$thetag}<br />\
";
    	$stmtTag->bindValue('tags', $thetag);
        $stmtTag->execute();   
    }  
} 

Ok i tried what you said (changed Tags to Tag, that was my error before), trying to bind the values however i got this error code this time


o_id = 0
Array
(
    [0] => no
    [1] => yes
)
Binding :o_id and 0
Binding :tags and no
Binding :o_id and 0
Binding :tags and yes
there was a problem creating the comment tableSQLSTATE[42000]: Syntax error or access violation: 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 '( id INT NOT NULL PRIMARY AUTO_INCREMENT, Name VARCHAR(9999) NOT NULL, Email ' at line 2

which means taht the error is in teh comments, so ill check my database to see if it worked

OK, either in phpMyAdmin, or your prefered MySQL client, run this command on that database: DESCRIBE Tags

Then tell me what that says.

And sure enough it did work thanks kduv, ii think ill do what you said and also do this type of table for comments as well so that error can be ignored!
srry uploaded just as you did

Cool. Glad it’s working for you now.

if your still interested the error in phpmyadmin came out as


#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 ''.$tableName.'
    (
    id INT NOT NULL PRIMARY AUTO_INCREMENT,
    Name VARCHAR(9999' at line 1 

i think that meens i concentated wrong, however just a quick question why did bonding work?

When you bind the parameters VIA the execute() method, it does it by calling bindParam() which takes the variables by reference, where bindValue doesn’t.

Ok thanks for all the help kduv!