PDA

View Full Version : Is my code right? Can I run PWS and APACHE...


Mhtml
12-09-2002, 09:53 AM
Ok, don't frown to much mods coz this post is with reason..

I just made my first PHP page Yay!:D
I've installed phpdev from firepages.com.au and have 3 questions.

1: Can I have PWS and Apache running side by side?
2: Is there anything wrong with my coding?
3: Why do I use ?php instead of ? ...

<?php
if (strlen($_GET['MyQuery']) > 0 ) {
echo "MyQuery = ";
echo $_GET['MyQuery'];
} else {
echo "The querystring MyQuery contains nothing.";
}
?>


THe above works, I'm so pleased I figured most of that myself. :D

brothercake
12-09-2002, 10:13 AM
1 - I think so; you would need to bind the server to different ports. Or if you have a LAN, just give them different IP addresses.

2 - Looks good to me. Personally, I'd have gone

if (isset($_GET['MyQuery'])) {

but it amounts to the same thing

3 - I don't believe ?php is necessary anymore - ? will do

Spookster
12-09-2002, 10:18 AM
1. No, unless you configure either Apache or PWS/IIS to run on a different port other than port 80 which is the default port. Otherwise they will both fight to use that port.

2. Not necessarily. There are various different ways of checking if GET or POST data has been populated.

<?php
if (isset($_GET['MyQuery'])) {
echo "MyQuery = ";
echo $_GET['MyQuery'];
} else {
echo "The querystring MyQuery contains nothing.";
}
?>

is another way of doing that.

3. You can use short tags <? ?> <% %> in PHP as long as short tags are enabled in your php.ini file. By default they are disabled so you must use the <?php ?> tags.

Mhtml
12-10-2002, 04:03 AM
Ahh, k sweet..
Last night I came to the conclusion that I will just connnect this comp with my new one and have apache on this and iis on the new one coz it will have xp pro.

BUT, until then how could I change the ports??

Spookster
12-10-2002, 04:56 AM
I don't know what it would be for IIS but for Apache you need to open the httpd.conf file and find this section:


# Port: The port to which the standalone server listens. Certain firewall
# products must be configured before Apache can listen to a specific port.
# Other running httpd servers will also interfere with this port. Disable
# all firewall, security, and other services if you encounter problems.
# To help diagnose problems use the Windows NT command NETSTAT -a
#
Port 80


and change the port then restart apache if it is already running.