lilwing Posted June 4, 2008 Share Posted June 4, 2008 Recently I've set up a web server on a Windows 2003 server platform, using Apache 2.2, MySQL 5.0, and PHP 5.2.6. PHP seems to be working fine; I tested by making some variables with mathematical functions, and then echoing them. So I thought I'd try uploading and running my database setup script. I get a blank page from a remote location, and directly on the server, I get an internal server error. I even tried taking example scripts from the PHP website. <?php $link = mysql_connect('[serverip]', 'root', '**********'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_close($link); ?> It seems like anything else is functional, but any mysql functions, like mysql_connect, do not. Maybe it's a MySQL thing; I didn't create any users. I am just using the default account. I've tried the usernames 'root' and 'admin' and I am using the correct ip address and password. What's the issue? Quote Link to comment https://forums.phpfreaks.com/topic/108741-mysql-functions-and-internal-server-error/ Share on other sites More sharing options...
lilwing Posted June 4, 2008 Author Share Posted June 4, 2008 update: I changed username to "root@[ipaddresshere]" from the server, and now I get a blank page with the title Internal server error (500). Hmm.... Quote Link to comment https://forums.phpfreaks.com/topic/108741-mysql-functions-and-internal-server-error/#findComment-557668 Share on other sites More sharing options...
wildteen88 Posted June 4, 2008 Share Posted June 4, 2008 Check your servers error logs. This is where the true error message for why the Internal Server Error message occurs You may be getting the error because your may not have enabled the MySQL extension for PHP yet? Quote Link to comment https://forums.phpfreaks.com/topic/108741-mysql-functions-and-internal-server-error/#findComment-557681 Share on other sites More sharing options...
craygo Posted June 4, 2008 Share Posted June 4, 2008 Also make sure you have mysql extensions running on the server. mysql extensions are not on by default in php Ray Quote Link to comment https://forums.phpfreaks.com/topic/108741-mysql-functions-and-internal-server-error/#findComment-557682 Share on other sites More sharing options...
lilwing Posted June 4, 2008 Author Share Posted June 4, 2008 It's most likely because I didn't install the extensions; this is my first time doing this (and oh joy! I am doing it on a windows computer!) So I went to the guide on PHP.net, followed that, and here's my understanding and what I've done so far: put the php_mysql.dll file in the ext directory inside my PHP directory. put the libmysql.dll file in the PHP directory inserted the following line under the [mysql] section of the php.ini file: extension=php_mysql.dll and then I added the path to the libmysql.dll file: C:\..\PHP\libmysql.dll; I noticed there is already a path to the PHP directory, I wasn't sure if I should delete it or not, so I just left it. Then restarted, and tested. No luck. Thanks for the help so far, I am hoping you can help me further. Quote Link to comment https://forums.phpfreaks.com/topic/108741-mysql-functions-and-internal-server-error/#findComment-557766 Share on other sites More sharing options...
discomatt Posted June 4, 2008 Share Posted June 4, 2008 Are you using this as a production server or a development server? I recommend starting with something that 'works' XAMPP and WAMP (my preference) are both great developer packages. Quote Link to comment https://forums.phpfreaks.com/topic/108741-mysql-functions-and-internal-server-error/#findComment-557770 Share on other sites More sharing options...
lilwing Posted June 4, 2008 Author Share Posted June 4, 2008 Production server. Once I get this set up, I have all kinds of scripts and files to upload... it's going to be a school website Oh and, packages are nice, but I really need to know how to do this manually. Quote Link to comment https://forums.phpfreaks.com/topic/108741-mysql-functions-and-internal-server-error/#findComment-557773 Share on other sites More sharing options...
discomatt Posted June 4, 2008 Share Posted June 4, 2008 Makes sense. Good luck And THANK YOU for not using IIS Quote Link to comment https://forums.phpfreaks.com/topic/108741-mysql-functions-and-internal-server-error/#findComment-557776 Share on other sites More sharing options...
DarkWater Posted June 4, 2008 Share Posted June 4, 2008 1) Really, don't use Windows if you can help it. 2) This is going to be a production server? You have reverse DNS records and everything that you need for a domain on that box? 3) Can you check Apache's logs and check why it's not working? 4) Do: if (function_exists('mysql_connect')) { echo "MySQL installed."; } else { die("MySQL not installed."); } Quote Link to comment https://forums.phpfreaks.com/topic/108741-mysql-functions-and-internal-server-error/#findComment-557778 Share on other sites More sharing options...
wildteen88 Posted June 4, 2008 Share Posted June 4, 2008 It's most likely because I didn't install the extensions; this is my first time doing this (and oh joy! I am doing it on a windows computer!) So I went to the guide on PHP.net, followed that, and here's my understanding and what I've done so far: put the php_mysql.dll file in the ext directory inside my PHP directory. put the libmysql.dll file in the PHP directory inserted the following line under the [mysql] section of the php.ini file: extension=php_mysql.dll and then I added the path to the libmysql.dll file: C:\..\PHP\libmysql.dll; I noticed there is already a path to the PHP directory, I wasn't sure if I should delete it or not, so I just left it. Then restarted, and tested. No luck. Thanks for the help so far, I am hoping you can help me further. Have you set up the extension_dir directive in the php.ini to point to your php extension folder too? Also make sure php is reading the php.ini you are modifying. To check this create a script call this info.info and add the following code to it: <?php phpinfo(); ?> Run info.php from your site and make sure the Loaded Configuration File line reads the correct path to where your php.ini is located to. If its not finding your php.ini then you'll need to correct this first in order for PHP to load the mysql extension. Quote Link to comment https://forums.phpfreaks.com/topic/108741-mysql-functions-and-internal-server-error/#findComment-557783 Share on other sites More sharing options...
lilwing Posted June 4, 2008 Author Share Posted June 4, 2008 1) Really, don't use Windows if you can help it. 2) This is going to be a production server? You have reverse DNS records and everything that you need for a domain on that box? 3) Can you check Apache's logs and check why it's not working? 4) Do: if (function_exists('mysql_connect')) { echo "MySQL installed."; } else { die("MySQL not installed."); } 1. If I was hired and came in to work from scratch, I would have set up a Linux server... however that is not the case. My client has been given a government-distributed server, set up with Windows Server 2003, and there is no way for me to squeeze around that issue. However it is workable. 2. Yes, we have domain records and everything... in fact this school has had a website previously... ran with IIS, but in my experience with Apache, I recommended using that for the HTTP server. IIS operates everything else; mail and so forth. 3. Yes I have checked the logs; I saw a syntax error on both the scripts, however, these are not syntax errors (I have scripted with PHP for 3 years) they are mysql functions assigned to variables. I know that I have not yet configured the extensions. I did not install PHP manually; I used the MSI. But I also downloaded the ZIP with all the DLL's and everything, and I copied those in their respective directories. 4. No, I get a 500 internal error. But with other PHP scripts that use functions other than mysql functions, I do not get an error. It must have something to do with not setting up the extensions. Quote Link to comment https://forums.phpfreaks.com/topic/108741-mysql-functions-and-internal-server-error/#findComment-557789 Share on other sites More sharing options...
lilwing Posted June 4, 2008 Author Share Posted June 4, 2008 It's most likely because I didn't install the extensions; this is my first time doing this (and oh joy! I am doing it on a windows computer!) So I went to the guide on PHP.net, followed that, and here's my understanding and what I've done so far: put the php_mysql.dll file in the ext directory inside my PHP directory. put the libmysql.dll file in the PHP directory inserted the following line under the [mysql] section of the php.ini file: extension=php_mysql.dll and then I added the path to the libmysql.dll file: C:\..\PHP\libmysql.dll; I noticed there is already a path to the PHP directory, I wasn't sure if I should delete it or not, so I just left it. Then restarted, and tested. No luck. Thanks for the help so far, I am hoping you can help me further. Have you set up the extension_dir directive in the php.ini to point to your php extension folder too? Also make sure php is reading the php.ini you are modifying. To check this create a script call this info.info and add the following code to it: <?php phpinfo(); ?> Run info.php from your site and make sure the Loaded Configuration File line reads the correct path to where your php.ini is located to. If its not finding your php.ini then you'll need to correct this first in order for PHP to load the mysql extension. Yes, the extension_dir directive in the php.ini file does point to the correct spot.. I think: C:\......\PHP\ext\ I created the info.php page, and the Loaded Configuration File line does read to the correct path. Quote Link to comment https://forums.phpfreaks.com/topic/108741-mysql-functions-and-internal-server-error/#findComment-557798 Share on other sites More sharing options...
craygo Posted June 4, 2008 Share Posted June 4, 2008 I use Windows without any problems whatsoever. You may need to put the libmysql.dll in the window or windows/system32 folder. Unless you add the php folder to you path. I added the PHP folder to the environment path and now I can store everything to do with php right in the php folder even the php.ini file. if not windows defaults to looking for dll files in the windows or windows/system32 folder. Ray Quote Link to comment https://forums.phpfreaks.com/topic/108741-mysql-functions-and-internal-server-error/#findComment-557803 Share on other sites More sharing options...
lilwing Posted June 4, 2008 Author Share Posted June 4, 2008 I use Windows without any problems whatsoever. You may need to put the libmysql.dll in the window or windows/system32 folder. Unless you add the php folder to you path. I added the PHP folder to the environment path and now I can store everything to do with php right in the php folder even the php.ini file. if not windows defaults to looking for dll files in the windows or windows/system32 folder. Ray I haven't really had any problems with the Windows server. This error is likely on my part. But I do have a problem with Windows PCs, but that's a different story for a different time. What do you mean by environment path? I copied the libmysql.dll file into WINDOWS/system32, and then changed the path to that file. Then restarted. Still no luck. I am beginning to think that maybe completely uninstalling php and then installing it manually. Maybe that will solve the problem. Any other ideas? Quote Link to comment https://forums.phpfreaks.com/topic/108741-mysql-functions-and-internal-server-error/#findComment-557809 Share on other sites More sharing options...
craygo Posted June 5, 2008 Share Posted June 5, 2008 Most people have a problem with windows PC because they don't know enough about them. but like you said that is another story for another time. In examples below I will use "C:\PHP512" as my default php path Right click on my computer, go to properties, click advanced, click environment variables, in the system variables box(second one) scroll till you see path, click path and click edit go to the end put a semicolon in and add the path to your PHP folder ;C:\PHP512 so part of mine looks like C:\Program Files\Raster Design 2008\;C:\PHP512;C:\Program Files\MySQL\MySQL Server 5.0\bin; You can use the last backslash or not doesn't matter. now you just have to restart your server. Now any dll, php.ini file can just be kept in the php folder. Make sure your paths are correct ;;;;;;;;;;;;;;;;;;;;;;;;; ; Paths and Directories ; ;;;;;;;;;;;;;;;;;;;;;;;;; ; UNIX: "/path1:/path2" ;include_path = ".:/php/includes" ; ; Windows: "\path1;\path2" include_path = "c:\PHP512\includes" ; The root of the PHP pages, used only if nonempty. ; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root ; if you are running php as a CGI under any web server (other than IIS) ; see documentation for security issues. The alternate is to use the ; cgi.force_redirect configuration below doc_root = "c:\Inetpub\wwwroot" ; The directory under which PHP opens the script using /~username used only ; if nonempty. user_dir = ; Directory in which the loadable extensions (modules) reside. extension_dir = "c:\PHP512\extensions" Make sure you activate the extension by removing the semi-colon extension=php_mysql.dll I know you did most of these but just want to go through the list Another thing you may need to do is give the account that Apache, or IIS uses read permission to the PHP folder so that it can read the dll files. I am not sure which account apache uses but IIS uses the IUSR_computername account. Hope this helps out. Ray Quote Link to comment https://forums.phpfreaks.com/topic/108741-mysql-functions-and-internal-server-error/#findComment-558234 Share on other sites More sharing options...
lilwing Posted June 5, 2008 Author Share Posted June 5, 2008 Yeah, I did all that. And Apache must have access to the PHP folder because it works, other than those mysql functions. I will check regardless. Quote Link to comment https://forums.phpfreaks.com/topic/108741-mysql-functions-and-internal-server-error/#findComment-558444 Share on other sites More sharing options...
lilwing Posted June 5, 2008 Author Share Posted June 5, 2008 So I just installed a WAMP and now it works If this was not a job, I would sit here and try to figure out what I did wrong, but since I am on the clock, I can't really waste any more time on it. Thanks for the help though! Quote Link to comment https://forums.phpfreaks.com/topic/108741-mysql-functions-and-internal-server-error/#findComment-558462 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.