prakash911 Posted March 16, 2010 Share Posted March 16, 2010 guys if i use the mysql_connect command from php to connect to a mysql server, but information do i need to provide if i want to connect to this particular server and bookstore database in that server here is an image i need the information from: Link to comment https://forums.phpfreaks.com/topic/195386-php-mysql-connect-statement/ Share on other sites More sharing options...
StathisG Posted March 16, 2010 Share Posted March 16, 2010 Read this Example: mysql_connect('localhost','root','password'); mysql_select_db('bookstore'); Also you need to handle errors. Link to comment https://forums.phpfreaks.com/topic/195386-php-mysql-connect-statement/#findComment-1026726 Share on other sites More sharing options...
prakash911 Posted March 16, 2010 Author Share Posted March 16, 2010 would i need to make host:localhost:3306 or is localhost fine Link to comment https://forums.phpfreaks.com/topic/195386-php-mysql-connect-statement/#findComment-1026730 Share on other sites More sharing options...
LeadingWebDev Posted March 16, 2010 Share Posted March 16, 2010 localhost default port specified in php.ini Link to comment https://forums.phpfreaks.com/topic/195386-php-mysql-connect-statement/#findComment-1026734 Share on other sites More sharing options...
satre Posted March 16, 2010 Share Posted March 16, 2010 Here's ways to handle the errors: $sql0 = mysql_connect('localhost','root','password'); if (!$sql0) { die('Could not connect: ' . mysql_error()); } if (!mysql_select_db('bookstore')) { die('Could no select database: ' . mysql_error()); } Link to comment https://forums.phpfreaks.com/topic/195386-php-mysql-connect-statement/#findComment-1026735 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.