Alright, so I thought I had everything coded right, but when I put my script to the test, all that came up was the end of my script. Here's how my script looks:
ON THE HOST PAGE
</td>
<td width="50%" valign="top">
MY RATING SCRIPT
<table border="0" width="100%" cellspacing="0" cellpadding="5">
<tr>
<td width="100%">
<p align="center"><b><font face="Arial" size="3"><u>Attraction
Rating</u></font></b></td>
</tr>
<tr>
<?php
$id = $_GET['id'] ;
$ip = $_SERVER['REMOTE_ADDR'] ;
$link=mysql_connect('HOST','USERNAME','PASSWORD')
or die('Could not connect: ' . mysql_error());
mysql_select_db('DATABASE') or die('Could not select database');
$query = "SELECT AVG(rating) FROM `rating` WHERE `type` = '$type' AND `attractionid` = '$id'";
$result = mysql_query($query);
$rows = mysql_num_rows($result);
if($rows == 0)
{
?>
<td width="100%"><p align="center"><font face="Arial" size="2">This attraction has not yet been rated!</font></td>
<?php
}
else
{
while ($array = mysql_fetch_array($result)) {
extract($array);
}
?>
<td width="100%"><p align="center"><font face="Arial" size="2">$rating out of 10</font></td>
<?php
}
mysql_close($link);
?>
</tr>
<tr>
</tr>
</table>
<br>
<?php
$id = $_GET['id'] ;
$ip = $_SERVER['REMOTE_ADDR'] ;
$link=mysql_connect('mysql5.hostexcellence.com','rroost_mircsql','timbers2005')
or die('Could not connect: ' . mysql_error());
mysql_select_db('rroost_mirollercoast') or die('Could not select database');
$query = "SELECT * FROM `rating` WHERE `ip` = '$ip' AND `attractionid` = $id AND `type` = '$type'";
$result = mysql_query($query);
$rows = mysql_num_rows($result);
if($rows == 0)
{
<form method="POST" action="rate.php">
<p align="center"><b><u><font face="Arial" size="3">Your
Rating</font></u></b><font face="Arial" size="2"><br>
</font><select size="1" name="rating">
<option value="10">10 - Great</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5 - OK</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1 - Terrible</option>
<input type="hidden" name="ip" value="<?php echo $_SERVER['REMOTE_ADDR'] ?>">
<input type="hidden" name="attractionid" value="<?php echo $id ?>">
<input type="hidden" name="type" value="<?php echo $type ?>">
</select><br>
<input type="submit" value="Rate" name="B1"></p>
</form>
}
else
{
?>
<p align="center"><font face="Arial" size="2">You have already rated this attraction!</font><p align="center"> </p>
<?php
}
mysql_close($link);
?>
AFTER SCRIPT IN HOST PAGE
</td>
<?php
include "skin_footer.php";
?>
I can't figure out what's wrong with it. I've followed the advice of many different people here, and yet it still does not work. Here is my test page to show you what it looks like when I put the script into my file: http://www.mirollercoast.com/viewthrilltest.php?id=002
And yes, mySQL information was deleted for a reason.
Thanks for any help,
~ Reality
Owner of MIRollerCoast.com