Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7909949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:40:01+00:00 2026-06-03T12:40:01+00:00

I get this syntax on the internet and modified some parts. I would like

  • 0

I get this syntax on the internet and modified some parts. I would like to locate/search records in a table. this syntax ended up as “Search Query not found” I can’t find the problem in this syntax. Can you give me a little help in finding errors? Here’s the syntax.

<?php  // Get the search variable from URL
if(!isset($_GET['q']))
die('Search Query not found'); 
$var = $_GET['q'];
$trimmed = trim($var); //trim whitespace from the stored variable

// rows to return
$limit=10;

// check for an empty string and display a message.
if ($trimmed == ""){
echo "<p>Please enter a search…</p>";
exit;
}

// check for a search parameter
if (!isset($var)){
echo "<p>We dont seem to have a search parameter!</p>";
exit;
}

//connect to your database ** EDIT REQUIRED HERE **
mysql_connect("localhost","user1","test123");

//specify database ** EDIT REQUIRED HERE **
mysql_select_db("inventory") or die("Unable to select database");
// Build SQL Query
$query = ("SELECT * FROM client WHERE account_name LIKE \"%$trimmed%\" or maintenance_type like \"%$trimmed%\" or ma_status like \"%$trimmed%\" ma_contract_start like \"%$trimmed%\" ma_contract_end like \"%$trimmed%\" ma_reference_no like \"%$trimmed%\" ORDER BY account_name DESC");

// EDIT HERE and specify your table and field names for the SQL query

$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);

// If we have no results, offer a google search as an alternative — this is optional

if ($numrows == 0)
{
echo "<h4>Results</h4>";
echo "<p>Sorry, your search: $trimmed returned zero results</p>";

// google
echo "<p><a href=\"http://www.google.com/search?q="
. $trimmed . "\" target=\"_blank\" title=\"Look up
" . $trimmed . " on Google\">Click here</a> to try the
search on google</p>";
}

// next determine if s has been passed to script, if not use ZERO (0) to Limit the output
if (empty($s)) {
$s=0;
}

// get results
$query = " limit $s,$limit";
$result = mysql_query($query) or die("Couldn’t execute query");

// display what the person searched for
echo "<p>You searched for: $var </p>";

// begin to show results set
echo "Results: <br/>";
$count = 1 + $s ;

// now you can display the results returned
while ($row= mysql_fetch_array($result)) {
$name = $row['account_name'];
$mtype = $row['maintenance_type'];
$status = $row['ma_status'];
$start = $row['ma_contract_start'];
$end = $row['ma_contract_end'];
$reference = $row['reference_no'];


echo "$count.> $name $mtype $status $start $end $reference <br/>" ;
$count++ ;
}

$currPage = (($s/$limit) + 1);

//break before paging
echo "<br />";

// next we need to do the links to other results
if ($s>=1) {

// bypass PREV link if s is 0
$prevs=($s-$limit);
print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><<
Prev 10</a>  ";
}

// calculate number of pages needing links
$pages=intval($numrows/$limit);

// $pages now contains int of pages needed unless there is a remainder from division

if ($numrows%$limit) {
// has remainder so add one page
$pages++;
}

// check to see if last page
if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {

// not last page so give NEXT link
$news=$s+$limit;

echo " <a href=\"$PHP_SELF?s=$news&q=$var\">Next 10 >></a>";
}

$a = $s + ($limit) ;
if ($a > $numrows) { $a = $numrows ; }
$b = $s + 1 ;
echo "<p>Showing results $b to $a of $numrows</p>";

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T12:40:05+00:00Added an answer on June 3, 2026 at 12:40 pm

    You have mentioned you are getting this error “Search Query not found”. The code you have written clearly tells the parameter ‘q’ is not set in the url.

    if(!isset($_GET['q']))
     die('Search Query not found'); 
    

    If this has to work, your url should be

    www.example.com?q=some_value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a simple batch file and i get this The syntax of
See also SO 1664677 I get this error 2: Syntax error: ( unexpected when
I get this error:- You have an error in your SQL syntax; check the
I get this error when I run the application Incorrect syntax near 12 ,
What is the syntax to get this bit of jQuery to call when say,
Why do I get this error? Syntax error(s) [line 3:63 missing EOF at 'select']
This is my statement Why I get those errors Incorrect syntax near the keyword
Cannot get this statement to update the table and am almost certain my problem
I get this syntax error with my code - I've tried putting the quotes
I'm trying to get the script below to produce a shortcut like this: C:\Program

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.