Jump to content

[SOLVED] PHP-IIS coding problem


Recommended Posts

:facewall:

 

I have not "coded" for almost 8 years and really don't want to get back into it but I have encountered an issue that is causing me more pain than I think I deserve.

 

Environment:

Windows Server 2003 SP1

IIS 6

MySql

PHP5

MRBS (Meeting Room Booking System - PHP)

 

Problem:

Installed MRBS/MySql - MBRS did not work as no PHP installed. Installed PHP5.1. MRBS still not working.

 

Investigated possible reasons, reinstalled php and found a simple piece of code to display config:

 

<?php

phpinf()

?>

 

Works fine but MySql not showing in list of core includes. I decided to come back to that as I would like to see if there is an issue somewhere else. Found a piece of code that just displays text on the page:

 

<?php

echo "Hello World"

?>

 

Works fine, more testing with variables:

 

<?php

$TextVar = "Hello World"

echo $TextVar

?>

 

Does not work, nothing is displayed, I brought both simple snippets together:

 

<?php

echo "Hello World"

$TextVar = "Hello World"

echo $TextVar;

?>

 

Does not work, nothing is displayed, but if I do this:

 

<?php

echo "Hello World"

/$TextVar = "Hello World"

/echo $TextVar;

?>

 

Hello World is displayed. I don't know enough about PHP and the default settings and this "Simple" problem is holding things up not only with mrbs but with other things too so any help with this would be appreciated.

 

Johno

Link to comment
Share on other sites

You're not ending your lines properly. At the end of each line you need place a semi-colon (;). Correct code

<?php
echo "Hello World";
$TextVar = "Hello World";
echo $TextVar;
?>

 

Note: You should turn errors on in your php.ini. Make sure error_reporting is set to E_ALL and that display_errors is set to on.

Link to comment
Share on other sites

You're not ending your lines properly. At the end of each line you need place a semi-colon (;). Correct code

<?php
echo "Hello World";
$TextVar = "Hello World";
echo $TextVar;
?>

 

Note: You should turn errors on in your php.ini. Make sure error_reporting is set to E_ALL and that display_errors is set to on.

 

Thanks for the swift reply. I did as you suggested but with the same result. I then copied your code and replaced mine. It worked and I've done a little bit more testing and it seems to work up to implimenting the next phase which is MySql, PHP and IIS.

 

The issue seems to be a failure somewhere in the config of the system as a whole. I have followed the install guides for MySql and PHP, altered the PHP.INI for the connection to MySql (extension=php_mysql.dll, extension=php_mysqli.dll) but when running a downloaded piece of code called dbtest.php I get the same result as posted earlier. I've checked through the code to ensure the lines are terminated correctly, no missing quotes etc but I don't even get an error message after running. The code is below.

 

The only hint I get is when running the phpinfo() in a simple web page no reference is made to the MySql extensions.

 

Again, any help really appreciated.

 

Johno

:shrug:

 

<?php
// Establish a connection and select a database
$link = mysql_connect('localhost', 'phptest', 'phptest')
or die('Could not connect to the MySQL Server: ' . mysql_error());
mysql_select_db('mysql') or die('Could not Select the Database.<br><br>
The error returned by MySQL was: <br>' . mysql_error());
// Close the connection
mysql_close($link);
?>

 

 

Link to comment
Share on other sites

You will need to enable the mysql extension before you can use the mysql_* functions. Uncomment the following line (remove the semi-colon) in the php.ini

;exetension=php_mysql.dll

 

Ensure your have setup the extension_dir directive is pointing to PHP's extensions folder. So if you have php installed in C:/php then you'll want to set the extension_dir like so

extension_dir = "C:/php/ext"

 

Save the php.ini and restart IIS

Link to comment
Share on other sites

You will need to enable the mysql extension before you can use the mysql_* functions. Uncomment the following line (remove the semi-colon) in the php.ini

;exetension=php_mysql.dll

 

Ensure your have setup the extension_dir directive is pointing to PHP's extensions folder. So if you have php installed in C:/php then you'll want to set the extension_dir like so

extension_dir = "C:/php/ext"

 

Save the php.ini and restart IIS

 

Again, thanks for the quick response. I have changed the php.ini file already and restarted the server but the same thing happened. After further investigation I found a small note saying that 'libmysql.dll' should be in the windows root directory. So that's where I've put it and will reboot the server after my users have gone for the evening (yet another lateish night)

 

I'll post here after I've rebooted.

 

Again thanks.

 

JohnoJohnson

Link to comment
Share on other sites

You only need to restart IIS not the whole server. Restarting IIS shouldn't affect your users.

 

No but I needed to make sure that things were OK and I'm hosting our intranet site from the same server, also IIS based but using MSSQL.

 

having rebooted it still didn't display any webpage and MySql again doesn't show in the extensions list.

 

Dead End from my side, I 'could' try reinstalling everything except IIS (tooooo much of a nono for that to happen)

 

Johno

Link to comment
Share on other sites

Thanks.

 

Check phpinfo(), php.ini is in the c:\windows\ directory. Completed a search and that one is the only instance of php.ini on the hard drive.

 

As this server is only hosting the intranet, I can uninstall php, mysql and mbrs and test each installation at each stage. The only issue I can think of at the moment is that something isn't registered correctly on the server.

 

Johno

 

 

Link to comment
Share on other sites

Installed PHP5.1.

 

Exactly how did you install php? The .msi installer or the .zip package? And why not the current version and what site did you get php from?

 

I downloaded the .zip package as suggested, created a directory and extracted to there. Followed the recommendations regarding the php.ini and "moved" it to the windows directory. I then added php as a web service extension.

 

I then encountered the "missing" output.

Link to comment
Share on other sites

Resolution.

 

Removed all instances of php from the HDD excluding the c:\php5\ directory structure. Renamed that to c:\php5.2.1

 

Downloaded the php3 zip file, extracted to c:\php. Removed the web service instance from IIS, restarted IIS. Tried to add the phpisapi.dll file couldn't find it. Downloaded another version (5.2), when throught he same process and bingo/voila now working perfectly.

 

Any more than that and I don't know.

 

Thanks for all the help provided but I may have some more questions about PHp in the very near future, you have been warned.

 

Johno

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.