Page 1 of 2

PHP site problems

Posted: Sat Jun 07, 2008 8:40 am
by mikeyboy
Hi there,
I'm having a few problems with a site conversion.

I previously created an access database and connected it to an ASP site - all worked fine

I wanted to convert it to PHP so it could be used on an SQL-based website .....
I altered the PHP and have it working fine on my PC (IIS localhost), so the PHP itself i assume is correct

BUT

When i change the connection values (to have my db name pass etc) and upload the php files, i get either errors or only the HTML showing. The database has been converted to SQL without a problem and is residing on my server.

I inserted the following to hopefully glean some answers about why it won't work:
ini_set ("display_errors", "1");
error_reporting(E_ALL);

But it gives me no information. It just seems to skip the if and print the not available line.
Why would it not do the same as the offline localhost version.
I tried switching the two print statements round and that gives me an error with one of the mysql functions.
Code below without most of the html so i don't make the post any longer than necessary.

The site basically runs through a set of pages to reach a final picture destination and this is the first page (i.e. the gallery page allows the user to select the type of picture, this carries forward to the next page where they choose the style and so on).

Working local version:
----------------------------------------

Code: Select all

<?php
$CategoryID=$_GET["CategoryID"];
$CategoryName=$_GET["CategoryName"];
 
$ManufacturerID=$_GET["ManufacturerID"];
$ManufacturerName=$_GET["ManufacturerName"];
$ManufacturerCategoryID=$_GET["ManufacturerCategoryID"];
 
$conn=odbc_connect('Gallery','','');
$sql="SELECT Group.GroupID, Group.GroupName, Group.GroupImg FROM [Group] ORDER BY Group.GroupName";
$rs=odbc_exec($conn,$sql);
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" cool gridx="8" gridy="8" showgridx showgridy usegridx usegridy><tr height="8"><td align="center"><img src="images/CGLLogoSmall.jpg"></td></tr></table>
                  
<hr />
<br />
<table width="100%">
<tr><td align="center" class="subheading"><strong>Welcome to the Gallery</strong>                    </td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td colspan="4" align="center"><strong>Please select your style from the options below: </strong></td></tr>
<tr><td colspan="4" align="center">
<table width="90%" border="0"><tr><td><table class="heading" width="500px" border="0">
<?php if (!($rs==0))
{
?>
<?php   while(odbc_fetch_row($rs))
  {
?>
<?php     print "<tr><td align='left'><a href='Group.php?GroupID=".odbc_result($rs,"GroupID")."&Group=".odbc_result($rs,"GroupName")."' class='heading'>".odbc_result($rs,"GroupName")."</a></td><td><img src='' /></td></tr>";?>
<?php     //$rs=odbc_fetch_array($rs_query);
?>
<?php   } 
}
  else
{
  print "<tr><td>Not Available</td></tr>";
} 
odbc_close($conn);
?>
-----------------------------------------------------------------------------------------
Not working online version:

Code: Select all

 
<?php
ini_set ("display_errors", "1");
error_reporting(E_ALL);
 
/*$CategoryID=$_GET["CategoryID"];
$CategoryName=$_GET["CategoryName"];
$ManufacturerID=$_GET["ManufacturerID"];
$ManufacturerName=$_GET["ManufacturerName"];
$ManufacturerCategoryID=$_GET["ManufacturerCategoryID"];
*/
 
echo "Microsoft.Jet.OLEDB.4.0";
$conn=mysql_connect("localhost","XXXX","XXXX");
mysql_select_db("XXXX",$conn);
 
$rs=mysql_query("SELECT Group.GroupID, Group.GroupName, Group.GroupImg FROM [Group] ORDER BY Group.GroupName");
$GroupID = ("GroupID");
$Group = ("GroupName");
?>
 
<table width="100%" border="0" cellspacing="0" cellpadding="0" cool gridx="8" gridy="8" showgridx showgridy usegridx usegridy><tr height="8"><td align="center"><img src="images/CGLLogoSmall.jpg"></td></tr></table>
                      
<hr />
<br />
<table width="100%">
<tr><td align="center" class="subheading"><strong>Welcome to the Gallery</strong>                    </td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td colspan="4" align="center"><strong>Please select your style from the options below: </strong></td></tr>
<tr><td colspan="4" align="center">
<table width="90%" border="0"><tr><td><table class="heading" width="500px" border="0">
<?php if (!($rs==0))
{
?>
 
<?php   while(!($rs=0))
  {
?>
<?php     print "<tr><td align='left'><a href='Group.php?GroupID=".mysql_result($rs,"GroupID")."&Group=".mysql_result($rs,"GroupName")."' class='heading'>".mysql_result($rs,"GroupName")."</a></td><td><img src='' /></td></tr>";
          ?>
<?php     //$rs=odbc_fetch_array($rs_query);
?>
<?php   }
}
  else
{
  print "<tr><td>Not Available</td></tr>";
}
mysql_close($conn);
?>
 
Could be something simple or stupid, but i've been coding so much recently my eyes are going funny. Now if i had hair i'd be pulling it out, so i'm settling for a sense of humour failure, which is most unlike me.
Any assistance would be greatly appreciated.

Re: PHP site problems

Posted: Sat Jun 07, 2008 9:22 am
by dbemowsk
Please use BBcode tags. Your code is so long it is hard to follow.

Re: PHP site problems

Posted: Sat Jun 07, 2008 9:36 am
by mikeyboy
My apologies i read the bit about BBcode after i posted. Doh ..

Re: PHP site problems

Posted: Sat Jun 07, 2008 10:05 am
by dbemowsk
The value of $rs after the mysql_query call will either be false if it fails or contain a result resource identifier. Therefore your line

Code: Select all

if (!($rs==0))
will not do the trick completely. Try something like this:

Code: Select all

 
$rs=mysql_query("SELECT Group.GroupID, Group.GroupName, Group.GroupImg FROM [Group] ORDER BY Group.GroupName");
if ($rs) { //This will check if the query failed or not
  if (mysql_num_rows($rs) > 0) {  //This will check if there were any results returned from the query
    while ($row = mysql_fetch_array($rs)) {
      echo "<tr><td align='left'><a href='Group.php?GroupID=".$row['GroupID']."&Group=".$row['GroupName']."' class='heading'>".$row['GroupName']."</a></td><td><img src='' /></td></tr>";
    }
  } else {
    echo "No results found";
  }
} else {
  echo "There was a query error : " . mysql_error(); //Echo out the mysql query error
}
 
This should fix your problems I would think.

Re: PHP site problems

Posted: Sat Jun 07, 2008 10:32 am
by Benjamin
Your query on line 17 is not valid MySQL syntax.

Code: Select all

 
$rs=mysql_query("SELECT Group.GroupID, Group.GroupName, Group.GroupImg FROM [Group] ORDER BY Group.GroupName");
 
Change it to:

Code: Select all

 
$rs=mysql_query("SELECT GroupID, GroupName, GroupImg FROM `Group` ORDER BY GroupName");
 

Re: PHP site problems

Posted: Sat Jun 07, 2008 10:42 am
by mikeyboy
Thanks for the response.
I tried the code you suggested, but got the following error:

There was a query error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[Group] ORDER BY GroupName' at line 1

Group is a table within my db. It contains 2 columns GroupID and GroupName.
As i'm only calling this select from a single table i've just removed the Group. in front of all the queries as it shouldn't be necessary. Doesn't help at all though :(

I know that Group is an SQL reserved word but understood i could bypass this by using []

Just in case though, i tried using one of the other tables "category", which also has only 2 columns CategoryID and CategoryName ... no joy with those either, so i have to assume its the code.

Mikey

Re: PHP site problems

Posted: Sat Jun 07, 2008 10:50 am
by dbemowsk
As astions explained, change "[Group]" in your query to "Group".

Re: PHP site problems

Posted: Sat Jun 07, 2008 10:53 am
by Benjamin
dbemowsk wrote:As astions explained, change "[Group]" in your query to "Group".
`Group`

Re: PHP site problems

Posted: Sat Jun 07, 2008 10:57 am
by mikeyboy
Yup, i tried that too, but saw the suggestion after i'd hit post. It just changes the error to:

There was a query error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''Group' ORDER BY GroupName' at line 1

Re: PHP site problems

Posted: Sat Jun 07, 2008 11:00 am
by Benjamin
It's backticks, not single or double quotes. Please copy and paste the query into your code.

Re: PHP site problems

Posted: Sat Jun 07, 2008 11:05 am
by mikeyboy
Thanks Astion, that works great.

I'm so so happy :)

Re: PHP site problems

Posted: Sat Jun 07, 2008 12:24 pm
by mikeyboy
Ok i have another one ...

Further along the chain i have a page with much denser code that i have barely begun to re-write for online (i.e. most of it still calls odbc functions for my working localhost version)

The connection data is fine, but again it passes by the IF statement and posts as not available.
Added to that, many odbc bits are within code and i'm not clear what they should be changed to.
I have a feeling it's because this page has a form in it, but as above I can't tell how i should re-phrase it all.

Code: Select all

 
<?php 
$CategoryID=$_GET["CategoryID"];
$CategoryName=$_GET["CategoryName"];
$GroupID=$_GET["GroupID"];
$Group=$_GET["Group"];
$ManufacturerID=$_GET["ManufacturerID"];
$ManufacturerName=$_GET["ManufacturerName"];
$ManufacturerCategoryID=$_GET["ManufacturerCategoryID"];
 
echo "Microsoft.Jet.OLEDB.4.0";
$conn=mysql_connect("localhost","XXXX","XXXX");
mysql_select_db("XXXX",$conn);
 
$ManufacturerName = ("ManufacturerName");
$CategoryID = ("CategoryID");
$CategoryName = ("CategoryName");
?>
 
<table width="100%" border="0" cellspacing="0" cellpadding="0" cool gridx="8" gridy="8" showgridx showgridy usegridx usegridy>
<tr height="8"><td align="center"><img src="images/CGLLogoSmall.jpg"></td></tr></table>
                      
<hr />
<br />
<table width="100%">
<tr><td align="center" class="heading"><a href="Gallery.php" class="heading">Gallery</a> - <a href="Group.php?Group=<? print $Group;?>&GroupID=<? print $GroupID;?>" class="heading"><? print $Group;?> Prints</a> - <? print $ManufacturerName;?></td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td colspan="4" align="center"><strong>Please select a Category</strong></td></tr>
<tr><td colspan="4" align="center">
<table width="90%"><tr><td valign="top"></td><td><table class="heading" width="500px"><td align="left">
<? if (!($rs==0))
{
?>
<?php   do 
  {
?>
<form name="Paintingsform" method="post" action="Paintings.php"><input type="hidden" name="CategoryID" value="<?  print  odbc_result($rs,"CategoryID");?>" /><tr><td align="left"><a href="Paintings.php?CategoryID=<?     print odbc_result($rs,"CategoryID");?>&CategoryName=<?     print odbc_result($rs,"CategoryName");?>&Group=<?     print $Group;?>&GroupID=<?     print $GroupID;?>&ManufacturerID=<?     print $ManufacturerID;?>&ManufacturerName=<?     print $ManufacturerName;?>&ManufacturerCategoryID=<?     print $ManufacturerCategoryID;?>" class="heading"><img src="Images/<?php   print odbc_result($rs,"ImgName");?>.gif" border="0" /></a></td><td align="left"><a href="Paintings.php?CategoryID=<?     print odbc_result($rs,"CategoryID");?>&CategoryName=<?     print odbc_result($rs,"CategoryName");?>&Group=<?     print $Group;?>&GroupID=<?     print $GroupID;?>&ManufacturerID=<?     print $ManufacturerID;?>&ManufacturerName=<?     print $ManufacturerName;?>&ManufacturerCategoryID=<?     print odbc_result($rs,"ManufacturerCategoryID");?>"class="heading"><?     print odbc_result($rs,"CategoryName");?></a> - <span class="subheading"></span></td><td></tr></form>
<?   }
while(odbc_fetch_row($rs))
?>
<?
}
  else
{
   print "Not Available";
} 
mysql_close($conn);
 ?>
 
Once again i would greatly appreciate any assistance and thanks again for the previous help :)

Re: PHP site problems

Posted: Sat Jun 07, 2008 4:17 pm
by dbemowsk
mikeyboy, again you are using similar code as in your first post

Code: Select all

 
<? if (!($rs==0))
{
?>
<?php   do
  {
?>
<form name="Paintingsform" method="post" action="Paintings.php"><input type="hidden" name="CategoryID" value="<?  print  odbc_result($rs,"CategoryID");?>" /><tr><td align="left"><a href="Paintings.php?CategoryID=<?     print odbc_result($rs,"CategoryID");?>&CategoryName=<?     print odbc_result($rs,"CategoryName");?>&Group=<?     print $Group;?>&GroupID=<?     print $GroupID;?>&ManufacturerID=<?     print $ManufacturerID;?>&ManufacturerName=<?     print $ManufacturerName;?>&ManufacturerCategoryID=<?     print $ManufacturerCategoryID;?>" class="heading"><img src="Images/<?php   print odbc_result($rs,"ImgName");?>.gif" border="0" /></a></td><td align="left"><a href="Paintings.php?CategoryID=<?     print odbc_result($rs,"CategoryID");?>&CategoryName=<?     print odbc_result($rs,"CategoryName");?>&Group=<?     print $Group;?>&GroupID=<?     print $GroupID;?>&ManufacturerID=<?     print $ManufacturerID;?>&ManufacturerName=<?     print $ManufacturerName;?>&ManufacturerCategoryID=<?     print odbc_result($rs,"ManufacturerCategoryID");?>"class="heading"><?     print odbc_result($rs,"CategoryName");?></a> - <span class="subheading"></span></td><td></tr></form>
<?   }
while(odbc_fetch_row($rs))
 
See my previous post on how to deal with fetching data from the database.

Your first problem is that I don't see your database query in your code where $rs = mysql_query(...query string...);. Another problem is with

Code: Select all

 
<? if (!($rs==0))
{
?>
 

which is not the proper way to check your query results. Also, you are trying to mix a MySQL connection with an ODBC connection, which will not work anyway.

Fix these multiple errors by guide of my previous post and you should be good to go..

Re: PHP site problems

Posted: Sat Jun 07, 2008 5:17 pm
by mikeyboy
Firstly i think you misunderstood the first bit, as i said i do know that it displays some of the same characteristics as the first post and also that i had not yet changed many of the odbc points. Hence i am not trying to mix an odbc with an sql, i'm simply making sure i get the changes right.

I need input on whether there were any differences in syntax with it being a form.
i.e.

Code: Select all

 
<form name="Paintingsform" method="post" action="Paintings.php"><input type="hidden" name="CategoryID" value="<?  print  odbc_result($rs,"CategoryID");?>" /><tr><td align="left"><a href="Paintings.php?CategoryID=<?     print odbc_result($rs,"CategoryID");?>&CategoryName=<?     print odbc_result($rs,"CategoryName");?>&Group=<?     print $Group;?>&GroupID=<?     print $GroupID;?>&ManufacturerID=<?     print $ManufacturerID;?>&ManufacturerName=<?     print $ManufacturerName;?>&ManufacturerCategoryID=<?     print $ManufacturerCategoryID;?>" class="heading">
 
That looks a bit strange using <a href='Paintings.php?CategoryID=".$row['CategoryID']. (etc). Hence does the syntax need to be different?
Also as there is a do statement within the if, so again ... does that change the syntax you suggested in your earlier response.
I realise the query is missing, so that is now back in again.

In its current state (with your amended if statement commented out as i'm not sure if it still works the same):

Code: Select all

 
<?php 
ini_set ("display_errors", "1");
error_reporting(E_ALL);
 
//$CategoryID=$_GET["CategoryID"];
//$CategoryName=$_GET["CategoryName"];
$GroupID=$_GET["GroupID"];
$Group=$_GET["Group"];
$ManufacturerID=$_GET["ManufacturerID"];
$ManufacturerName=$_GET["ManufacturerName"];
//$ManufacturerCategoryID=$_GET["ManufacturerCategoryID"];
 
 
echo "Microsoft.Jet.OLEDB.4.0";
$conn=mysql_connect("localhost","XXXX","XXXX");
mysql_select_db("XXXX",$conn);
 
$ManufacturerID = ("ManufacturerID");
$ManufacturerCategoryID = ("ManufacturerCategoryID");
$ManufacturerName = ("ManufacturerName");
$CategoryID = ("CategoryID");
$CategoryName = ("CategoryName");
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" cool gridx="8" gridy="8" showgridx showgridy usegridx usegridy><tr height="8"><td align="center"><img src="images/CGLLogoSmall.jpg"></td></tr></table>
<hr />
<br />
<table width="100%">
<tr><td align="center" class="heading"><a href="Gallery.php" class="heading">Gallery</a> - <a href="Group.php?Group=<? print $Group;?>&GroupID=<? print $GroupID;?>" class="heading"><? print $Group;?> Prints</a> - <? print $ManufacturerName;?></td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td colspan="4" align="center"><strong>Please select a Category</strong></td></tr>
<tr><td colspan="4" align="center">
 
<table width="90%"><tr><td valign="top"></td><td><table class="heading" width="500px"><td align="left">
<?
$rs=mysql_query("SELECT Category.CategoryID AS CategoryID, Category.CategoryName, Manufacturer.ManufacturerID AS ManufacturerID, Manufacturer.ManufacturerName, ManufacturerCategory.ManufacturerCategoryID, ManufacturerCategory.ManufacturerID, ManufacturerCategory.CategoryID FROM Category, Manufacturer, ManufacturerCategory WHERE Category.CategoryID = ManufacturerCategory.CategoryID AND Manufacturer.ManufacturerID = ManufacturerCategory.ManufacturerID AND Manufacturer.ManufacturerID = '" & ManufacturerID & "' Order by Category.CategoryName");
// if ($rs) { //This will check if the query failed or not
//   if (mysql_num_rows($rs) > 0) {  //This will check if there were any results returned from the query
//     while ($row = mysql_fetch_array($rs)) {
 if (!($rs==0))
{
?>
<?php   do 
  {
<form name="Paintingsform" method="post" action="Paintings.php"><input type="hidden" name="CategoryID" value=".$row['CategoryID']."/><tr><td align="left"><a href='Paintings.php?CategoryID=".$row['CategoryID']."&CategoryName=".$row['CategoryName']."&Group=".$row['Group']."&GroupID=".$row['GroupID']."&ManufacturerID=".$row['ManufacturerID']."&ManufacturerName=".$row['ManufacturerName']."&ManufacturerCategoryID=".$row['ManufacturerCategoryID'].>" class="heading"></td><td align="left"><a href='Paintings.php?CategoryID=".$row['CategoryID']."&CategoryName=".$row['CategoryName']."&Group=".$row['Group']."&GroupID=".$row['GroupID']."&ManufacturerID=".$row['ManufacturerID']."&ManufacturerName=".$row['ManufacturerName']."&ManufacturerCategoryID=".$row['ManufacturerCategoryID']."class="heading"><? ".$row['CategoryName']."?></a> - <span class="subheading"></span></td><td></tr></form>
 <?   }
while(odbc_fetch_row($rs))
?>
<?
}
  else
{
  print "Not Available";
} 
mysql_close($conn);
 ?>
 
I get errors about white space in the form line, which makes me think the previously suggested way of altering the odbc to $row.[' etc is not the right syntax for this form.

Many thanks
M

Re: PHP site problems

Posted: Sat Jun 07, 2008 7:18 pm
by dbemowsk
Sorry about that, I did miss where you mentioned that you still have all the ODBC calls in place.
mikeyboy wrote:I need input on whether there were any differences in syntax with it being a form.
I don't know if I fully understand your question here, but I will give it a shot.

With any backend scripting language, be it ASP, PHP, PERL or whatever, the only difference is how you generate your HTML output. The resulting HTML should stay the same though. Weather you use

Code: Select all

<a href='Paintings.php?CategoryID=<?php print $row['CategoryID']; ?>
or

Code: Select all

<a href='Paintings.php?CategoryID=<?php print odbc_result($rs,"CategoryID"); ?>
If your category ID is 5, either way you should end up with

Code: Select all

<a href='Paintings.php?CategoryID=5
As for the "do" statement in the "if", there are 2 different ways of doing a do...while loop in PHP.

Code: Select all

 
do {
  [your code]
}
while ($a_number < 10);
 
is similar to

Code: Select all

 
while(while ($a_number < 10) {
  [your code]
}
 
the only difference is that if $a_number = 12, the first instance will execute [your code] and check the condition afterwards. In the second instance, [your code] is not executed since the condition was checked first and evaluated to false.

What error are you getting about white space in the form line? The syntax of the code that I have provided should not cause such an error, though I do not know what the error is exactly. Not to mention, that line is so long, I may have missed something when reviewing it.

Your code should look like this:

Code: Select all

 
<?php
if ($rs) 
{ //This will check if the query failed or not
  if (mysql_num_rows($rs) > 0) 
  {  //This will check if there were any results returned from the query
    while ($row = mysql_fetch_array($rs)) 
    {
?>
      <form name="Paintingsform" method="post" action="Paintings.php"><input type="hidden" name="CategoryID" value=<?php print $row['CategoryID']; ?>/><tr><td align="left"><a href='Paintings.php?CategoryID=<?php print $row['CategoryID'] ;?>&CategoryName=<?php print $row['CategoryName']; ?>&Group=<?php print $row['Group'] ;?>&GroupID=<?php print $row['GroupID']; ?>&ManufacturerID=<?php print $row['ManufacturerID']; ?>&ManufacturerName=<?php print $row['ManufacturerName']; ?>&ManufacturerCategoryID=<?php print $row['ManufacturerCategoryID']; ?> class="heading"></td><td align="left"><a href='Paintings.php?CategoryID=<?php print $row['CategoryID']; ?>&CategoryName=<?php print $row['CategoryName']; ?>&Group=<?php print $row['Group']; ?>&GroupID=<?php print $row['GroupID']; ?>&ManufacturerID=<?php print $row['ManufacturerID'];  ?>&ManufacturerName=<?php print $row['ManufacturerName']; ?>&ManufacturerCategoryID=<?php print $row['ManufacturerCategoryID']; ?>class="heading"><?php print $row['CategoryName']; ?></a> - <span class="subheading"></span></td><td></tr></form>
 <?php   }
  }
  else 
  {
    print "no results found"; //Edit this line as needed for what you need displayed when no database records are found in the query
  }
}
  else
{
  print "Not Available";
} 
?>
 
When you are trying to display PHP variable values inside your HTML code which resides outside the PHP tags, you need to do a PHP print or echo which requires you to put it in PHP tags <?php print $your_variable; ?>. I also suggest using "<?php" instead of "<?" since the first will work in all PHP configurations whereas the second won't.

To avoid all the "<?php .....; ?>", you could code this like this:

Code: Select all

 
<?php
if ($rs) 
{ //This will check if the query failed or not
  if (mysql_num_rows($rs) > 0) 
  {  //This will check if there were any results returned from the query
    while ($row = mysql_fetch_array($rs)) 
    {
      print "<form name=\"Paintingsform\" method=\"post\" action=\"Paintings.php\">";
      print "<input type=\"hidden\" name=\"CategoryID\" value=". $row['CategoryID'] ." />";
      print "<tr><td align=\"left\">";
      print "<a href=\"Paintings.php?CategoryID=". $row['CategoryID'] ."&CategoryName=". $row['CategoryName'] ."&Group=". $row['Group'] ."&GroupID=". $row['GroupID']  ."&ManufacturerID=". $row['ManufacturerID'] ."&ManufacturerName=". $row['ManufacturerName'] ."&ManufacturerCategoryID=". $row['ManufacturerCategoryID'] ."\" class=\"heading\">";
      print "</td><td align=\"left\">";
      print "<a href=\"Paintings.php?CategoryID=". $row['CategoryID'] ."&CategoryName=". $row['CategoryName'] ."&Group=". $row['Group'] ."&GroupID=". $row['GroupID']  ."&ManufacturerID=". $row['ManufacturerID'] ."&ManufacturerName=". $row['ManufacturerName'] ."&ManufacturerCategoryID=". $row['ManufacturerCategoryID'] ." \" class=\"heading\">". $row['CategoryName'] ."</a>";
      print " - <span class=\"subheading\"></span></td><td></tr></form>";
    }
  }
  else 
  {
    print "no results found"; //Edit this line as needed for what you need displayed when no database records are found in the query
  }
}
  else
{
  print "Not Available";
} 
?>
 
I broke up the large form tag line into some smaller print statements to make the code easier to follow. Notice all the \" within the print statements. This tells PHP to escape the quotes and print a literal double quote mark. If this is not done, the PHP parser will take that as an end to a quoted string.

This is a lot to swallow in one post, but I hope you caught all that.