tanvirzafar Posted March 21, 2014 Share Posted March 21, 2014 hello friends i have a problem..i create a page in localhost db.php here is its code <?php$con= mysql_connect("localhost:8080","root","");$db = mysql_select_db('gcuf',$con);?> it is looking fine...but it doesnot work....when i see the page where i include this one it does not show me any error also not connect to database...dont know what's going on...my apache is running on port 8080 tell me its solution please?? Link to comment Share on other sites More sharing options...
thescientist Posted March 21, 2014 Share Posted March 21, 2014 what are you expecting it to do though? You make a connection and select a database, that's it. You don't aren't sending any output. However, 8080 is likely not the port you want to connect to. By default SQL server runs on port 3306. Just try "localhost" Link to comment Share on other sites More sharing options...
tanvirzafar Posted March 21, 2014 Author Share Posted March 21, 2014 what are you expecting it to do though? You make a connection and select a database, that's it. You don't aren't sending any output. However, 8080 is likely not the port you want to connect to. By default SQL server runs on port 3306. Just try "localhost" i try localhost...but it doesnot connect...as the other keyword become dark blue color in notepad++ these mysql_connect and mysql)select_db not become like other....not work??? Link to comment Share on other sites More sharing options...
Ingolme Posted March 21, 2014 Share Posted March 21, 2014 Forget Notepad++, it has nothing to do with how PHP works. Are you running this page on a server with PHP enabled? You should check for errors as well. <?php$con= mysql_connect("localhost:8080","root","");if(!$con) { echo 'Connection error: ' . mysql_error(); exit;}$db = mysql_select_db('gcuf',$con);?> Link to comment Share on other sites More sharing options...
justsomeguy Posted March 21, 2014 Share Posted March 21, 2014 You should also drop the mysql extension and use mysqli or PDO instead. Link to comment Share on other sites More sharing options...
tanvirzafar Posted March 22, 2014 Author Share Posted March 22, 2014 thanks i got it.... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now