Jump to content

Not a valid result in SQL?


Gregg

Recommended Posts

Thanks to "AndyB" for helping me in the last topic i have only one error left to fix!
On the "Who Winked At Me.php" i recive this error..

[code]Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in
/home/darkwate/public_html/datingsite/interestinme.php on line 10[/code]
"LINE 10" IS: $total1=mysql_num_rows($result1);

THE HEAD CODE IS:
[code]<?
include("cookie.php");
include("connect.php");

$resuser=mysql_query("select * from users where identity='$UsErCoOkIe'");
$rowuser=mysql_fetch_object($resuser);

  $sql1="select * from interest where loveid='$rowuser->userid' and time>=date_sub(sysdate(),interval $last) order by time desc";
  $result1=mysql_query($sql1,$db);
  $total1=mysql_num_rows($result1);
 
if(!$argv[1])
{
$pg = 1;
}
else
{
$pg = $argv[1];
}
if(!$pg)
{
$pg = 1;
}

$total=$total1;
$StartRow =  $PRODUCTSPERPAGE * ($pg-1);

$totalpages = (int) ($total / $PRODUCTSPERPAGE);
if(($total % $PRODUCTSPERPAGE)!=0)
$totalpages++;

$sql1 .= " LIMIT $StartRow,$PRODUCTSPERPAGE";
$result1=mysql_query($sql1,$db);
$totalrows = mysql_affected_rows();
?>[/code]

I checked the DB, and the user has 5 winks so it aint empy i know that!
I used the check error code and recived this message:
[code]Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in
/home/darkwate/public_html/datingsite/interestinme.php on line 10
Error: 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 ') order by time desc'
at line 1 with query select * from interest where loveid='36' and time>=date_sub(sysdate(),interval )
order by time desc[/code]
Link to comment
Share on other sites

While testing, it never hurts to have good error-trapping and get details of what went wrong and what made it go awry. Saves time in the end, so change:

[code]$result1=mysql_query($sql1,$db);[/code]

to:

[code]$result1=mysql_query($sql1,$db) or die("Error: ". mysql_error(). " with query ". $sql1);[/code]
Link to comment
Share on other sites

I did and it says:
[code]Error: 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 ') order by time desc' at line 1 with query select * from
interest where loveid='36' and time>=date_sub(sysdate(),interval ) order by time desc[/code]
Link to comment
Share on other sites

Well heres all the code maby you can see the error:
[code]<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top">&nbsp;</td>
</tr>
<tr>
<td height="20"><img src="images/line wink.gif" alt="who found you interesting" width="50" height="50"></td>
</tr>
</table></td>
</tr>
<tr>
<td valign="top" class="small_txt"><table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td class="big_txt" height="24" align=center valign="top"><br>
<font size="2"> <? echo $total1?> people have Winked at you in last
[color=red]<?
if($last=="15 day")
{
$last1="15 days";
}
if($last=="7 day")
{
$last1="7 days";
}
if($last=="1 month")
{
$last1="1 month";
}
if($last=="6 month")
{
$last1="6 months";
}

echo $last1?>[/color]
</font><br>
<br>
</td>
</tr>
        [color=red]    <?if($totalrows>0){?>[/color]
<tr>
<td><table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
                      <td width="98%" valign="bottom">&nbsp;</td>
                      <td width="1%" class="curve_top">&nbsp;</td>
                      <td width="1%" valign="bottom">&nbsp;</td>
                    </tr>
                    <tr>
<td colspan="3>
<table width="100%" border="0" cellspacing="0" cellpadding="0">[color=red]<?
for($i=0;$i<$totalrows;$i++)
{
$loverow=mysql_fetch_array($result1);
$userid=$loverow["userid"];

$query="select * from users where userid='$userid'";
$result=mysql_query($query,$db);
$rowuser=mysql_fetch_array($result);
$useridentity=$rowuser["identity"];

$sql1="select * from photo where username='$useridentity' and main='Y'";
$res1=mysql_query($sql1,$db);
$row1=mysql_fetch_array($res1);
if($row1["photo"])
$photo=$row1["photo"];
else
$photo="";

$PRODUCTIMAGES="photoimage/";

?>[/color]
                          <tr>
                            <td><table width="95%" border="0" cellspacing="0" cellpadding="0" align="center">
                                <tr>
                                  <td width="22%"><table width="99%" border="0" cellspacing="1" cellpadding="0">
                                      <tr>
                                        <td width="39%" align="center"><? if($photo)
{?>
                                            <a href="#" onClick="openWindow('<?echo $PRODUCTIMAGES.$photo?>')"> <img class=black_border name="<?$row1["quote"]?>" src=" <? echo $PRODUCTIMAGES.$photo?>" alt="<?$row1["quote"]?>" border=1 width=60 height=75 align=absmiddle></a>
                                            <?}
  else
{?>
                                            <img src="images/no_photo.jpg" alt="no photo" width="60" height="75">
                                            <?}?>
                                        </td>
                                      </tr>
                                      <tr>
                                        <td colspan="2" align="center" height="55"><a href="viewprofile.php?id=<? echo $rowuser["userid"]?>"> <img src="images/view_profile.jpg" alt="view photos" width="100" height="13" border="0"></a>
                                            <?if($photo){?>
                                            <a href="#" onClick="openpicWindow('<?echo $rowuser["identity"]?>')"> <img src="images/view_photos.jpg" alt="view photos" width="110" height="50" border="0"></a>
                                            <?}?>
                                        </td>
                                      </tr>
                                  </table></td>
                                  <td width="78%" valign="top"><table width="99%" border="0" cellspacing="0" cellpadding="0" align="center" class="border_main">
                                      <tr bgcolor="#FFE9E0">
                                        <td height="25" colspan="2" bgcolor="#E1E1E1" class="big_txt"><a href="viewprofile.php?id=<? echo $rowuser["userid"]?>" class="side"><font size="3"> <? echo $rowuser["identity"]?> </font></a> ,
                                          <?
            $birth=$rowuser["birthdate"];;
  $date=date("Y");
  $age=$date-$birth;

  echo $age?>
                                            <?if($rowuser["genderid"]%2==0)
echo Female;
else
echo Male;?>
                                        </td>
                                      </tr>
                                      <tr class="normal_txt">
                                        <td valign="top" width="46%"><table width="100%" border="0">
                                            <tr class="normal_txt">
                                              <td height="20" width="8%" valign="top"><font face="Webdings">4</font></td>
                                              <td height="20" width="92%" valign="top">Seeking
                                                a
                                                <? $country1=$rowuser["lookingfor"];
  $rescon=mysql_query("select * from lookingfor where id='$country1'",$db);
  $rowcon=mysql_fetch_object($rescon);  
  echo $rowcon->name?>
                                              </td>
                                            </tr>
                                            <tr class="normal_txt">
                                              <td height="20" width="8%" valign="top"><font face="Webdings">4</font></td>
                                              <td height="20" width="92%" valign="top"><? $country1=$rowuser["ethnicity"];
  $rescon=mysql_query("select * from ethnicity where id='$country1'",$db);
  $rowcon=mysql_fetch_object($rescon);  
  echo $rowcon->name?>
                                              </td>
                                            </tr>
                                            <tr class="normal_txt">
                                              <td height="20" width="8%" valign="top"><font face="Webdings">4</font></td>
                                              <td height="20" width="92%" valign="top"><? $country1=$rowuser["personality"];
  $rescon=mysql_query("select * from personality where id='$country1'",$db);
  $rowcon=mysql_fetch_object($rescon);  
  echo $rowcon->name?>
                                              </td>
                                            </tr>
                                            <tr class="normal_txt">
                                              <td height="20" width="8%" valign="top"><font face="Webdings">4</font></td>
                                              <td height="20" width="92%" valign="top"><? $country1=$rowuser["bodytype"];
  $rescon=mysql_query("select * from bodytype where id='$country1'",$db);
  $rowcon=mysql_fetch_object($rescon);  
  echo $rowcon->name?>
                                              </td>
                                            </tr>
                                        </table></td>
                                        <td valign="top" width="54%"><table width="100%" border="0">
                                            <tr class="normal_txt">
                                              <td height="20" width="7%" valign="top"><font face="Webdings">4</font></td>
                                              <td height="20" width="93%" valign="top"><? $country1=$rowuser["city"];
  $rescon=mysql_query("select * from city where id_city='$country1'",$db);
  $rowcon=mysql_fetch_object($rescon);  
  echo $rowcon->city_name.", "?>
                                                  <? $country1=$rowuser["state"];
  $rescon=mysql_query("select * from state where id_state='$country1'",$db);
  $rowcon=mysql_fetch_object($rescon);  
  echo $rowcon->state_name?>
                                              </td>
                                            </tr>
                                            <tr class="normal_txt">
                                              <td height="20" width="7%" valign="top"><font face="Webdings">4</font></td>
                                              <td height="20" width="93%" valign="top"><? $country1=$rowuser["marital_status"];
  $rescon=mysql_query("select * from maritalstatus where id='$country1'",$db);
  $rowcon=mysql_fetch_object($rescon);  
  echo $rowcon->name?>
                                              </td>
                                            </tr>
                                            <tr class="normal_txt">
                                              <td height="20" width="7%" valign="top"><font face="Webdings">4</font></td>
                                              <td height="20" width="93%" valign="top"><? $country1=$rowuser["livingsituation"];
  $rescon=mysql_query("select * from livingsituation where id='$country1'",$db);
  $rowcon=mysql_fetch_object($rescon);  
  echo $rowcon->name?>
                                              </td>
                                            </tr>
                                        </table></td>
                                      </tr>
                                  </table></td>
                                </tr>
                            </table></td>
                          </tr>
                          <?if($i<$totalrows-1){?>
                          <tr>
                            <td height="30"><hr color=#FFF0EA size="1">
                            </td>
                          </tr>
                          <?}}?>
                </table></td>
              </tr>
              <tr>
                <td width="98%" valign="top">&nbsp;</td>
                <td width="1%" class="curve_down">&nbsp;</td>
                <td width="1%" valign="top">&nbsp;</td>
              </tr>
            </table>
              <br>
          </td>
        </tr>
        <?}?>
      </table>
      <?if($totalpages>0){?>
      <table width="95%" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr>
          <td width="50%" height="48"><?
if($pg>1)
{
$PrevPageNo = $pg -1;
    ?>
              <div align="left" ><a href="interestinme.php?+<?php echo $PrevPageNo; ?>+&last=<?echo $last?>"> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">Previous</font></a></div>
            <? }?>
          </td>
          <td width="50%" height="48"><?
if($pg<$totalpages)
{
$NextPageNo = $pg + 1;
  ?>
              <div align="right"><a href="interestinme.php?+<?php echo $NextPageNo; ?>+&last=<?echo $last?>"> <font size="2">Next</font> </a></div>
            <?}?>
          </td>
        </tr>
      </table>
      <?}?>[/code]
Link to comment
Share on other sites

This is it, i am not shure where it went i belive this page was an error a long while back and i never fixed it:
[code]
<td class="big_txt" height="24" align=center valign="top"><br>
                                <font size="2"> <? echo $total1?> people have found you interesting in last
                                  <?
if($last=="15 day")
{
$last1="15 days";
}
if($last=="7 day")
{
$last1="7 days";
}
if($last=="1 month")
{
$last1="1 month";
}
if($last=="6 month")
{
$last1="6 months";
}

echo $last1?>
                                </font><br>
                                <br>                            </td>
                          </tr>
                          <?if($totalrows>0){?>
                          <tr>
                            <td><table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
                              <tr>
                                <td width="2%" valign="bottom">&nbsp;</td>
                                <td width="95%" class="curve_top">&nbsp;</td>
                                <td width="3%" valign="bottom">&nbsp;</td>
                              </tr>
                              <tr>
                                <td colspan="3>
                              <table width="100%" border="0" cellspacing="0" cellpadding="0"><?
for($i=0;$i<$totalrows;$i++)
{
$loverow=mysql_fetch_array($result1);
$userid=$loverow["userid"];

$query="select * from users where userid='$userid'";
$result=mysql_query($query,$db);
$rowuser=mysql_fetch_array($result);
$useridentity=$rowuser["identity"];

$sql1="select * from photo where username='$useridentity' and main='Y'";
$res1=mysql_query($sql1,$db);
$row1=mysql_fetch_array($res1);
if($row1["photo"])
$photo=$row1["photo"];
else
$photo="";

$PRODUCTIMAGES="photoimage/";

?>
                                                          <tr>
                                                            <td><table width="95%" border="0" cellspacing="0" cellpadding="0" align="center">
                                                                <tr>
                                                                  <td width="22%"><table width="99%" border="0" cellspacing="1" cellpadding="0">
                                                                      <tr>
                                                                        <td width="39%" align="center"><? if($photo)
{?>
                                                                            <a href="#" onClick="openWindow('<?echo $PRODUCTIMAGES.$photo?>')"> <img class=black_border name="<?$row1["quote"]?>" src=" <? echo $PRODUCTIMAGES.$photo?>" alt="<?$row1["quote"]?>" border=1 width=60 height=75 align=absmiddle></a>
                                                                            <?}
  else
{?>
                                                                            <img src="images/no_photo.jpg" alt="no photo" width="60" height="75">
                                                                            <?}?>                                                                        </td>
                                                                      </tr>
                                                                      <tr>
                                                                        <td colspan="2" align="center" height="55"><a href="viewprofile.php?id=<? echo $rowuser["userid"]?>"> <img src="images/view_profile.jpg" alt="view photos" width="100" height="13" border="0"></a>
                                                                            <?if($photo){?>
                                                                            <a href="#" onClick="openpicWindow('<?echo $rowuser["identity"]?>')"> <img src="images/view_photos.jpg" alt="view photos" width="101" height="13" border="0"></a>
                                                                            <?}?>                                                                        </td>
                                                                      </tr>
                                                                  </table></td>
                                                                  <td width="78%" valign="top"><table width="99%" border="0" cellspacing="0" cellpadding="0" align="center" class="border_main">
                                                                      <tr bgcolor="#FFE9E0">
                                                                        <td height="25" class="big_txt" colspan="2"><a href="viewprofile.php?id=<? echo $rowuser["userid"]?>" class="side"><font size="3"> <? echo $rowuser["identity"]?> </font></a> ,
                                                                          <?
            $birth=$rowuser["birthdate"];;
  $date=date("Y");
  $age=$date-$birth;

  echo $age?>
                                                                            <?if($rowuser["genderid"]%2==0)
echo Female;
else
echo Male;?>                                                                        </td>
                                                                      </tr>
                                                                      <tr class="normal_txt">
                                                                        <td valign="top" width="46%"><table width="100%" border="0">
                                                                            <tr class="normal_txt">
                                                                              <td height="20" width="8%" valign="top"><font face="Webdings">4</font></td>
                                                                              <td height="20" width="92%" valign="top">Seeking
                                                                                a
                                                                                <? $country1=$rowuser["lookingfor"];
  $rescon=mysql_query("select * from lookingfor where id='$country1'",$db);
  $rowcon=mysql_fetch_object($rescon);  
  echo $rowcon->name?>                                                                              </td>
                                                                            </tr>
                                                                            <tr class="normal_txt">
                                                                              <td height="20" width="8%" valign="top"><font face="Webdings">4</font></td>
                                                                              <td height="20" width="92%" valign="top"><? $country1=$rowuser["ethnicity"];
  $rescon=mysql_query("select * from ethnicity where id='$country1'",$db);
  $rowcon=mysql_fetch_object($rescon);  
  echo $rowcon->name?>                                                                              </td>
                                                                            </tr>
                                                                            <tr class="normal_txt">
                                                                              <td height="20" width="8%" valign="top"><font face="Webdings">4</font></td>
                                                                              <td height="20" width="92%" valign="top"><? $country1=$rowuser["personality"];
  $rescon=mysql_query("select * from personality where id='$country1'",$db);
  $rowcon=mysql_fetch_object($rescon);  
  echo $rowcon->name?>                                                                              </td>
                                                                            </tr>
                                                                            <tr class="normal_txt">
                                                                              <td height="20" width="8%" valign="top"><font face="Webdings">4</font></td>
                                                                              <td height="20" width="92%" valign="top"><? $country1=$rowuser["bodytype"];
  $rescon=mysql_query("select * from bodytype where id='$country1'",$db);
  $rowcon=mysql_fetch_object($rescon);  
  echo $rowcon->name?>                                                                              </td>
                                                                            </tr>
                                                                        </table></td>
                                                                        <td valign="top" width="54%"><table width="100%" border="0">
                                                                            <tr class="normal_txt">
                                                                              <td height="20" width="7%" valign="top"><font face="Webdings">4</font></td>
                                                                              <td height="20" width="93%" valign="top"><? $country1=$rowuser["city"];
  $rescon=mysql_query("select * from city where id_city='$country1'",$db);
  $rowcon=mysql_fetch_object($rescon);  
  echo $rowcon->city_name.", "?>
                                                                                  <? $country1=$rowuser["state"];
  $rescon=mysql_query("select * from state where id_state='$country1'",$db);
  $rowcon=mysql_fetch_object($rescon);  
  echo $rowcon->state_name?>                                                                              </td>
                                                                            </tr>
                                                                            <tr class="normal_txt">
                                                                              <td height="20" width="7%" valign="top"><font face="Webdings">4</font></td>
                                                                              <td height="20" width="93%" valign="top"><? $country1=$rowuser["marital_status"];
  $rescon=mysql_query("select * from maritalstatus where id='$country1'",$db);
  $rowcon=mysql_fetch_object($rescon);  
  echo $rowcon->name?>                                                                              </td>
                                                                            </tr>
                                                                            <tr class="normal_txt">
                                                                              <td height="20" width="7%" valign="top"><font face="Webdings">4</font></td>
                                                                              <td height="20" width="93%" valign="top"><? $country1=$rowuser["livingsituation"];
  $rescon=mysql_query("select * from livingsituation where id='$country1'",$db);
  $rowcon=mysql_fetch_object($rescon);  
  echo $rowcon->name?>                                                                              </td>
                                                                            </tr>
                                                                        </table></td>
                                                                      </tr>
                                                                  </table></td>
                                                                </tr>
                                                            </table></td>
                                                          </tr>
                                                          <?if($i<$totalrows-1){?>
                                                          <tr>
                                                            <td height="30"><hr color=#FFF0EA size="1">                                                            </td>
                                                          </tr>
                                                          <?}}?>
                            </table></td>[/code]

MOD EDIT: Use code tags
Link to comment
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.