Jump to content


Photo

Error Message


  • Please log in to reply
2 replies to this topic

#1 Ameslee

Ameslee
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts

Posted 20 April 2006 - 01:48 AM

Can anyone tell me why the code below is displaying this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/tafeamy/public_html/project/Klever Kids/display_events.php on line 113
<td><h1>Events Details</h1>
                 <table width=100% height=10% border=1 align=center cellpadding=0>
                        <tr> 
                        <td id=headings width=20% align=center>Event</div></td>
                        <td id=headings width=10% align=center>Date</div></td>
                        <td id=headings width=30% align=center>Cost</div></td>
                        <td id=headings width=15% align=center>Other Info</div></td>
                        <td id=headings width=15% align=center>Contact Person</div></td>
                        <td id=headings width=15% align=center>Contact Number</div></td>
                        <td id=headings width=15% align=center>Mobile</div></td>
                      </tr></table>
                <?php
                $hostname = localhost;
                $username = tafeamy_amy;
                $password = feathers;

                $conn = mysql_connect($hostname, $username, $password) or die(mysql_error());
                $connection = mysql_select_db("tafeamy_project", $conn);


                $query = "SELECT event, date, cost, otherinfo, contactperson, number, mobile FROM events";
                $mysql_result=mysql_query($query,$conn);

                while ($rows = mysql_fetch_array($mysql_result))
                {
                $event = $rows['event'];
                $date = $rows['date'];
                $cost = $rows['cost'];
                $otherinfo = $rows['otherinfo'];
                $contactperson = $rows['contactperson'];
                $number = $rows['number'];
                $mobile = $rows['mobile'];
                
                echo("<table width=100% border=0 cellpadding=0 cellspacing=0>
                      
                        <tr>
                        <td width=20%>$event</td>
                        <td width=25%>$date</td>
                        <td width=25%>$cost</td>
                        <td width=25%>$otherinfo</td>
                        <td width=25%>$contactperson</td>
                        <td width=25%>$number</td>
                        <td width=25%>$mobile</td>
                      </tr>
                    </table>");

                }
                ?>

EDIT BY OBER: PLEASE USE CODE TAGS WHEN POSTING CODE AND THINK ABOUT WHERE YOU ARE POSTING.

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 20 April 2006 - 12:47 PM

I have moved this thread to PHP Help.

The only reason that error occurs is if you have something wrong with your query. I suggest you run the query directly against the MySQL database (phpmyadmin or any of the MySQL tools) to see if it returns valid results. Also make sure that your connection works properly.

Also keep in mind that "date" is a very poor choice for a column name since it is a function name in PHP and is a datatype in many systems. "number" is also a relatively poor choice.

Info: PHP Manual


#3 Ameslee

Ameslee
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts

Posted 21 April 2006 - 03:14 AM

the thing is that the php was working on other pages and now it is not working on this one! so it is not my choice of names that isnt making it work.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users