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 9016447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:59:54+00:00 2026-06-16T03:59:54+00:00

Possible Duplicate: PHP: Notice: Undefined variable and Notice: Undefined index I did a search

  • 0

Possible Duplicate:
PHP: “Notice: Undefined variable” and “Notice: Undefined index”

I did a search engine with fields and the result is displayed on a different page. On the result page there is pagination, the problem is when i click next my query and field is undefined. I’m a newbie in php and i really need some help. oh, please please please

i don’t know if i had to type this because you’re experts out here but here it is anyway: the $query is the users input and the $field is the selected field

<?php
session_start();
require("config.php");
require("clean.php");

print "<body><h1>Jobs</h1>";

$query = $_GET['query'];
$field = $_GET['field'];

$rowsPerPage = 1;
$pageNum = 1;

if(isset($_GET['page'])) {
    $pageNum = clean($_GET['page']);
}

$offset = ($pageNum - 1) * $rowsPerPage;

$result = mysql_query("SELECT * FROM post WHERE upper($field) LIKE'%$query%'"."LIMIT $offset, $rowsPerPage") or die('Error, query failed'); 
while ($row=mysql_fetch_array($result, MYSQL_ASSOC)) {
        print "<li>";
        print "<b>{$row['CNAME']}</b><br />";
        print "{$row['CITY']}, ";
        print "{$row['PROV']} (";
        print "{$row['CNTRY']}) <br /><br />";
        print "<u>{$row['POS']}</u><br />";
        print "{$row['REQ']}<br /><br />";
        print "<i>{$row['CNO']}</i>";
        print "</li>";
}
print "<br />";

$query = "SELECT COUNT(*) AS numrows FROM POST WHERE upper($field) LIKE'%$query%'";
$result = mysql_query($query) or die('Error, query failed');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];
print "<HR><BR><CENTER>($numrows results found!)";
print "<BR><br>You are now in page $pageNum</CENTER>";

$maxPage = ceil($numrows/$rowsPerPage);

echo "<CENTER>Go to page : ";
for($page = 1; $page <= $maxPage; $page++) {
    echo "<a href='result7.php?page=$page'>$page</a> ";
}
$page=$page-1;

print "<br><br>Click <a href=\"home.php\">here </a> for new search";?>
  • 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-16T03:59:55+00:00Added an answer on June 16, 2026 at 3:59 am

    Remember, your page doesn’t know anything except what gets passed in the URL or POST. Your links to subsequent pages do not pass the $query or $field fields. You need to add those to the URL’s you are creating for each link:

    for($page = 1; $page <= $maxPage; $page++) {
        echo "<a href='result7.php?page=$page&field=$field_escaped&query=$something_escaped'>$page</a> ";
    }
    

    where $query_escaped and $field_escaped are URL encoded versions of the field and query values you want to pass to subsequent pages.

    Note that there are all sorts of security problems with this code; you are pretty much asking for an SQL exploit if this were to appear in public.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: PHP: “Notice: Undefined variable” and “Notice: Undefined index” This code shows warnings
Possible Duplicate: PHP: Notice: Undefined variable and Notice: Undefined index I know its basic
Possible Duplicate: PHP: Notice: Undefined variable and Notice: Undefined index I am just learning
Possible Duplicate: PHP: Notice: Undefined variable and Notice: Undefined index Reference - What does
Possible Duplicate: PHP: Notice: Undefined variable and Notice: Undefined index I want when I
Possible Duplicate: PHP: Notice: Undefined variable and Notice: Undefined index Okay, so I am
Possible Duplicate: PHP: Notice: Undefined variable and Notice: Undefined index In html code: <select
Possible Duplicate: PHP: Notice: Undefined variable and Notice: Undefined index I've created a form
Possible Duplicate: PHP: Notice: Undefined variable and Notice: Undefined index im trying to create
Possible Duplicate: PHP: Notice: Undefined variable and Notice: Undefined index if(isset($_POST['bul'])) { $marka1=$_POST['marka']; $model1=$_POST['model'];

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.