Jump to content

Recommended Posts

Please deal with me for a moment as I try to explain what is occurring. 

 

I have created drop down menu that you choose a name and the php/MySQL will run multiple queries to display information regarding the chosen name. 

The query works great.  There is no problem with the query.

 

However when you leave the page, either by navigation or by X'ing out.  When you return there are two errors that pop up:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in

 

You can then use the drop down menu and choose a name and it all works great.

 

It is my belief that these errors occur due to how the query was written, as the two queries that have these errors both have math in them.

 

My question is, how do I block these errors from occurring when you return to the page?

 

Here is the query:

 

<?php

//Worst Regular Season Record

 

include_once('../other/functions.php');

       

$con = mysql_connect($hostname, $username, $password)

    OR DIE ('Unable to connect to database! Please try again later.');

    $db = mysql_select_db($dbname, $con);

 

$query = "SELECT win, loss, year, teamname FROM standings, owners WHERE owners.owner_id =

standings.owner_id AND win = (SELECT MIN(win) FROM standings) AND standings.owner_id = $thing ORDER

BY year";

$result = mysql_query($query);

$row = mysql_fetch_array($result);

 

@ mysql_data_seek($result, 0);

 

if(mysql_num_rows($result)>0) {

 

echo "<table CELLPADDING=5 border =1>";

echo "<tr>";

echo "<th align=center colspan=4 > Worst Regular Season Record </th>";

echo "</tr>";

 

while ($row = mysql_fetch_array($result)) {

echo "<tr>";

echo '<td align=center> In '.$row['year'].', the '.$row['teamname'].' had '.$row['win'].' wins, and '.$row['loss'].' losses.</td>';

echo "</tr>";

}

} else {

 

}

echo "</table>";

 

mysql_close($con);

?>

Link to comment
https://forums.phpfreaks.com/topic/236717-due-to-math-in-query-there-is-an-error/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.