Page 1 of 1

Warning: mysql_fetch_array(): supplied argument is not a...

Posted: Mon Mar 23, 2009 12:27 pm
by FusionSarson
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

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);
?>
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.

Re: Warning: mysql_fetch_array(): supplied argument is not a...

Posted: Mon Mar 23, 2009 12:38 pm
by jayshields
Check the debugging help mentioned viewtopic.php?f=1&t=97460&p=528502#p528502

Re: Warning: mysql_fetch_array(): supplied argument is not a...

Posted: Mon Mar 23, 2009 12:56 pm
by FusionSarson
We've been taught nothing, it's all like looking at a language ive never seen before to me. it's only part of our assignment if we need it to be...my idea requires it as do most people are coming up with. Some pointers however annoying would be hugely appreciated, rather than pointed towards massively confusing manual, sorry to be a dumb ass.

Re: Warning: mysql_fetch_array(): supplied argument is not a...

Posted: Mon Mar 23, 2009 1:33 pm
by califdon
In your first post, you said "Any help will be great" and that "We've been taught nothing", but when someone points you specifically to the page that explains how to answer your question (and it doesn't happen to be a manual, so I must assume that you didn't even look at it), you aren't satisfied. I'm really not sure how to help you.

Re: Warning: mysql_fetch_array(): supplied argument is not a...

Posted: Mon Mar 23, 2009 4:33 pm
by jayshields
I agree with what califdon said. We also have a sticky thread in the Databases forum about debugging MySQL viewtopic.php?f=2&t=17096