View Full Version : Newb PHP Question

07-25-2008, 02:33 PM
So I am relatively new to PHP and I am trying to simply get this small bit of code to work.

<?php if ($row_rsCWGetProduct["product_TypeInput"] == 1) {
<form id="GeneralName" name="GeneralName" method="post" action="">
<label for="Name">Name:</label>
<input name="Name" type="text" id="Name" size="20" maxlength="100" />
<label for="textfield">Name</label>
<input type="text" name="textfield" id="textfield" />

The gist is that if the vale of the first variable is 1, then the form box will display (I know that I still need to code to make it functional, but I need it to display first).

When I comment out the form bits, the page displays fine, but when they are included and the value is 1, I get the error:

Parse error: syntax error, unexpected '<'

On the 4th line down.

Can anyone help me with this simple basic question? All help is greatly appreciated.

I figured it out, moderator, you can remove this thread. Thanks

07-26-2008, 04:27 PM
Your mixing HMTL with PHP?? Thats like me ¡Hablando de repente español, usted acostumbrado puede comprender un dicho de palabra Im! (#translation#-suddenly speaking spanish, you wont be able to understand a word Im saying!)

Also please place code between code tags, the moderators dont like lose code :)

<?php if ($row_rsCWGetProduct["product_TypeInput"] == 1) {
echo "<form id=\"GeneralName\" name=\"GeneralName\" method=\"post" action=\"\">\n";
echo "<label for=\"Name\">Name:</label>\n";
echo "<input name=\"Name\" type=\"text\" id=\"Name\" size=\"20\" maxlength=\"100\" />\n";
echo "</form>\n";
echo "<label for=\"textfield\">Name</label>\n";
echo "<input type=\"text\" name=\"textfield\" id=\"textfield\" />\n";

backslash \ to escape " character for the string out. I would recommend doing a PHP tutorial, just google it and that should get you started. This is basic "Hello World" stuff so you will find that all this is covered in the first part of any tutorial you find.

Kind regards

07-27-2008, 03:02 AM
<?php if ($row_rsCWGetProduct["product_TypeInput"] == 1): ?>
<form id="GeneralName" name="GeneralName" method="post" action="">
<label for="Name">Name: </label>
<input name="Name" type="text" id="Name" size="20">
<label for="textfield">Name</label>
<input type="text" name="textfield" id="textfield">
<?php endif; ?>

07-27-2008, 03:20 AM
Better isnt a word I would use there actually Twey more like "Different" :)