mysql_num_rows() expects parameter 1 to be resource

Hi

I’m getting this error on all my codes.

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘and Distance=‘Classic’’ at line 1
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/content/75/9075675/html/tables/Hrp_Sires.php on line 268

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/content/75/9075675/html/tables/Hrp_Sires.php on line 271
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘and Distance=‘Classic’’ at line 1

This is my website url where I’m getting the error

http://hrpinfo.net/tables/Hrp_Sires.php?multipleFilter=1&Bloodline=&Distance=Classic&Surface=&desc=&asc=

I’d post the code , but I dont know what the php warning button means.

Thank you for any help

I hope this works

[php][/php]<?php
include(“connection.php”);
?>

Race | Entry .subMenu { min-width:100px; padding:10px; min-height:50px; border:1px solid; position:absolute; background-color:#FFF; border:1px solid #000; display:none; color:#000; } .subMenu a { display:block; text-decoration:none; color:#333; font-weight:bold; font-style:italic; }


Bloodline
<?php
  $result1=mysql_query(" select Bloodline from Jos_HrpSires   group by Bloodline ");
  echo(mysql_error());
  ?>
          <select name="Bloodline" id="Bloodline" onchange="">
            <option value="">All</option>
        <?php

while($rows1=mysql_fetch_array($result1))
{
?>
<option <?php if((isset($_GET['multipleFilter'])) && ($_GET['Bloodline']==$rows1['Bloodline'])){echo('selected="selected"');} ?> value="<?php echo($rows1['Bloodline']); ?>">
<?php echo($rows1['Bloodline']); ?>

<?php
}
?>


Distance

<?php
  $result1=mysql_query("select Distance from Jos_HrpSires   group by Distance ");
  echo(mysql_error());
  ?>
          <select name="Distance" id="Distance" onchange="">
            <option value="">All</option>
        <?php

while($rows1=mysql_fetch_array($result1))
{
?>
<option <?php if((isset($_GET['multipleFilter'])) && ($_GET['Distance']==$rows1['Distance'])){echo('selected="selected"');} ?> value="<?php echo($rows1['Distance']); ?>">
<?php echo($rows1['Distance']); ?>

<?php
}
?>



Surface

<?php
  $result1=mysql_query("select Surface from Jos_HrpSires   group by Surface ");
  echo(mysql_error());
  ?>
          <select name="Surface" id="Distance" onchange="">
            <option value="">All</option>
        <?php

while($rows1=mysql_fetch_array($result1))
{
?>
<option <?php if((isset($_GET['multipleFilter'])) && ($_GET['Surface']==$rows1['Surface'])){echo('selected="selected"');} ?> value="<?php echo($rows1['Surface']); ?>">
<?php echo($rows1['Surface']); ?>

<?php
}
?>



Sort High to Low
        <select  name="desc" onchange="if(this.value!=''){document.getElementById('asc').style.display='none';}else{document.getElementById('asc').style.display='block';}">
          <option  value="">Select Field</option>
          <option <?php if((isset($_GET['multipleFilter'])) && ($_GET['desc']=="Winners")){echo('selected="selected"');} ?> value="Winners">Winners</option>
          <option <?php if((isset($_GET['multipleFilter'])) && ($_GET['desc']=="StakesWinners")){echo('selected="selected"');} ?>  value="StakesWinners">StakesWinners</option>
          <option <?php if((isset($_GET['multipleFilter'])) && ($_GET['desc']=="GradedStakesWinners")){echo('selected="selected"');} ?>  value="GradedStakesWinners">GradedStakesWinners</option>
          <option <?php if((isset($_GET['AvgWinningDistance'])) && ($_GET['desc']=="AvgWinningDistance")){echo('selected="selected"');} ?>  value="AvgWinningDistance">AvgWinningDistance</option>
          <option <?php if((isset($_GET['TurfToDirt'])) && ($_GET['desc']=="TurfToDirt")){echo('selected="selected"');} ?>  value="TurfToDirt">TurfToDirt</option>
        </select><br />
        </span>
        </td>
        <td>
        <span  id="asc">
        Sort Low to High<br />
        <select name="asc" onchange="if(this.value!=''){document.getElementById('desc').style.display='none';}else{document.getElementById('desc').style.display='block';}">
          <option value="">Select Field</option>
          <option <?php if((isset($_GET['multipleFilter'])) && ($_GET['asc']=="Winners")){echo('selected="selected"');} ?> value="Winners">Winners</option>
          <option <?php if((isset($_GET['multipleFilter'])) && ($_GET['asc']=="StakesWinners")){echo('selected="selected"');} ?>  value="StakesWinners">StakesWinners</option>
          <option <?php if((isset($_GET['multipleFilter'])) && ($_GET['asc']=="GradedStakesWinners")){echo('selected="selected"');} ?>  value="GradedStakesWinners">GradedStakesWinners</option>
          <option <?php if((isset($_GET['AvgWinningDistance'])) && ($_GET['asc']=="AvgWinningDistance")){echo('selected="selected"');} ?>  value="AvgWinningDistance">AvgWinningDistance</option>
          <option <?php if((isset($_GET['TurfToDirt'])) && ($_GET['asc']=="TurfToDirt")){echo('selected="selected"');} ?>  value="TurfToDirt">TurfToDirt</option>
        </select><br />
        </span>
        
        </td>
        
        </tr>
        <tr>
          <td colspan="5" align="center">
            <input type="submit" value="Search" />
            </td>
        </tr>
        </table>
<?php

$orderByStatement="";
$condition="";
$totalConditions="";
if(isset($_GET[‘sort’]))
{
$orderByStatement=“order by “.$_GET[‘field’].” “.$_GET[‘sort’];
}
if(isset($_GET[‘filter’]))
{
$condition=“where “.$_GET[‘field’].”=’”.$_GET[‘filter’].”’”;
}
else if(isset($_GET[‘startDate’]))
{
$condition=“and DATE_FORMAT(RaceDate, ‘%m/%d/%Y’) between '”.$_GET[‘startDate’]."’ AND ‘".$_GET[‘endDate’]."’";
}
else if(isset($_GET[‘multipleFilter’]))
{$condition="where ";
$i=0;

foreach ($_GET as $k => $v) 

{   $i++;

if($v!="")
  {
    if(($i>1) && ($k!="asc") && ($k!="desc") && ($k!="index") && ($k!="multipleFilter"))
    {
       if(isset($_GET['index']))
       {$j=3;}
       else
       {
         $j=2;
       }
       $totalConditions++;
      if($i==$j)
      {
        $condition.=$k."='".$v."'";
      }
      else
      {
        $condition.=" and ".$k."='".$v."'";
      }
    }
  }
  
}
// end for each loop

if($totalConditions<1)
{
  $condition="";  
}
if(isset($_GET['desc']) && ($_GET['desc']!=""))
{
  $orderByStatement="order by  ABS(".$_GET['desc'].") desc";  
}
else if(isset($_GET['asc']) && ($_GET['asc']!=""))
{
  $orderByStatement="order by  ABS(".$_GET['asc'].") asc";  
}

}
$perPageRecord=100;
if(!isset($_GET[‘index’]))
{
$index=0;
}
else
{
$index=$_GET[‘index’];
}

$result=mysql_query("SELECT * from Jos_HrpSires  $condition $orderByStatement  ");

$result1=mysql_query(“SELECT * from Jos_HrpSires $condition”);
echo(mysql_error());
$numberOfRecords=mysql_num_rows($result1);
$totalPages=ceil($numberOfRecords/$perPageRecord);

while($rows=mysql_fetch_array($result))
{
?>

<?php  

}
echo(mysql_error());
?>

Horse
</td>
<td>Bloodline
  </td>
<td>Distance

</td>
<td>Surface
  
   
</td>
<td>Winners
  
    </div>
    
</td>
<td>Stakes Winners

</td>
<td>
Graded Stakes Winners

</td>
<td>Avg Winning Distance

</td>
<td>Turf To Dirt

</td>
<?php echo($rows['Horse']); ?> <?php echo($rows['Bloodline']); ?> <?php echo($rows['Distance']); ?> <?php echo($rows['Surface']); ?> <?php echo($rows['Winners']); ?>% <?php echo($rows['StakesWinners']); ?>% <?php echo($rows['GradedStakesWinners']); ?>% <?php echo($rows['AvgWinningDistance']); ?>% <?php echo($rows['TurfToDirt']); ?>%
Pages: <?php for($i=1; $i<=$totalPages; $i++) { ?> value="index=<?php echo(($i-1)); if(isset($_GET['multipleFilter'])){echo("&multipleFilter=".$_GET['multipleFilter']."&Bloodline=".$_GET['Bloodline']."&Distance=".$_GET['Distance']."&Surface=".$_GET['Surface']."&desc=".$_GET['desc']."&asc=".$_GET['asc']); } ?>"><?php echo($i); ?> <?php } ?>
​[php][/php]

[php]<?php
include(“connection.php”);
?>

Race | Entry .subMenu { min-width:100px; padding:10px; min-height:50px; border:1px solid; position:absolute; background-color:#FFF; border:1px solid #000; display:none; color:#000; } .subMenu a { display:block; text-decoration:none; color:#333; font-weight:bold; font-style:italic; }


Bloodline
<?php
  $result1=mysql_query(" select Bloodline from Jos_HrpSires   group by Bloodline ");
  echo(mysql_error());
  ?>
          <select name="Bloodline" id="Bloodline" onchange="">
            <option value="">All</option>
        <?php

while($rows1=mysql_fetch_array($result1))
{
?>
<option <?php if((isset($_GET['multipleFilter'])) && ($_GET['Bloodline']==$rows1['Bloodline'])){echo('selected="selected"');} ?> value="<?php echo($rows1['Bloodline']); ?>">
<?php echo($rows1['Bloodline']); ?>

<?php
}
?>


Distance

<?php
  $result1=mysql_query("select Distance from Jos_HrpSires   group by Distance ");
  echo(mysql_error());
  ?>
          <select name="Distance" id="Distance" onchange="">
            <option value="">All</option>
        <?php

while($rows1=mysql_fetch_array($result1))
{
?>
<option <?php if((isset($_GET['multipleFilter'])) && ($_GET['Distance']==$rows1['Distance'])){echo('selected="selected"');} ?> value="<?php echo($rows1['Distance']); ?>">
<?php echo($rows1['Distance']); ?>

<?php
}
?>



Surface

<?php
  $result1=mysql_query("select Surface from Jos_HrpSires   group by Surface ");
  echo(mysql_error());
  ?>
          <select name="Surface" id="Distance" onchange="">
            <option value="">All</option>
        <?php

while($rows1=mysql_fetch_array($result1))
{
?>
<option <?php if((isset($_GET['multipleFilter'])) && ($_GET['Surface']==$rows1['Surface'])){echo('selected="selected"');} ?> value="<?php echo($rows1['Surface']); ?>">
<?php echo($rows1['Surface']); ?>

<?php
}
?>



Sort High to Low
        <select  name="desc" onchange="if(this.value!=''){document.getElementById('asc').style.display='none';}else{document.getElementById('asc').style.display='block';}">
          <option  value="">Select Field</option>
          <option <?php if((isset($_GET['multipleFilter'])) && ($_GET['desc']=="Winners")){echo('selected="selected"');} ?> value="Winners">Winners</option>
          <option <?php if((isset($_GET['multipleFilter'])) && ($_GET['desc']=="StakesWinners")){echo('selected="selected"');} ?>  value="StakesWinners">StakesWinners</option>
          <option <?php if((isset($_GET['multipleFilter'])) && ($_GET['desc']=="GradedStakesWinners")){echo('selected="selected"');} ?>  value="GradedStakesWinners">GradedStakesWinners</option>
          <option <?php if((isset($_GET['AvgWinningDistance'])) && ($_GET['desc']=="AvgWinningDistance")){echo('selected="selected"');} ?>  value="AvgWinningDistance">AvgWinningDistance</option>
          <option <?php if((isset($_GET['TurfToDirt'])) && ($_GET['desc']=="TurfToDirt")){echo('selected="selected"');} ?>  value="TurfToDirt">TurfToDirt</option>
        </select><br />
        </span>
        </td>
        <td>
        <span  id="asc">
        Sort Low to High<br />
        <select name="asc" onchange="if(this.value!=''){document.getElementById('desc').style.display='none';}else{document.getElementById('desc').style.display='block';}">
          <option value="">Select Field</option>
          <option <?php if((isset($_GET['multipleFilter'])) && ($_GET['asc']=="Winners")){echo('selected="selected"');} ?> value="Winners">Winners</option>
          <option <?php if((isset($_GET['multipleFilter'])) && ($_GET['asc']=="StakesWinners")){echo('selected="selected"');} ?>  value="StakesWinners">StakesWinners</option>
          <option <?php if((isset($_GET['multipleFilter'])) && ($_GET['asc']=="GradedStakesWinners")){echo('selected="selected"');} ?>  value="GradedStakesWinners">GradedStakesWinners</option>
          <option <?php if((isset($_GET['AvgWinningDistance'])) && ($_GET['asc']=="AvgWinningDistance")){echo('selected="selected"');} ?>  value="AvgWinningDistance">AvgWinningDistance</option>
          <option <?php if((isset($_GET['TurfToDirt'])) && ($_GET['asc']=="TurfToDirt")){echo('selected="selected"');} ?>  value="TurfToDirt">TurfToDirt</option>
        </select><br />
        </span>
        
        </td>
        
        </tr>
        <tr>
          <td colspan="5" align="center">
            <input type="submit" value="Search" />
            </td>
        </tr>
        </table>
<?php

$orderByStatement="";
$condition="";
$totalConditions="";
if(isset($_GET[‘sort’]))
{
$orderByStatement=“order by “.$_GET[‘field’].” “.$_GET[‘sort’];
}
if(isset($_GET[‘filter’]))
{
$condition=“where “.$_GET[‘field’].”=’”.$_GET[‘filter’].”’”;
}
else if(isset($_GET[‘startDate’]))
{
$condition=“and DATE_FORMAT(RaceDate, ‘%m/%d/%Y’) between '”.$_GET[‘startDate’]."’ AND ‘".$_GET[‘endDate’]."’";
}
else if(isset($_GET[‘multipleFilter’]))
{$condition="where ";
$i=0;

foreach ($_GET as $k => $v) 

{   $i++;

if($v!="")
  {
    if(($i>1) && ($k!="asc") && ($k!="desc") && ($k!="index") && ($k!="multipleFilter"))
    {
       if(isset($_GET['index']))
       {$j=3;}
       else
       {
         $j=2;
       }
       $totalConditions++;
      if($i==$j)
      {
        $condition.=$k."='".$v."'";
      }
      else
      {
        $condition.=" and ".$k."='".$v."'";
      }
    }
  }
  
}
// end for each loop

if($totalConditions<1)
{
  $condition="";  
}
if(isset($_GET['desc']) && ($_GET['desc']!=""))
{
  $orderByStatement="order by  ABS(".$_GET['desc'].") desc";  
}
else if(isset($_GET['asc']) && ($_GET['asc']!=""))
{
  $orderByStatement="order by  ABS(".$_GET['asc'].") asc";  
}

}
$perPageRecord=100;
if(!isset($_GET[‘index’]))
{
$index=0;
}
else
{
$index=$_GET[‘index’];
}

$result=mysql_query("SELECT * from Jos_HrpSires  $condition $orderByStatement  ");

$result1=mysql_query(“SELECT * from Jos_HrpSires $condition”);
echo(mysql_error());
$numberOfRecords=mysql_num_rows($result1);
$totalPages=ceil($numberOfRecords/$perPageRecord);

while($rows=mysql_fetch_array($result))
{
?>

<?php  

}
echo(mysql_error());
?>

Horse
</td>
<td>Bloodline
  </td>
<td>Distance

</td>
<td>Surface
  
   
</td>
<td>Winners
  
    </div>
    
</td>
<td>Stakes Winners

</td>
<td>
Graded Stakes Winners

</td>
<td>Avg Winning Distance

</td>
<td>Turf To Dirt

</td>
<?php echo($rows['Horse']); ?> <?php echo($rows['Bloodline']); ?> <?php echo($rows['Distance']); ?> <?php echo($rows['Surface']); ?> <?php echo($rows['Winners']); ?>% <?php echo($rows['StakesWinners']); ?>% <?php echo($rows['GradedStakesWinners']); ?>% <?php echo($rows['AvgWinningDistance']); ?>% <?php echo($rows['TurfToDirt']); ?>%
Pages: <?php for($i=1; $i<=$totalPages; $i++) { ?> value="index=<?php echo(($i-1)); if(isset($_GET['multipleFilter'])){echo("&multipleFilter=".$_GET['multipleFilter']."&Bloodline=".$_GET['Bloodline']."&Distance=".$_GET['Distance']."&Surface=".$_GET['Surface']."&desc=".$_GET['desc']."&asc=".$_GET['asc']); } ?>"><?php echo($i); ?> <?php } ?>
​[/php]
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and Distance='Classic'' at line 1
I searched your document for the word classic, and I didn't find it. Could it be in your included file? It's telling you that you have a query that includes "and Distance='Classic'" and it doesn't like something you did there.
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/content/75/9075675/html/tables/Hrp_Sires.php on line 268

[php]$result1=mysql_query(“SELECT * from Jos_HrpSires $condition”);[/php]
^ This returns nothing, so $result1 takes the boolean value false. So future attempts to work with it and get the number of rows will not work (see below).
[php]$numberOfRecords=mysql_num_rows($result1);[/php]
You need to figure out how to handle situations where nothing comes back. What do you want to happen?

I need the column to filter the distance. The the distance column has 5 fields Classic,Route,Sprint.Heavy Sprint and Mile.

If I Filter all the columns in the table it works fine and I don’t get that error/

If I filter Bloodline by itself it also works, but if I try to filter Distance or Surface by themselves I get that error.

This is the url where I’m having the problem

http://hrpinfo.net/tables/Hrp_Sires.php

Thank you for the help

Sponsor our Newsletter | Privacy Policy | Terms of Service