Can anybody see whats wrong with this code??

I have looked over and over this code and I can’t find what’s wrong with it. When I open it up in a browser(firefox) it displays the headings and the outline of the table, but then it shows code. I have looked for missing bracket quotes, and I think it looks fine. Can anybody help, please…

[code]

Car Types <?php

/* Select all catagories from CarType*/
$query = “SELECT * FROM Cartype ORDER BY carType”;
$result = pg_query($query)
or die (“Couldn’t execute query.”);

/* Display text before form */
echo "

Car Catalog

The following cars are waiting for you to sit behind the wheel.

Find the car that fits you perfectly and ride down the streets in style.

What car are you interested in?

";

/* Creat form containing selection list */
echo “”;
echo “

”;
$counter=1;
while ($row = pg_fetch_array($result))
{
extract($row);
echo “
”;
echo "<input type=‘radio’ name=‘interest’ value=’$carType’;
 if($counter == 1)
 { 
    echo "checked";
 }
 echo "><font size='+1'><b>$carType</b></font>";
 echo "</td>
       <td>$typeDescription</td>";
 echo "</tr>";
 $counter++;

}
echo “

”;
echo "


";
?>

[/code]
(missing opening tag) <?php

/* Select all catagories from CarType*/
$query = “SELECT * FROM Cartype ORDER BY carType”; (I’m showing and error message here …T_Variable)
$result = pg_query($query)
or die (“Couldn’t execute query.”);

/* Display text before form */
echo "

Car Catalog

The following cars are waiting for you to sit behind the wheel.

Find the car that fits you perfectly and ride down the streets in style.

What car are you interested in?

";

/* Creat form containing selection list */
echo “”;
echo “

”;
$counter=1;
while ($row = pg_fetch_array($result))
{
extract($row);
echo “
”;
echo "<input type=‘radio’ name=‘interest’ value=’$carType’;
 if($counter == 1)
 { 
    echo "checked";
 }
 echo " > (delete this character)<font size='+1'><b>$carType</b></font>";
 echo "</td>
       <td>$typeDescription</td>";
 echo "</tr>";
 $counter++;

}
echo “

”;
echo "


";
?>

thats all I can help you with

What exactly does it show? Do you have a live version somewhere publicly available (like a website)? I would like to see the source code for this page.

This is the all the code for the page, just copy and paste and oopen it in a browser.

I went in and fixed some of the syntax to this:

[code]

<?php /* Select all catagories from CarType*/
$query = "SELECT * FROM Cartype ORDER BY carType";
$result = pg_query($query)
	or die ("Couldn't execute query.");

							/* Display text before form */

	echo "<h1 align='center'>Car Catalog</h1>
		<h2 align='center'>The following cars are waiting for you to sit behind the wheel.</h2>
				<p align='center'>Find the car that fits you perfectly and ride down the streets in style.
				<p><h3>What car are you interested in?</h3>";

				/* Creat form containing selection list */

	echo "<form action='ViewCars.php' method='post'>";
	echo "<table cellpadding='5' border='1'>";
$counter=1;
		while ($row = pg_fetch_array($result))

{
extract($row);
echo “

”;
echo “”;
if($counter == 1)
{
echo “checked”;
}
echo “$carType”;
echo "
$typeDescription";
echo “”;
$counter++;
}
echo “”;
echo "


";
?>

[/code]

There are two lines where I’m getting errors now - the $result = pg_query($query) and while ($row = pg_fetch_array($result)) … it is the pg_query and pg_fetch_array that it is having trouble with. If I delete either function I get a loop of error on line 33 which is the extract($row).

You sure there isn’t something missing?

I can’t. I don’t have a webserver available to me right now, and whenever I do, it doesn’t have PostgreSQL up 'n running. Next to that, I never use persistent connections, so if I tried to run this script, it would throw an error here:

$result = pg_query($query)

Where are you connecting to your database? Are you using error_reporting(E_ALL)? Are you getting any errors/warnings/notices?

Thanks guys, it works now. I was missing a brace afterall. Thank you much

Sponsor our Newsletter | Privacy Policy | Terms of Service