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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
FusionSarson
Forum Newbie
Posts: 2
Joined: Mon Mar 23, 2009 12:24 pm

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

Post 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.
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

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

Post by jayshields »

Check the debugging help mentioned viewtopic.php?f=1&t=97460&p=528502#p528502
FusionSarson
Forum Newbie
Posts: 2
Joined: Mon Mar 23, 2009 12:24 pm

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

Post 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.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

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

Post 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.
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

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

Post 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
Post Reply