tj71587 Posted September 5, 2007 Share Posted September 5, 2007 Hey all I just installed php and mysql on a cent os box. I am able to get phpinfo() to display, therefore I am sure it installed. I am just trying to insert things into the data base using this code: (I have a database named test and a table named tracker with the fields username and password) <html> <head> <title>DBASE</title> </head> <body> <?php include 'includes/config.php'; include 'includes/opendb.php'; mysql_select_db($mysql); $query = "INSERT INTO test ( tracker.username, tracker.password) VALUES ('TEST', 'TEST')"; mysql_query($query) or die('Error, insert query failed First One'); $query = "FLUSH PRIVILEGES"; mysql_query($query) or die('Error, insert query failed'); include 'includes/closedb.php'; ?> </body> </html> Here are the includes I have: config.php: <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'password'; $dbname = 'test'; ?> opendb.php: <?php // This is an example opendb.php $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname); ?> closedb.php: <?php // an example of closedb.php // it does nothing but closing // a mysql database connection mysql_close($conn); ?> I get this error message: Error, insert query failed First One Is it a php setting or mysql setting or is my syntax just wrong. thanks. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted September 5, 2007 Share Posted September 5, 2007 Change this line: mysql_query($query) or die('Error, insert query failed First One'); To: mysql_query($query) or die('Error, insert query failed First One <br>ERROR: '.mysql_error()); Tell us what it prints out. Quote Link to comment Share on other sites More sharing options...
tj71587 Posted September 5, 2007 Author Share Posted September 5, 2007 Error, insert query failed First One ERROR: Table 'test.test' doesn't exist Where did i declare test.test? Sorry if I am asking stupid questions. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted September 5, 2007 Share Posted September 5, 2007 Your database is called test, and so is your table...therefor it is defined as test.test. So it is saying there is no such table named "test" in the database "test". Quote Link to comment Share on other sites More sharing options...
tj71587 Posted September 5, 2007 Author Share Posted September 5, 2007 Thanks, I get that, I just dont see where i called my table test...I thought I called it tracker. Can you point out the code where I did that if you wouldnt mind. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted September 5, 2007 Share Posted September 5, 2007 Look at your first query: INSERT INTO test You are wanting to insert into the "test" table. It's telling you that you can't because that table doesn't exist. Quote Link to comment Share on other sites More sharing options...
tj71587 Posted September 5, 2007 Author Share Posted September 5, 2007 Gotcha, thanks so much for the help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.