Nexus10 Posted June 21, 2010 Share Posted June 21, 2010 <?php $host = "localhost"; $user = "ericsmi_admin"; $password = "password"; $database = "ericsmi_Users"; mysql_connect($host, $user, $password) or die(mysql_error("DIED")); mysql_select_db($database) or die("Error: Could not connect to database"); $query = INSERT INTO Users(user, date_registered, password, email) VALUES ("eric", "12/12/12, test, [email protected]"); mysql_query($query) or die("Error: data not inserted"); echo("Data inserted");?> Nothing happens, nothing is printed, not no error message. Link to comment https://forums.phpfreaks.com/topic/205408-connecting-to-mysql-database/ Share on other sites More sharing options...
phpchamps Posted June 21, 2010 Share Posted June 21, 2010 whats in the view source? Link to comment https://forums.phpfreaks.com/topic/205408-connecting-to-mysql-database/#findComment-1074934 Share on other sites More sharing options...
Nexus10 Posted June 21, 2010 Author Share Posted June 21, 2010 Still nothing when using the full tag. Link to comment https://forums.phpfreaks.com/topic/205408-connecting-to-mysql-database/#findComment-1074935 Share on other sites More sharing options...
phpchamps Posted June 21, 2010 Share Posted June 21, 2010 print insert query and try to run it through phpmyadmin Link to comment https://forums.phpfreaks.com/topic/205408-connecting-to-mysql-database/#findComment-1074936 Share on other sites More sharing options...
Nexus10 Posted June 21, 2010 Author Share Posted June 21, 2010 print insert query and try to run it through phpmyadmin I don't understand (new to PHP)? Link to comment https://forums.phpfreaks.com/topic/205408-connecting-to-mysql-database/#findComment-1074939 Share on other sites More sharing options...
Nexus10 Posted June 21, 2010 Author Share Posted June 21, 2010 ? Link to comment https://forums.phpfreaks.com/topic/205408-connecting-to-mysql-database/#findComment-1074950 Share on other sites More sharing options...
phpchamps Posted June 21, 2010 Share Posted June 21, 2010 Try this and tell me whts the output... error_reporting(E_ALL); $host = "localhost"; $user = "ericsmi_admin"; $password = "password"; $database = "ericsmi_Users"; mysql_connect($host, $user, $password) or die(mysql_error("DIED")); mysql_select_db($database) or die("Error: Could not connect to database"); $query = "INSERT INTO Users(user, date_registered, password, email) VALUES ('eric', '12/12/12', 'test', '[email protected]')"; mysql_query($query) or die("Error: data not inserted"); echo("Data inserted"); Link to comment https://forums.phpfreaks.com/topic/205408-connecting-to-mysql-database/#findComment-1074951 Share on other sites More sharing options...
dabaR Posted June 21, 2010 Share Posted June 21, 2010 $query = INSERT INTO Users(user, date_registered, password, email) VALUES ("eric", "12/12/12, test, [email protected]"); There are no quotes around the query string. You need: $query = 'INSERT INTO Users(user, date_registered, password, email) VALUES ("eric", "12/12/12, test, [email protected]")'; Link to comment https://forums.phpfreaks.com/topic/205408-connecting-to-mysql-database/#findComment-1074953 Share on other sites More sharing options...
dabaR Posted June 21, 2010 Share Posted June 21, 2010 Oh, and.... Get into the habit of starting all your scripts with error_reporting(E_ALL); Link to comment https://forums.phpfreaks.com/topic/205408-connecting-to-mysql-database/#findComment-1074954 Share on other sites More sharing options...
Nexus10 Posted June 21, 2010 Author Share Posted June 21, 2010 Try this and tell me whts the output... Error: data not inserted Link to comment https://forums.phpfreaks.com/topic/205408-connecting-to-mysql-database/#findComment-1074956 Share on other sites More sharing options...
phpchamps Posted June 21, 2010 Share Posted June 21, 2010 cool now problem is in your insert query... get it right.. simple... Link to comment https://forums.phpfreaks.com/topic/205408-connecting-to-mysql-database/#findComment-1074958 Share on other sites More sharing options...
Nexus10 Posted June 21, 2010 Author Share Posted June 21, 2010 Thanks, it works now Link to comment https://forums.phpfreaks.com/topic/205408-connecting-to-mysql-database/#findComment-1074959 Share on other sites More sharing options...
phpchamps Posted June 21, 2010 Share Posted June 21, 2010 cool....mark this post as solved... Link to comment https://forums.phpfreaks.com/topic/205408-connecting-to-mysql-database/#findComment-1074966 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.