2 Answers
2

You need to create a PDO object to be able to use prepared statements. Instead you have opened a connection with mysql_connect(). The two do not mix, and PDO is preferred between them as it is more easily secured through the use of prepared statements (among other reasons).

Youre trying to use 2 different MySQL interfaces at the same time. The mysql_* family of functions use the ext/mysql extension... The prepared statement stuff is PDO. You need to choose one or the other. Since PDO is really the way to go ill give you an example with that:

Yeah it was probably assumed youd not just copy and paste, but rather go and investigate the Docs for PDO and then realize its a completely different extension with a different interface from the examples found there.
– prodigitalsonMar 9 '12 at 17:19