kidzkit Posted July 7, 2008 Share Posted July 7, 2008 No matter what i do i cant connect to mysql. I spent a few hours the other day trying every possible connect statement. Here is what i have now. Some help would greatly be appreciated thanks Eric. $con = mysql_connect("localhost","root","rhoads"); if (!$con) { die('Could not connect:' . mysql_error()); } else { echo "Good connection"; } mysql_close($con); Quote Link to comment https://forums.phpfreaks.com/topic/113617-can-someone-help-me-connect-to-mysql/ Share on other sites More sharing options...
discomatt Posted July 7, 2008 Share Posted July 7, 2008 What error are you getting. I suggest changing your password now as well. Quote Link to comment https://forums.phpfreaks.com/topic/113617-can-someone-help-me-connect-to-mysql/#findComment-583821 Share on other sites More sharing options...
wildteen88 Posted July 7, 2008 Share Posted July 7, 2008 What problems are you experiencing? If you're getting a blank page then enable display_errors and make sure error_reporting is set to E_ALL. Save the php.ini and restart server and rerun your script, if you get an error such as "fatal error undefined mysql_connect" then you havn't enabled the mysql extension. if you post your server setup (OS version, PHP version and Server version - example: XP SP2, PHP 5.2.6, Apache2.2.6) then we can help you. Quote Link to comment https://forums.phpfreaks.com/topic/113617-can-someone-help-me-connect-to-mysql/#findComment-583822 Share on other sites More sharing options...
PFMaBiSmAd Posted July 7, 2008 Share Posted July 7, 2008 What error do you get when you run that code? If you don't get an error, what do you see in front of you when you run that code? If you don't see anything when you run that code, what does a "view source" in your browser show? Basically, we only see the information you provide in your post. If you don't tell us what you see in front of you, we cannot help. Quote Link to comment https://forums.phpfreaks.com/topic/113617-can-someone-help-me-connect-to-mysql/#findComment-583823 Share on other sites More sharing options...
kidzkit Posted July 7, 2008 Author Share Posted July 7, 2008 I am getting a complete blank page. No error messages. It doesnt even seem to get to the if statements. I have tried so many different ways of this code i found in tutorials. Quote Link to comment https://forums.phpfreaks.com/topic/113617-can-someone-help-me-connect-to-mysql/#findComment-583824 Share on other sites More sharing options...
wildteen88 Posted July 7, 2008 Share Posted July 7, 2008 Then this is the classic signs of the mysql extension is not enabled. Post your server setup (OS version, PHP version and Server version - example: XP SP2, PHP 5.2.6, Apache2.2.6) then we can help you. Quote Link to comment https://forums.phpfreaks.com/topic/113617-can-someone-help-me-connect-to-mysql/#findComment-583826 Share on other sites More sharing options...
kidzkit Posted July 7, 2008 Author Share Posted July 7, 2008 windows xp sp2, apache 2.2.9, mysql server 5.0, and php 5.2.5. Thats my current setup Quote Link to comment https://forums.phpfreaks.com/topic/113617-can-someone-help-me-connect-to-mysql/#findComment-583827 Share on other sites More sharing options...
kidzkit Posted July 7, 2008 Author Share Posted July 7, 2008 How do I turn on the mysql thing? This is my setup windows xp sp2, apache 2.2.9, mysql server 5.0, and php 5.2.5. Quote Link to comment https://forums.phpfreaks.com/topic/113617-can-someone-help-me-connect-to-mysql/#findComment-583840 Share on other sites More sharing options...
wildteen88 Posted July 7, 2008 Share Posted July 7, 2008 How have you install Apache, PHP and MySQL? Using separate installers? If you have, go to php.net and download the zipped binaries package rather than the PHP installer. Extract the zip to where you have installed PHP to, now rename php.ini-recommended to just php.ini (remove the existing one) Next step add PHP to the PATH Environment Variable. Then open your php.ini and enable display_errors and make sure error_reporting is set to E_ALL. After find the following line: extension_dir = .\ change it to extension_dir = "C:/path/to/php/ext" Change the text in blue Scroll down and find the following line ;extension=php_mysql.dll Remove the ; at the start of the line. Save the php.ini and restart Apache. Rerun your test script. Quote Link to comment https://forums.phpfreaks.com/topic/113617-can-someone-help-me-connect-to-mysql/#findComment-583848 Share on other sites More sharing options...
kidzkit Posted July 7, 2008 Author Share Posted July 7, 2008 OK now i got the errors working and this is what i have for the errors Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\connect.php on line 2 So any way to tell me how this works. Quote Link to comment https://forums.phpfreaks.com/topic/113617-can-someone-help-me-connect-to-mysql/#findComment-583856 Share on other sites More sharing options...
wildteen88 Posted July 7, 2008 Share Posted July 7, 2008 Ok so you have followed everything I told you in my previous post. Then the next problem is PHP may not be reading the php.ini you're editing. Adjust your script to this: phpinfo(); $con = mysql_connect("localhost","root","rhoads"); if (!$con) { die('Could not connect:' . mysql_error()); } else { echo "Good connection"; } mysql_close($con); Run your script again, this time you'll get a web page rendered, with PHP's current settings. The line you want to be concerned with is the Loaded Configuration File line. To the right of that line should be the full path to the php.ini PHP is reading for configuration, it should read C:/path/to/php/php.ini Can you confirm this? Quote Link to comment https://forums.phpfreaks.com/topic/113617-can-someone-help-me-connect-to-mysql/#findComment-583865 Share on other sites More sharing options...
kidzkit Posted July 7, 2008 Author Share Posted July 7, 2008 The loaded configuration file line says C:\Program Files\PHP\php.ini , I have followed what you said and its not working still. Quote Link to comment https://forums.phpfreaks.com/topic/113617-can-someone-help-me-connect-to-mysql/#findComment-583877 Share on other sites More sharing options...
kidzkit Posted July 7, 2008 Author Share Posted July 7, 2008 Thanks for everyone's help. I got mysql configured now. I really appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/113617-can-someone-help-me-connect-to-mysql/#findComment-583905 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.