Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Can't figure it out. Please help
Old 12-18-2007, 12:06 PM Can't figure it out. Please help
Dale Hodge's Avatar
Skilled Talker

Posts: 63
Location: Syracuse, ny
Trades: 1
I have a problem with this script.

everything works great until I try to go to the next page.

This is when I get the following error:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/public_html/conference/admin/result.php on line 57
No Results Found!

Error, query failed.

Here is the code:

PHP Code:
<?
session_start
();
if(!
session_is_registered(myusername)){
header("location:index.php");
}
include(
"template_top.php");
include(
"connect.php");
$qsearch $_POST['qsearch'];
$search_results $_POST['qsearch'];
$search $_POST['search'];
$exact $_POST['exact'];
if (
$search_results == "lastname") {
$search_results "Last Name";
}
if (
$search_results == "requiredorganization") {
$search_results "Organization";
}


?>
<div id="content">
    <div id="colOne">
        <div class="post">
            <h2 class="title">Search Results <?php echo $search_results ?></h2>
   <h3 class="posted">

   </h3>
            <div class="story">
  <p></p>
<?php

$qProfile 
"SELECT * FROM options WHERE id='1'";
$rsProfile mysql_query($qProfile);
$row mysql_fetch_array($rsProfile);
extract($row);
$noa stripslashes($noa);
// how many rows to show per page
$rowsPerPage $noa;

// by default we show first page
$pageNum 1;

// if $_GET['page'] defined, use it as page number
if(isset($_GET['page']))
{
    
$pageNum $_GET['page'];
}

// counting the offset
$offset = ($pageNum 1) * $rowsPerPage;

if (
$exact) {
$query="SELECT * FROM application WHERE $qsearch LIKE '$search' ORDER BY
lastname ASC LIMIT 
$offset$rowsPerPage";
$action "WHERE $qsearch LIKE '$search'";
}
else {
$query="SELECT * FROM application WHERE $qsearch LIKE '%$search%' ORDER BY
lastname ASC LIMIT 
$offset$rowsPerPage";
$action "WHERE $qsearch LIKE '%$search%'";
}
$result=mysql_query($query);
$num mysql_num_rows ($result);

if (
$num ) {
$i=0;
while (
$i $num) {
$requiredname mysql_result($result,$i,"requiredname");
$lastname mysql_result($result,$i,"lastname");
$title mysql_result($result,$i,"title");
$requiredemail mysql_result($result,$i,"requiredemail");
$requiredorganization mysql_result($result,$i,"requiredorganization");
$address mysql_result($result,$i,"address");
$city mysql_result($result,$i,"city");
$state mysql_result($result,$i,"state");
$zip mysql_result($result,$i,"zip");
$phone mysql_result($result,$i,"phone");
$fax mysql_result($result,$i,"fax");
$nysid mysql_result($result,$i,"nysid");
$fdid mysql_result($result,$i,"fdid");
$price mysql_result($result,$i,"price");
$d mysql_result($result,$i,"d");
$total mysql_result($result,$i,"total");
$paydate mysql_result($result,$i,"paydate");
$comment mysql_result($result,$i,"comment");
$extra1 mysql_result($result,$i,"extra1");
$extra2 mysql_result($result,$i,"extra2");
$extra3 mysql_result($result,$i,"extra3");
$id mysql_result($result,$i,"id");
?>
<table border="0"  width="100%">
<tr>
   <td width="50%"><font color="#0000A0"><b>Last Name:</b></font></td>
  <td>

  <?
  
if ($search_results == "Last Name") {
  echo 
"" $tip search_highlight($search"<b><font style='color:white; background-color:blue;'>" $search "</font></b>"$lastname) . "";
  }
  else {
  echo 
$lastname;
  }
  
?>
 </td>
</tr>
<tr>
   <td width="50%"><font color="#0000A0"><b>First Name:</b></font></td>
  <td><?php echo $requiredname ?></td>
</tr>
<tr>
   <td width="50%"><font color="#0000A0"><b>Organization:</b></font></td>
  <td>
  <?
  
if ($search_results == "Organization") {
  echo 
"" $tip search_highlight($search"<b><font style='color:white; background-color:blue;'>" $search "</font></b>"$requiredorganization) . "";
  }
  else {
  echo 
$requiredorganization;
  }
  
?>
  </td>
</tr>
<tr>
  <td width="50%"><font color="#0000A0"><b>Date Payment Received:</b></font></td>
  <td><?php echo $paydate ?></td>
</tr>
</table>
<BR>
<?
echo "<center><a href=\"update.php?id=$id&referpage=result\">View/Update</a> - <a href=\"delete.php?id=$id\">Delete</a></center>";
echo 
"<BR><BR>";
echo 
"<h3 class=\"seperator\"></h3>";
echo 
"<br>";

++
$i; } } else { echo "<H3>No Results Found!</H3><br>"; }

$query   "SELECT COUNT(id) AS numrows FROM application $action";
$result  mysql_query($query) or die('Error, query failed');
$row     mysql_fetch_array($resultMYSQL_ASSOC);
$numrows $row['numrows'];
mysql_close();
if (
$numrows <=  $rowsPerPage) {
}
else {
// how many pages we have when using paging?
$maxPage ceil($numrows/$rowsPerPage);

$self $_SERVER['PHP_SELF'];

// creating 'previous' and 'next' link
// plus 'first page' and 'last page' link

// print 'previous' link only if we're not
// on page one
if ($pageNum 1)
{
    
$page $pageNum 1;
    
$prev " <a href=\"$self?page=$page\">[Prev]</a> ";

    
$first " <a href=\"$self?page=1\">[First]</a> ";
}
else
{
    
$prev  ' [Prev] ';       // we're on page one, don't enable 'previous' link
    
$first ' [First] '// nor 'first page' link
}

// print 'next' link only if we're not
// on the last page
if ($pageNum $maxPage)
{
    
$page $pageNum 1;
    
$next " <a href=\"$self?page=$page\">[Next]</a> ";

    
$last " <a href=\"$self?page=$maxPage\">[Last]</a> ";
}
else
{
    
$next ' [Next] ';      // we're on the last page, don't enable 'next' link
    
$last ' [Last] '// nor 'last page' link
}
echo 
$first $prev " Showing page <strong>$pageNum</strong> of <strong>$maxPage</strong> pages " $next $last "<br><br>";
}

function 
search_highlight($needle$replace$haystack)
{
 
$haystack eregi_replace($needle,$replace,$haystack);
 return 
$haystack;
}

include(
"template_bottom.php");
?>
Any help would be great, thanks
Dale Hodge is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-18-2007, 03:15 PM Re: Can't figure it out. Please help
solomongaby's Avatar
Webmaster Talker

Latest Blog Post:
How Do You Find Music Online ?
Posts: 522
Name: Gabe Solomon
Location: Romania
Trades: 1
it usualy means that you have an error in you're query and the result object hasnt been returned

try to do at the line the error is pointing something like :
$rsProfile = mysql_query($qProfile) or die ('MySQL Error:'.mysqlerror());
__________________
If you like my posts ... TK is appreciated:)

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
solomongaby is offline
Reply With Quote
View Public Profile Visit solomongaby's homepage!
 
Old 12-18-2007, 06:15 PM Re: Can't figure it out. Please help
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Another good tip is to print the queries to the page, after they have been fully put together. You probably have some minor logical error by the paging which gives you a limit claus like 'LIMIT -10, 20', or simular.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Reply     « Reply to Can't figure it out. Please help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.68687 seconds with 12 queries