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. Link to comment https://forums.phpfreaks.com/topic/67974-solved-beginner-help/ 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. Link to comment https://forums.phpfreaks.com/topic/67974-solved-beginner-help/#findComment-341714 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. Link to comment https://forums.phpfreaks.com/topic/67974-solved-beginner-help/#findComment-341727 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". Link to comment https://forums.phpfreaks.com/topic/67974-solved-beginner-help/#findComment-341730 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. Link to comment https://forums.phpfreaks.com/topic/67974-solved-beginner-help/#findComment-341732 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. Link to comment https://forums.phpfreaks.com/topic/67974-solved-beginner-help/#findComment-341733 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. Link to comment https://forums.phpfreaks.com/topic/67974-solved-beginner-help/#findComment-341736 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.