I've just started working with PHP and MySQL, and I'm trying to create a table in MySQL. If I've got this right, I'm trying to do so by going to my host's SQL MyAdmin page and typing in

mysql_query("CREATE TABLE example(
id INT NOT NULL AUTO_INCREMENT, 
PRIMARY KEY(id),
 name VARCHAR(30), 
 age INT)")

in the query tab. I get an error saying that my syntax is wrong. Any advice?

I believe the PRIMARY statement needs to go at then end of all the column definitions

CREATE TABLE example (
  id int NOT NULL AUTO_INCREMENT,
  name varchar(30),
  age int,
  PRIMARY KEY (id)
)

I don't thing primarykey statement creates error,
I don't thing its is error in query, It may be #1046 - No database selected error,if so create database and select that

try with that

create database db_name;
use db_name;
CREATE TABLE example(
id INT NOT NULL AUTO_INCREMENT, 
PRIMARY KEY(id),
 name VARCHAR(30), 
 age INT)

I get an error saying that my syntax is wrong

What is the actual error message you are getting? Is it from mysql or from PHP?

the line of code you posted doesn't have a semicolon at the end, which will generate a syntax error in php if its like that in your page.

commented: The error message doesn't actually display an error code; very strange. +0