Jump to content

Error Message


Ameslee

Recommended Posts

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
[code]
<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>");

                }
                ?>
[/code]

[b]EDIT BY OBER: PLEASE USE CODE TAGS WHEN POSTING CODE AND THINK ABOUT WHERE YOU ARE POSTING.[/b]
Link to comment
https://forums.phpfreaks.com/topic/7914-error-message/
Share on other sites

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.
Link to comment
https://forums.phpfreaks.com/topic/7914-error-message/#findComment-28944
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.