Yeah, I know there are countless tutes that tell me how. I am quite a noob, and I hope you can help me out. I've just been running through a tutorial to set up php/mysql/apache. I seem to be having a problem connecting to mySQL in a php file. MySQL seems to be working fine; I can create databases and tables through the command prompt client, but even this php test file can't seem to get past the line mysqli_connect("localhost", "root", "myPass", "myDB");. I have included the line "extension=php_mysqli.dll" in my php.ini file and set the extension_dir to the directory that does include that dll. The call to connect just seems to hang-- trying to echo something directly afterward produces no output. I have set max_execution_time to small numbers of seconds and waited for timeout, but I cannot get any errors. Can anyone suggest what I should look for next? Using... PHP 5 MySQL Server 5.0 Thanks for any advice.
Thanks, I have read the notes before, and even copying the sample code directly (and replacing the appropriate username/pass/server) gets me nowhere. Even if I am not using the correct parameters, shouldn't the connection just fail rather than hang like that? I can't even get an error message on die(). Thanks!
Oh, and someone in an irc chan suggested I use mysqli in case of compatibility issues with PHP5, but I have also tried mysql_connect with no success.
The script works fine if I host it with a webhost that supports mysql. I really would like to develop on my own machine, though....
then you will have to load the libmysql.dll library into the php core, and the php_mysql.dll extension. To load the libmysql.dll library, you have to make sure the PHP path is available in the windows Path system variable. If it's not available, add it, and reboot your pc. If the libmysql.dll file is not located in the php root folder, copy it in there. Then you have to open your php.ini file, and uncomment (by removing the semi-colon at the beginning of the line) the following line: ;extension=php_mysql.dll Code (markup): make sure the "extension_dir" points to the correct directory Then (re)start your server, to (re)load the php settings
UnrealEd, These are things I had already done yesterday. Thanks for your help. Since I am a total noob at this stuff, please direct me in what direction my questions should be taking. I had originally assumed I was just sucking at php, but since I have tried numerous connection example scripts from reputable sources which all work fine -not- on my machine, this looks to be a different issue. Would it be more appropriate to seek help in a mySQL forum? (Even though your suggestions are much appreciated here!) Or is this inter-related enough to warrant a place in this forum? (On a side note, I am playing around with this stuff-- by relentlessly uploading junk to my web host, lulz-- and am surprised and pleased by its power. With the help of a couple of tutorials and much referencing of the php documentation, I have an ugly, bare-bones message board. Awesome.)
try adding a die() to the connection. might give you a better idea of what is wrong. $conn = mysql_connect("localhost","username","password") or die( mysql_error() ); mysql_select_db("database") or die( mysql_error() ); PHP:
1. What type of installation did you do for PHP? Did you use the msi installer or the the zip file? 2. What error message do you get? Also try running phpinfo and see whether the page you get shows mySQL as being enabled. One way to do this is create a php file with the code below and run it: <?php phpinfo(); ?> Code (markup):
I am experiencing the exact same problem trying to connect to a mysql database. The code to connect is as follows: @ $db = mysql_connect($server, $username, $password) or die(mysql_error()); Any code I have outputted before this statement is displayed but anything after it is not. I have an ifelse statement to test the $db handle but nothing displays. I have had a look at the phpinfo information but there is nothing about mysql in it. If anyone has a solution it would be greatly appreciated. Please email me on milbourne.leigh@gmail.com if you can help. Leigh.
http://www.apachefriends.org/en/xampp-windows.html Check out the following installation software. It comes prebundled with a lot of applications. MySQL server, Apahche, FTP, php, etc.. It will work straight out of the box most of the time and I recommend it 100% to everyone. I used it on my local computer. I think maybe you tried to install each thing seperate (you said command line mysql ouch!!) which can get confusing to setup. __________________ Please, don't forget to give Rep is for great answers.
Not too long ago Windows and MySQL had password issues and I think this is the problem you're facing. Search for password related issues and MySQL. Also, try installing xampp, if you haven't already.