msininism Posted March 9, 2007 Share Posted March 9, 2007 Hello, I have a laptop with apache, php, and mysql 5.0.27 installed. all three of them work fine and i have no problems working any one of them. my problem is that i can't integrate php and mysql on my laptop. i used dreamweaver to create a simple mysql connect script and the page comes up blank. here is my script, except my variables were changed to fit my database. _______________ <?php $link = mysql_connect("localhost", "mysql", "pw") or die("Connection failed: " . mysql_error()); if ($link) { echo "Connection successful"; } ?> i've entered in everything correct as well as making typos purposely to see if that had anything to do with it. no matter what i do, it will still come up blank. ive added the mysql extensions to php and edited php.ini according to a wiki on forge.mysql.com . i created a phpinfo.php file and ran it and these are the results under mysqli http://www.rosspractice.com/mysqli.jpg ive been trying to find an answer to my problem for the last few days, and nobodys been able to help me. can someone please help me? - ross Quote Link to comment https://forums.phpfreaks.com/topic/42008-solved-very-frustrating-mysqlphp-problem/ Share on other sites More sharing options...
paul2463 Posted March 9, 2007 Share Posted March 9, 2007 the reason the page is blank is that the connection is throwing an error, it is not showing you it because you are storing the error in $link change you code to <?php $link = mysql_connect("localhost", "mysql", "pw") or die("Connection failed: " . mysql_error()); if ($link) { echo "Connection successful"; } else { echo $link; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/42008-solved-very-frustrating-mysqlphp-problem/#findComment-203727 Share on other sites More sharing options...
msininism Posted March 9, 2007 Author Share Posted March 9, 2007 nah, still doing the same thing. thanks for trying though - ross Quote Link to comment https://forums.phpfreaks.com/topic/42008-solved-very-frustrating-mysqlphp-problem/#findComment-203728 Share on other sites More sharing options...
artacus Posted March 9, 2007 Share Posted March 9, 2007 Yeah, so what's the error? Does it not like your user/password or is it not accepting the connection? Quote Link to comment https://forums.phpfreaks.com/topic/42008-solved-very-frustrating-mysqlphp-problem/#findComment-203746 Share on other sites More sharing options...
msininism Posted March 9, 2007 Author Share Posted March 9, 2007 it wasn't the username/password combo, i wasn't sure what it was. i looked around and found someone with the same problem and they used these lines of code <?php $conn = mysqli_connect('localhost', 'userone', 'password', 'dbname') or die ('Error connecting to mysql'); echo "connection established"; ?> i fixed the variables and was able to get the "connection established" message. the only problem i have now is that when i run a homemade php application, i get a "connection established" message whenever mysql table data is supposed to appear. i know that the php application works because i tested out months ago on a verio webserver where everything was already installed and configured for me. the only thing im changing between this and that is the mysql connect script, and that script works on its own. i entered in data manually through my mysql command line client and when i tried to view it through my php file, nothing would show up. its like, theres a connection that is definitely established, yet the php file and the mysql database will not communicate. Quote Link to comment https://forums.phpfreaks.com/topic/42008-solved-very-frustrating-mysqlphp-problem/#findComment-203790 Share on other sites More sharing options...
wildteen88 Posted March 9, 2007 Share Posted March 9, 2007 I know you solved this, by using the mysqli_connect function but the problem was you was using mysql_connect to connect to the MySQL server but you have the mysqli extension enabled. You cannot use the mysql function library (mysql_connect, mysql_query etc) with that extension. You must use the mysql improved (mysqli - mysqli_connect) function set. php_mysql.dll and php_mysqli.dll have different function sets. Quote Link to comment https://forums.phpfreaks.com/topic/42008-solved-very-frustrating-mysqlphp-problem/#findComment-203899 Share on other sites More sharing options...
msininism Posted March 12, 2007 Author Share Posted March 12, 2007 Thank you all very much for all the help. I went to the php.ini file and changed the following Directory in which the loadable extensions (modules) reside. extension_dir = C:\Program Files\PHP\ext // MySQLi extension extension=php_mysqli.dll to Directory in which the loadable extensions (modules) reside. extension_dir = C:\Program Files\PHP\ext // MySQL extension extension=php_mysql.dll something so simple but i didn't think about it until wildteen mentioned that mysqli and mysql had different function sets. thanks again to everyone who tried to help me out. Quote Link to comment https://forums.phpfreaks.com/topic/42008-solved-very-frustrating-mysqlphp-problem/#findComment-205433 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.