Jump to content

Warning: mysql_num_rows() expects parameter 1 to be resource,


anton_1

Recommended Posts

This has been really annoying me for 2 hours now :(. I know its something silly

 

Database Structure

 

QuestionID int

Question VarChar

HelpDocument VarChar (Link)

 

Posting Code:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

  <head>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.5.3/jquery-ui.min.js"></script>

 

<script type="text/javascript" src="jquery.simpledialog/jquery.simpledialog.0.1.js"></script>

 

  <link rel="stylesheet" type="text/css" href="style.css" />

  <link rel="stylesheet" href="ui.datepicker.css" type="text/css" media="screen" />

    <link rel="stylesheet" href="jquery.simpledialog/simpledialog.css" type="text/css" media="screen" />

 

 

  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/

libs/jquery/1.3.0/jquery.min.js"></script>

<script type="text/javascript">

$(function()

{

$(".search_button").click(function()

{

var search_word = $("#search_box").val();

var dataString = 'search_word='+ search_word;

 

if(search_word=='')

{

}

else

{

$.ajax({

type: "GET",

url: "getHelpDocuments.php",

data: dataString,

cache: false,

beforeSend: function(html)

{

document.getElementById("insert_search").innerHTML = '';

$("#flash").show();

$("#searchword").show();

$(".searchword").html(search_word);

$("#flash").html('<img src="ajax-loader.gif" /> Loading Results...');

},

 

success: function(html){

$("#insert_search").show();

$("#insert_search").append(html);

$("#flash").hide();

}

 

});

 

}

return false;

});

});

</script>

 

    <style>

   

*{margin:0;padding:0;}

ol.update

{

list-style:none;

font-size:1.1em;

margin-top:20px

}

ol.update li

{

height:70px;

border-bottom:#dedede dashed 1px;

text-align:left;

}

ol.update li:first-child

{

border-top:#dedede dashed 1px;

height:70px;

text-align:left

}

   

   

    </style>

 

 

 

  </head>

  <body>

    <div id="AllContent">

   

    <div id="header">

    <br></br>

    <br></br>

 

    </div>

   

    <br></br>

   

    <div id="login">

   

 

    </div>

   

   

   

 

    <br></br>

    <br></br>

    <br></br>

    <br></br>

    <br></br>

    <br></br>

    <br></br>

   

 

    <div id="RequestAccess">

<form method="get" action="">

<input type="text" name="search" id="search_box" class='search_box'/>

<input type="submit" value="Search" class="search_button" />

</form>

 

<div id="searchword">

Search results for <span class="searchword"></span></div>

<div id="flash"></div>

<ol id="insert_search" class="update">

 

</ol>

 

</ul>

 

</div>

</div>

 

 

    </div>

   

 

 

 

   

   

   

   

   

   

    </div>

  </body>

</html>

 

 

PHP SCRIPT

 

<?php

 

 

if(isset($_GET['search_word']))

{

$search_word=$_GET['search_word'];

$search_word_new=mysql_escape_string($search_word);

$search_word_fix=str_replace(" ","%",$search_word_new);

$link = mysql_connect("localhost", "root", "");

mysql_select_db("blank", $link);

$sql=mysql_query("SELECT HelpDocument FROM Questions WHERE Question LIKE '%$search_word_fix%' ORDER BY Question DESC LIMIT 20", $link);

 

 

$count=mysql_num_rows($sql);

if($count > 0)

{

while($row=mysql_fetch_array($sql))

{

 

$msg=$row['Question'];

$bold_word='<b>'.$search_word.'</b>';

$final_msg = str_ireplace($search_word, $bold_word, $msg);

?>

 

<li><?php echo $final_msg; ?></li>

 

<?php

}

}

else

{

echo "<li>No Results</li>";

}

}

?>

 

 

getting this error Warning: mysql_num_rows() expects parameter 1 to be resource and it wont display the database fields after search

 

Any help is deeply appreciated

 

thanks

 

 

 

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.