Warning: mysql_fetch_array(): supplied argument is not a...
Posted: Mon Mar 23, 2009 12:27 pm
I am a complete newbie to all this, and this is for a school assignment, so if im way way off i won't be surprised. But here goes it...
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/asarson/public_html/ASSIGNMENT/getcity.php on line 29
I have a html file where the user chooses a city from a drop down list, then from that choice of city, a table of information displays below. Any help will be great...and if you need anymore info ill be checking the thread regularly.
Thanks in advance.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/asarson/public_html/ASSIGNMENT/getcity.php on line 29
Code: Select all
<?php
$q=$_GET["q"];
$con = mysql_connect('localhost', 'ASarson', 'database');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("ajax_demo", $con);
$sql="SELECT * FROM City WHERE id = '".$q."'";
$result = mysql_query($sql);
echo "<table border='1'>
<tr>
<th>City</th>
<th>Team Name</th>
<th>Logo</th>
<th>Year Founded</th>
<th>Division</th>
<th>Owner</th>
<th>Coach</th>
<th>Offensive Coordinator</th>
<th>Defensive Coordinator</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['City'] . "</td>";
echo "<td>" . $row['Name'] . "</td>";
echo "<td>" . $row['Logo'] . "</td>";
echo "<td>" . $row['Year Founded'] . "</td>";
echo "<td>" . $row['Division'] . "</td>";
echo "<td>" . $row['Owner'] . "</td>";
echo "<td>" . $row['Coach'] . "</td>";
echo "<td>" . $row['Offensive Coordinator'] . "</td>";
echo "<td>" . $row['Defensive Coordinator'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>Thanks in advance.