zenix Posted June 20, 2009 Share Posted June 20, 2009 Hi, I am attempting to learn how to make a basic database that will allow input from a user of a web page to be entered into it. I am not the most efficient coder, but I'm learning and I'm new at this. Anyway, I keep getting this error that says for me to check the mysql manual for the right syntax to use near '(test_id) KEY testype(test_lname, test_fname))' at line 4. I can't see anything wrong with it. If someone could guide me in the right direction I'd really appreciate it! Here is the code I've made: ' <?php $conn = mysql_connect('localhost', 'root')or die(mysql_error()); $create = mysql_query("CREATE DATABASE IF NOT EXISTS testdb") or die(mysql_error()); mysql_select_db ("testdb"); //create table $testdb = 'CREATE TABLE test(test_id int (11) NOT NULL auto_increment, test_lname varchar(40) NOT NULL, test_fname varchar(40) NOT NULL PRIMARY KEY(test_id) KEY testype(test_lname, test_fname))'; $result = mysql_query($testdb) or die(mysql_error()); //Create test type table $testype = 'CREATE TABLE testype(testype_id int(11) NOT NULL auto_incrememnt, empl_pos NOT NULL, primary key (testtype_id))'; //create table others $others = 'CREATE TABLE others(others_id int (11) NOT NULL auto_increment, others_mom varchar(40) NOT NULL, others_dad varchar(40) NOT NULL others_bro varchar(40) NOT NULL others_sis varchar(40) NOT NULL PRIMARY KEY(others_id))'; $results = mysql_query($others) or die(mysql_error()); echo 'Database successfully created!'; ?> Link to comment https://forums.phpfreaks.com/topic/163019-solved-trying-to-learn-tables/ Share on other sites More sharing options...
kickstart Posted June 20, 2009 Share Posted June 20, 2009 Hi Nothing major. Couple of missing commas:- CREATE TABLE zenix2(zenix_id int (11) NOT NULL auto_increment, zenix_lname varchar(40) NOT NULL, zenix_fname varchar(40) NOT NULL, PRIMARY KEY(zenix_id), KEY testype(zenix_lname, zenix_fname)) All the best Keith Link to comment https://forums.phpfreaks.com/topic/163019-solved-trying-to-learn-tables/#findComment-860193 Share on other sites More sharing options...
zenix Posted June 20, 2009 Author Share Posted June 20, 2009 UNBELIEVABLE!! Thanks a lot man! Next time I will look a little harder for the obvious, I really appreciate your assistance! Link to comment https://forums.phpfreaks.com/topic/163019-solved-trying-to-learn-tables/#findComment-860208 Share on other sites More sharing options...
kickstart Posted June 20, 2009 Share Posted June 20, 2009 Hi It is the little things that catch people out. I have stared for ages at code before now trying to see a problem, then someone has spotted it in seconds (or I have spotted it while explaining the problem). All the best Keith Link to comment https://forums.phpfreaks.com/topic/163019-solved-trying-to-learn-tables/#findComment-860246 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.