justlukeyou Posted February 28, 2011 Share Posted February 28, 2011 Hi, I found the following tutorial on a list of Top 20 tutorials. However, I have gone through code and there doesn't seem to be any form database connection or config.php fille. So how does this code write to a database if it doesn't connect to a database? http://www.99points.info/2010/07/facebook-style-wallpost-and-comments-system-using-jquery-ajax-and-php-reloaded/ Quote Link to comment https://forums.phpfreaks.com/topic/229077-non-connecting-database-code/ Share on other sites More sharing options...
jcbones Posted February 28, 2011 Share Posted February 28, 2011 You mean like on page 1 of the tutorial where it says> include('dbcon.php'); Database connection is a requirement, most tutorials don't spell it out. This one doesn't, but shows the file included. Quote Link to comment https://forums.phpfreaks.com/topic/229077-non-connecting-database-code/#findComment-1180620 Share on other sites More sharing options...
justlukeyou Posted February 28, 2011 Author Share Posted February 28, 2011 Thanks, The dbcon.php file just shows code which includes itself which is a bit bizarre, so do I just remove that and enter the db connection details? Quote Link to comment https://forums.phpfreaks.com/topic/229077-non-connecting-database-code/#findComment-1180702 Share on other sites More sharing options...
gevensen Posted February 28, 2011 Share Posted February 28, 2011 basically what you need to do is start a connection is below $servername="localhost"; $dbusername="whateveryourusernameis"; $dbpassword="whateveryouruserpasswordis"; $dbname="whateveryourdatabasenameis"; mysql_connect($servername, $dbusername, $dbpassword) or $debug_message.=mysql_error()."Connect Error<br />"; mysql_select_db($dbname) or $debug_message.=mysql_error()."Select Error<br />"; if you put $servername="localhost"; $dbusername="whateveryourusernameis"; $dbpassword="whateveryouruserpasswordis"; $dbname="whateveryourdatabasenameis"; in a file called config.php and include it, if you change the info you only have to change one file i put the debug message in because when i am developing i can have it kick back a message to show all is ok or i screwed up somewhere Quote Link to comment https://forums.phpfreaks.com/topic/229077-non-connecting-database-code/#findComment-1180758 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.