Solved

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

Posted on 2010-11-23
5
825 Views
Last Modified: 2012-05-10
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
Comment
Question by:Kelvin81
  • 3
  • 2
5 Comments
 
LVL 12

Expert Comment

by:Kent W
ID: 34200309
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
 
LVL 8

Author Comment

by:Kelvin81
ID: 34200593
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
 
LVL 12

Accepted Solution

by:
Kent W earned 500 total points
ID: 34200699
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
 
LVL 8

Author Comment

by:Kelvin81
ID: 34205896
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
 
LVL 12

Expert Comment

by:Kent W
ID: 34207727
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now