Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 880
  • Last Modified:

Setting up PHP. Notepad++ does not recognize <?php

Hi,

I am a COMPLETE beginner.  I've read a tutorial or two and am trying to set up my PHP environment to work through some of these examples.

I've downloaded/installed notepad++ as an editor.  I've installed version PHP 5.3 (5.3.3) from php.net with the IISCgi webserver option.

While I have no clue what I'm doing, I was hoping that I set it up correctly.  

I'm new in general to web development and was hoping someone could help me out with what I'm doing wrong.  Currently when I run it, I just get a blank page, unless I put some html outside of the <?php .. ?> tags.

Attached is what I am trying to run to be able to test these in firefox.

Thanks again for helping me get on the road.  

Regards,
Kelvin
<html>
<head>

<title>Kelvin.php</title>

</head>
<body>

<?php
Test
$link = mysql_connect('<server>', '<user>', '<password>');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);


echo "Test";
?>


</body>

</html>

Open in new window

0
Kelvin81
Asked:
Kelvin81
  • 3
  • 2
1 Solution
 
Kent WSr. Network / Systems AdminCommented:
How are you  "running it"?  You should be copying this to your php-enabled web server and hitting it as a web page vi port 80 (defaultly).  I have a funny feeling you are just double clicking on the .php file directly in your file browser :)
If not, and you are viewing the php via a web call, there are several thing that could be wrong.
Foremost, was php installed correctly?  second try just doing a simple echo "Hello World" as a test before doing something larger, like a mysql connection.
But, since you say you can't "run it in firefox", I"m thinking you are probably just double clicking your fresh php file and opening in the default browser.  That won't work.  You need to send it through the web server.
If that's not what you are doing, holla back.
0
 
Kelvin81Author Commented:
sort of and almost.

I am using notepad++ which has the "Launch in Firefox" option for debugging.  I thought it would work but apparently not.  

How would I go about sending it through an IIS instance that is on my local machine?   (Sorry for how basic my question is).
0
 
Kent WSr. Network / Systems AdminCommented:
That will work for html, but not php.  If you have IIS with PHP installed an on, then you would just put the *.php page in your document root (usually C:\inetpup\wwwroot), but the properties of your default website will show for sure where the docroot is.
Then, just open up a broswer and go to, say, if your page is named "index.php",
http://localhost/index.php



0
 
Kelvin81Author Commented:
Sorry for the long delay.

I'm sure i'll be putting up questions about how to set up IIS to work with PHP.  So far all I get is badly formed header error in IIS.

(I don't know if it would be easier to scrap it and install apache).

Regards,
Kelvin
0
 
Kent WSr. Network / Systems AdminCommented:
PHP and IIS, although it works pretty well when setup correctly, it has it's issues, especially on how and which way to set it up.
I would suggest using apache, or if you have an old machine you can throw linux on...even a cheap VPS, that would give you more of a real developer experience, as most php apps run on the LAMP stack anyway.
Glad I could help :)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now