Jump to content
Larry Ullman's Book Forums

Issue In Ch.6 With Php In Netbeans Not Rendering The Php Script.


Recommended Posts

HI all,

I am in chapter six at the end when we are building the FOR loop. I am having a problem with netbeans rendering the php in the html. Is anyone else having this problem.

I have tried the following,

I have restarted Netbeans.

I have commented out the section and retyped it.

I have copied another php section from handle_reg.php and it does not render either.

I have cut out the php script, saved, restarted netbeans, and retyped the script.

I have gone character by character comparing syntax with the book, everything is as the book has it.

here is the code I am writing.

 

<p>Date of Birth:

<select name="month">

<option value="">Month</option>

<option value="1">January</option>

<option value="2">February</option>

<option value="3">March</option>

<option value="4">April</option>

<option value="5">May</option>

<option value="6">June</option>

<option value="7">July</option>

<option value="8">August</option>

<option value="9">September</option>

<option value="10">October</option>

<option value="11">November</option>

<option value="12">December</option>

</select>

<select name="day">

<option value="">Day</option>

<?php <--this is marked in Netbeans as a misspelled word. Also this whole section

is not color coded as other php scripts in the same project are.

for ($i = 1; $i <= 31; $i++) {

print "<option value=\"$i\">$i</option>\n";

}

?>

</select>

<input type="text" name="year" value="YYYY" size="4"/>

</p>

When I run this in the browser (chrome latest version) the drop down only shows "Day" as an option,

When I copy the Select statement in question to handle_reg.php and run it in the browser it rruns just fine i see a drop down with 31 numbers.

Is there a setting in netbeans that is not allowing php to render inside html? I don't think so because it works in every other page?

I am stumped!

Any ideas?

Link to comment
Share on other sites

I just figured it out. Its a stupid N00B mistake.

In Netbeans if you open a new file under your current project you have some base option including a php file or a blank php web page. all of the html files in the book need to be built a a "PHP Web Page" NOT an HTML or XHTML page. Netbeans makes all the code highlighting and php interpretations based on that initial configuration.I really like Netbeans nice configurations, code highlighting, and code completion, but some of the initial configuration for new files can be skipped over too easily.

I just need to slow down ad read the initial config options more carefully.

I hope this helps others.

Link to comment
Share on other sites

Ahh, that makes sense. I use the Netbeans IDE, too, and really like it except for the Code Hints always popping up too soon and getting in my way. Nate, has that been an issue for you? Maybe something is messed up in my configuration.

 

Yeah, really hate that too. I prefer Eclipse for PHP. I don't know why, I just do. For Java, I need NetBeans because the debugger is so awesome. You can stop execution at given points and look at what the objects are storing and look at the methods calls. I had this assignment where we should write a validator for Xhtml. Because you need to figure out "the state" of code, a large switch statements who called the next method. We had to do this char-for-char to figure out what kind of tag it was and whether it was valid or not. No way I would've found my bug without NetBeans!

 

Don't know if you can do something like that in PHP, but at least we have print_r() and var_dump(). :)

  • Upvote 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...