Reply to Re: php/mySQL search/mysql_num_rows() error

Your name:

Reply:


Posted by Chris on 06/12/06 21:53

Thanks,

The page will show, and I can get a result. However I now have other issues
with it. Apparently others have some of the same issues, such as duplicate
results, so I'm checking out those solutions around the Net. This search
code has apparently been available for quite a while, so may be based on an
earlier version of PHP. Also, it doesn't seem to have anything in the code
to make the results appear as a link (i.e. <a href>, etc.) so will have to
figure out where that goes.

Anyway, now I get an error in the search text box where the search
keyword(s) are supposed to be after you run the search. It says:

br /><b>Notice</b>: Undefined variable: q in
<b>c:\Inetpub\wwwroot\search.php</b> on line <b>85</b><br />

I thought it had to do with making it a 'sticky form', so the keyword will
stay in the box, but that perhaps this code was written when global
variables were on by default. The only place where the code refers to a $q
variable is in the form, and they also name the text box 'q'.

<form action="search.php" method="get" name="search">
<div align="center">
<input name="q" type="text" value=" <?php echo $q; ?> " size="15">
<input name="search" type="submit" value="Search">
</div>
</form>

So I tried to make it a sticky form using:

<input name="q" type="text" value=" <?php if (isset($_POST['q'])) echo
$_POST['q']; ?> " size="15">

But got the same error. Any thoughts on this?

Thaks


"J.O. Aho" <user@example.net> wrote in message
news:4f5ufoF1hfn4dU1@individual.net...
>
> I suggest you do a small change to your code
>
> //SQL queries uses single quotes to enclose strings
> $query = "SELECT * FROM links WHERE pageURL LIKE '%$trimm%' OR
> pageDesc LIKE '%$trimm%' OR pageTitle LIKE '%$trimm%' ORDER BY pageLink
> DESC" ;
> // Execute the query to get number of rows that contain search keywords
> $numresults = mysql_query($query);
> if($numresults) {
> //$numresults is a resource!!!
> $row_num_links_main = mysql_num_rows($numresults);
> } else {
> //$numresults is false
> echo "Query: $query<br>\n".mysql_errno().":
> ".mysql_error()."<br>\n";
> exit;
> }
>
> This way you see what is wrong with your query or if you have connection
> problems. When the page is finished, you may want to store this in a error
> log file instead of outputting it to the web page.
>
>
> //Aho

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация