Jump to content

mysql functions and internal server error


Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.");

}

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

 

 

 

 

 

Link to comment
Share on other sites

So I just installed a WAMP and now it works :D

 

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.