[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Search results display

Posted on 2009-12-29
11
Medium Priority
?
357 Views
Last Modified: 2013-12-13
I have a dynamiic site which allows user to search my databse. Everything worked well untill today. When there are multilple results pages involved, the first page displays correctly, showing how many records and how many pages, like:
FIRST PREV ( Page 1 of 37, Records 1 to 15 of 545) NEXT LAST

When I click the NEXT button to move onto results page two, nothing comes out. I can see the parameters are being passed on like this:
http://www.otoodle.com/r101.php?Pageno=2&searchterm=wipes&Radius=7000&Destination=95050
But in the results area it says:
FIRST PREV ( Page 1 of 0, Records 16 to 0 of 0) NEXT LAST

If I click the NEXT button again, the it becomes:
http://www.otoodle.com/r101.php?pageno=2&searchterm=&Radius=7000&Destination=95050
So it does not turn to page three, but stay on page two, and the searchterm is no being passed on this time, while the Radius and Destination are.

When I keep clicking the NEXT button all the way to the last page 37, the browser shows:
http://www.otoodle.com/r101.php?pageno=0&&searchterm=&Radius=7000&Destination=95050

However, if I click the LAST button in resuts page one, which displays everything correctly, I get:
http://www.otoodle.com/r101.php?pageno=37&&searchterm=wipes&Radius=7000&Destination=95050
Parematers are passed on, just no records show up in the table for showing records, but:
FIRST PREV ( Page 1 of 0, Records 541 to 0 of 0) NEXT LAST

I haven't made any changes recently. It all worked fine until today. I asked my hosting company any changes on their end. Answer is no. So I am at a loss now. Any ideas or suggestions on how to fix it are greatly appreciated. Below is the code.
<?php
ini_set("memory_limit","256M");
require_once('zipcode.php');      // zip code class
require_once('highlight.php');

include("config.php");
mysql_query("SET character_set_results='utf8'");
$Radius = trim($_REQUEST['Radius']);
$Destination = mysql_real_escape_string($_REQUEST['Destination']);


$second_search=mysql_real_escape_string($_POST['second_search']);
if($second_search){
$search_term = $second_search;
$searchterm = $search_term;
}else{
$search_term = mysql_real_escape_string($_POST['searchterm']);
}

$keywords =explode(" ",$searchterm);
$colors[0]='#00CCFF';
$html_text=$searchterm;

if (isset($_REQUEST['pageno'])) {
   $pageno = $_REQUEST['pageno'];
} else {
   $pageno = 1;
} // if

$zip=mysql_real_escape_string($_REQUEST['Destination']);

if ($zip !='' && is_numeric($zip) ){

$sql5 = "select * from zip_code where $zip=zip_code"; 
$result5 = mysql_query($sql5) or die (mysql_error());  
$query_data = mysql_fetch_row($result5);
$numrows = $query_data[0];
          
if ($numrows ==!1){
echo "<p><font size=\"4px\" face=\"Times New Roman\" color=\"#FF0000\"><b>Please go back and enter a valid 5-digit US Zip Code!</b></font></p>";
exit;
}
}
else {
echo "<p><font size=\"4px\" face=\"Times New Roman\" color=\"#FF0000\"><b>Please go back and enter a valid 5-digit US Zip Code!</b></font></p>";
exit;
}

$z = new zipcode_class;

$zips = $z->get_zips_in_range($Destination, $Radius, _ZIPS_SORT_BY_DISTANCE_ASC, true); 
$zipcodes = array_keys($zips); // this fetches all the zip codes in the $zips variable 
$zip1 = implode("','",$zipcodes);  

$sql5 = "select count(*) from Suppliers, test where Suppliers.Zip in ('.$zip1.') AND MATCH (test.Description,test.Primary_Category,test.Secondary_Category,test.Tertiary_Category,test.Quaternary_Category) AGAINST ('$searchterm') AND test.SID = Suppliers.SID"; 
$result5 = mysql_query($sql5) or die (mysql_error());  
$query_data = mysql_fetch_row($result5);
$numrows = $query_data[0];


$rows_per_page = 15;
$lastpage      = ceil($numrows/$rows_per_page);
$startrow = ($pageno - 1)*$rows_per_page;
$startrow2 = $startrow + 1;
$startrow3 = $startrow + $rows_per_page;
$pageno = (int)$pageno;
if ($pageno > $lastpage) {
   $pageno = $lastpage;
} // if
if ($pageno < 1) {
   $pageno = 1;
} // if
$limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page;

// Below is an example of how to calculate the distance between two zip codes.

$sql = "select * from Suppliers, test where Suppliers.Zip in ('.$zip1.') AND MATCH (test.Description,test.Primary_Category,test.Secondary_Category,test.Tertiary_Category,test.Quaternary_Category) AGAINST ('$searchterm') AND test.SID = Suppliers.SID $limit"; 
$result = mysql_query($sql) or die (mysql_error());  
$num_rows = mysql_num_rows($result);  

$row = mysql_fetch_assoc($result);
@mysql_data_seek($result,0);
if ($pageno == 1) {
   echo " FIRST PREV ";
} else {
   echo " <a href='{$_SERVER['PHP_SELF']}?pageno=1&searchterm=$searchterm&Radius=$Radius&Destination=$Destination'>FIRST</a> ";
   $prevpage = $pageno-1;
   echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage&searchterm=$searchterm&Radius=$Radius&Destination=$Destination'>PREV</a> ";
} // if

echo " ( Page $pageno of $lastpage, ";
echo " Records $startrow2 to ";
echo min($startrow3, $numrows);
echo " of $numrows) ";
if ($pageno == $lastpage) {
   echo " NEXT LAST ";
} else {
   $nextpage = $pageno+1;
   echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage&searchterm=$searchterm&Radius=$Radius&Destination=$Destination'>NEXT</a> ";
   echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$lastpage&&searchterm=$searchterm&Radius=$Radius&Destination=$Destination'>LAST</a> ";
} // if
            
          if($numrows == 0) {  
               echo "Sorry. No records found. Please refine your creteria by including more details. If problem persists, please contact us.";  
          }  
          else {  

echo "<table border='0'>
<tr>
<th></th>
<th></th>
<th></th>
</tr>";

echo "<td align='left'><form name=form2 action='r101.php' method='POST'>
Search&nbsp;<input type='text' name='second_search' id='second_search' value='$searchterm' class='input'>&nbsp;within&nbsp;";
echo "<select name='Radius' id='Radius' class='input'>
        <option value='50'>50</option>
        <option value='100'>100</option>
        <option value='150'>150</option>
        <option value='200'>200</option>
        <option value='250'>250</option>
        <option value='300'>300</option>
        <option value='7000' selected='selected'>any</option>
      </select>"; 
echo "&nbspmiles from Zip Code (5-digit)&nbsp;";
echo "<input name='Destination' type='text' id='Destination' size='10' class='input' />&nbsp;&nbsp";
echo "<input type='submit'  value='Find'>";
echo "</form><td>";

echo "<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";

echo "<td aligh='right'><form action='r200.php' method='POST'>
<input type='hidden' name='second_search' id='second_search' value='$searchterm'>
<input type='submit' class='style10' value='Visit the Knowledge Center for tips on selecting right $searchterm '>
</form></td></table>";

echo "<table border='1'>
<tr>
<th>Product Photo</th>
<th>Product Information</th>
<th>Supplier Information</th>
<th>Contact Information</th>
</tr>";

 
while($myrow = mysql_fetch_array($result))
  {
  $zipcode = $myrow['Zip'];  
  $miles = $zips[$zipcode]; // return the value for key with the zip code in it. 
   
  echo "<tr>";
  echo "<td><a onclick=\"DescriptionWin(this); return false;\" href=\"" . $myrow["Photo_URL"] . "\"> <img src=\"" . $myrow["Photo_URL"] . "\" border=0 height=150 width=150 alt=\"" . $myrow["Photo_URL"] . "\"></a></td>";
  echo "<td><br /><b>Brief Description: </b>".highlight_search($keywords,'<span>'.$myrow['Description'].'</span>',$colors)."<br />";
  echo "<br /><b>Supplier Product Code: </b>".$myrow['Supplier_Product_Code']."<br />";
  echo "<br />"."<a onclick=\"DescriptionWin(this); return false;\" href=\"" .$myrow['Page_URL']. "\">" . "<b>Click here for more specifications</b>" . "</a>"."<br />"."</td>";
  echo "<td><br /><b>Supplier Name: </b>" . $myrow['Supplier_Name']."<br />";
  echo "<br /><b>Address: </b>".$myrow['Address']."<br />"; 
  echo "<br /><b>Distance: </b>".$miles ." miles"."<br />". "</td>";   
  echo "<td><b><br /> Tollfree: </b>".$myrow['Tollfree']."<br />";
  echo "<br /><b>Local: </b>".$myrow['Phone']."<br />";
  echo "<br /><b>Fax: </b>".$myrow['Fax']."<br />";
  echo "<br /><b>E-mail: </b>"."<a href=mailto:" . $myrow['Email'] . ">" . $myrow['Email']."<br />"."</td>";
  echo "</tr>";  
 }

echo "</table>";
}  

?>

Open in new window

0
Comment
Question by:nnrsc
  • 6
  • 5
11 Comments
 

Author Comment

by:nnrsc
ID: 26141429
Plus, I have this erro log:
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20060613/uploadprogress.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20060613/uploadprogress.so: cannot open shared object file: No such file or directory in Unknown on line 0
0
 

Author Comment

by:nnrsc
ID: 26145028
Maybe it is holidays. Haven't seen any replies yet. Here is the error message I get for page two where errors occurs:
Warning: mysql_data_seek() [function.mysql-data-seek]: Offset 0 is invalid for MySQL result index 9 (or the query data is unbuffered) in /home1/.../r101.php on line 82

Line 82 says: @mysql_data_seek($result,0);

I removed the @ to see the error message. Put it back. Still same thing. Results displayed well on page one, from page two and on, no records.

Would anybody take a look at what's wrong?
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 26145085
Can you store the SQL statements you are executing?

Then run them manually via phpMyAdmin (or similar).

See if the query itself is off.

The 2 lines ...

$row = mysql_fetch_assoc($result);
@mysql_data_seek($result,0);


seem completely redundant.

You don't use $row anywhere. So, if you don't fetch the row, you don't need to call mysql_data_seek().

Try commenting out those two lines.



Also, you use mysql_fetch_array() in the while loop to iterate the results. You could use mysql_fetch_assoc().
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 40

Expert Comment

by:Richard Quadling
ID: 26145141
With regard to the uploadprogressbar.so, the error message is pretty self explanatory.

If this error only started in the last few days, go back to your ISP and ask them if they've moved your account to a different server or did some cleaning up with regard to the /usr directory.

0
 

Author Comment

by:nnrsc
ID: 26145220
Thanks for the reply. I commented out the two lines and switched to mysql_fetch_assoc(). Still same situation.

For the uploadprogress.so warning message, I will ask my hosting company again.
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 26145397
Must be a different line number ... and a different error.

Can you add to the top of the script ...

<?php
error_reporting(-1); // Turn on ALL errors/warnings/notices.
ini_set('display_errors', 1); // Actually display all those errors/warnings/notices.
set_time_limit(0); // Allow the script to run forever, rather than the default 30 seconds.
// now your code...
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 26145430
Are you sure there actually is some data for the zip code you supplied?

I can't seem to generate the errors you are.

0
 

Author Comment

by:nnrsc
ID: 26145787
I added that part as suggested. I am sure there are data since in the first results page, everything shows up properly, with a count of 545 records in 37 pages. Here is what I did:

Log on to http://www.otoodle.com/
Choose "Cleaning and Sterilization" from the first drop-down box where it says "Select Main Category".
Choose "Wipes" at the very bottom of the second drop-down box where it say " Select sub Category".
Click the Product Search button which directs you to http://www.otoodle.com/r100.php
(Everything works perfect in here. Clicking the NEXT or PREV button takes you to each page with good data.)

Now in http://www.otoodle.com/r100.php, put a zip code 95050 in the box right before the Find button. It takes you to http://www.otoodle.com/r101.php
Things work good so far as well. But when click the NEXT button to move to page two, I get such messages for now:

Notice: Undefined index: second_search in /home1/nnsource/public_html/otoodle/r101.php on line 108

Notice: Undefined index: searchterm in /home1/nnsource/public_html/otoodle/r101.php on line 113

Notice: Undefined variable: searchterm in /home1/nnsource/public_html/otoodle/r101.php on line 116

Notice: Undefined variable: searchterm in /home1/nnsource/public_html/otoodle/r101.php on line 118

Notice: Undefined variable: searchterm in /home1/nnsource/public_html/otoodle/r101.php on line 151

Notice: Undefined variable: searchterm in /home1/nnsource/public_html/otoodle/r101.php on line 173

Warning: mysql_data_seek() [function.mysql-data-seek]: Offset 0 is invalid for MySQL result index 9 (or the query data is unbuffered) in /home1/nnsource/public_html/otoodle/r101.php on line 178
FIRST PREV ( Page 1 of 0, Records 16 to 0 of 0)
Notice: Undefined variable: searchterm in /home1/nnsource/public_html/otoodle/r101.php on line 195
NEXT
Notice: Undefined variable: searchterm in /home1/nnsource/public_html/otoodle/r101.php on line 196
LAST Sorry. No records found. Please refine your creteria by including more details. If problem persists, please contact us.

To make the lines consistent, I attached all the code below, including the HTML part which I took away before to save some lines.
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SourceBook, Your Assistant in Sourcing for Industrial Materials and Equipment</title>

<script>
function DescriptionWin(url){
	w = document.body.clientWidth;
	h = document.body.clientHeight;
 
	var popW = 600, popH = 400;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	var myPopup = window.open(url,"Description","height=" + popH + ",width=" + popW + ",top=" + topPos + ",left=" +leftPos + ",scrollbars=yes,resizable=no,toolbar=no,directory=no")
	myPopup.focus();
}
</script>

<style type="text/css">
<!--
.style20 {font-family: "book Antiqua";
	font-size: 36pt;
	color: #0033FF;
}
.style11 {
	font-family: "Bookman Old Style";
	font-weight: bold;
	font-size: 24pt;
}
.style23 {
	font-family: "Bookman Old Style";
	font-style: normal;
	font-size: 24px;
}
.style10 {font-family: "Times New Roman", Times, serif;
	font-size: 12pt;
}

.input {
    border: 1px solid #006;
    background: #ffc;
	background-color:#66FFFF;
}
.input:hover {
    border: 1px solid;
    background: url('/forms/down.png') no-repeat top left;
    padding: 2px 8px;

}
.button {
    border: 1px solid;
	border:#CCCCCC
    background: url('/forms/up.png') no-repeat top left;
    padding: 2px 8px;
	text-align:left;
	width: 500px;
}
.button:hover {
    border: 1px solid;
    background: url('/forms/down.png') no-repeat top left;
    padding: 2px 8px;
}
label {
    display: block;
    width: 150px;
    float: left;
    margin: 2px 4px 6px 4px;
    text-align: right;
}
br { clear: left; }

-->
</style>
<meta name="Keywords" content="Online sourcing tool that helps procurement and sourcing professional locate manufacturers and distributors of industrial materials and equipment within a radius of your destination, with detailed product descriptions and supplier contact info available together just by one click." />
<meta name="Description" content="Online sourcing tool that helps procurement and sourcing professional locate manufacturers and distributors of industrial materials and equipment within a radius of your destination, with detailed product descriptions and supplier contact info available together just by one click." />
<meta name="robots" content="Online sourcing tool that helps procurement and sourcing professional locate manufacturers and distributors of industrial materials and equipment within a radius of your destination, with detailed product descriptions and supplier contact info available together just by one click." />
</head>

<body>

  <div align="left">
    <p><span class="style20"><span class="style11">SourceBook</span></span> <span class="style23"><sup>&#8482</sup></span></p>
</div>
<label></label>
  <label></label>
  <div align="left"></div>
  <p align="right"><span class="style9"><a href="http://www.otoodle.com/">Home</a> | <a href="Company.html">Company</a> | <a href="Clients.html">Clients</a> |<a href="Investment_Opportunity.html"> Investors</a> <span class="style10">| <a href="rss.php">SourceBuzz</a></span> | <a href="Contact.html">Contact</a></span></p>
<p>&nbsp;</p>
</body>
</html>

<?php
error_reporting(-1); // Turn on ALL errors/warnings/notices.
ini_set('display_errors', 1); // Actually display all those errors/warnings/notices.
set_time_limit(0); // Allow the script to run forever, rather than the default 30 seconds.


ini_set("memory_limit","256M");
require_once('zipcode.php');      // zip code class
require_once('highlight.php');

include("config.php");
mysql_query("SET character_set_results='utf8'");
$Radius = trim($_REQUEST['Radius']);
$Destination = mysql_real_escape_string($_REQUEST['Destination']);


$second_search=mysql_real_escape_string($_POST['second_search']);
if($second_search){
$search_term = $second_search;
$searchterm = $search_term;
}else{
$search_term = mysql_real_escape_string($_POST['searchterm']);
}

$keywords =explode(" ",$searchterm);
$colors[0]='#00CCFF';
$html_text=$searchterm;

if (isset($_REQUEST['pageno'])) {
   $pageno = $_REQUEST['pageno'];
} else {
   $pageno = 1;
} // if

$zip=mysql_real_escape_string($_REQUEST['Destination']);

if ($zip !='' && is_numeric($zip) ){

$sql5 = "select * from zip_code where $zip=zip_code"; 
$result5 = mysql_query($sql5) or die (mysql_error());  
$query_data = mysql_fetch_row($result5);
$numrows = $query_data[0];
          
if ($numrows ==!1){
echo "<p><font size=\"4px\" face=\"Times New Roman\" color=\"#FF0000\"><b>Please go back and enter a valid 5-digit US Zip Code!</b></font></p>";
exit;
}
}
else {
echo "<p><font size=\"4px\" face=\"Times New Roman\" color=\"#FF0000\"><b>Please go back and enter a valid 5-digit US Zip Code!</b></font></p>";
exit;
}

$z = new zipcode_class;

$zips = $z->get_zips_in_range($Destination, $Radius, _ZIPS_SORT_BY_DISTANCE_ASC, true); 
$zipcodes = array_keys($zips); // this fetches all the zip codes in the $zips variable 
$zip1 = implode("','",$zipcodes);  

$sql5 = "select count(*) from Suppliers, test where Suppliers.Zip in ('.$zip1.') AND MATCH (test.Description,test.Primary_Category,test.Secondary_Category,test.Tertiary_Category,test.Quaternary_Category) AGAINST ('$searchterm') AND test.SID = Suppliers.SID"; 
$result5 = mysql_query($sql5) or die (mysql_error());  
$query_data = mysql_fetch_row($result5);
$numrows = $query_data[0];


$rows_per_page = 15;
$lastpage      = ceil($numrows/$rows_per_page);
$startrow = ($pageno - 1)*$rows_per_page;
$startrow2 = $startrow + 1;
$startrow3 = $startrow + $rows_per_page;
$pageno = (int)$pageno;
if ($pageno > $lastpage) {
   $pageno = $lastpage;
} // if
if ($pageno < 1) {
   $pageno = 1;
} // if
$limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page;

// Below is an example of how to calculate the distance between two zip codes.

$sql = "select * from Suppliers, test where Suppliers.Zip in ('.$zip1.') AND MATCH (test.Description,test.Primary_Category,test.Secondary_Category,test.Tertiary_Category,test.Quaternary_Category) AGAINST ('$searchterm') AND test.SID = Suppliers.SID $limit"; 
$result = mysql_query($sql) or die (mysql_error());  
$num_rows = mysql_num_rows($result);  

$row = mysql_fetch_assoc($result);
mysql_data_seek($result,0);
if ($pageno == 1) {
   echo " FIRST PREV ";
} else {
   echo " <a href='{$_SERVER['PHP_SELF']}?pageno=1&searchterm=$searchterm&Radius=$Radius&Destination=$Destination'>FIRST</a> ";
   $prevpage = $pageno-1;
   echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage&searchterm=$searchterm&Radius=$Radius&Destination=$Destination'>PREV</a> ";
} // if

echo " ( Page $pageno of $lastpage, ";
echo " Records $startrow2 to ";
echo min($startrow3, $numrows);
echo " of $numrows) ";
if ($pageno == $lastpage) {
   echo " NEXT LAST ";
} else {
   $nextpage = $pageno+1;
   echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage&searchterm=$searchterm&Radius=$Radius&Destination=$Destination'>NEXT</a> ";
   echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$lastpage&&searchterm=$searchterm&Radius=$Radius&Destination=$Destination'>LAST</a> ";
} // if
            
          if($numrows == 0) {  
               echo "Sorry. No records found. Please refine your creteria by including more details. If problem persists, please contact us.";  
          }  
          else {  

echo "<table border='0'>
<tr>
<th></th>
<th></th>
<th></th>
</tr>";

echo "<td align='left'><form name=form2 action='r101.php' method='POST'>
Search&nbsp;<input type='text' name='second_search' id='second_search' value='$searchterm' class='input'>&nbsp;within&nbsp;";
echo "<select name='Radius' id='Radius' class='input'>
        <option value='50'>50</option>
        <option value='100'>100</option>
        <option value='150'>150</option>
        <option value='200'>200</option>
        <option value='250'>250</option>
        <option value='300'>300</option>
        <option value='7000' selected='selected'>any</option>
      </select>"; 
echo "&nbspmiles from Zip Code (5-digit)&nbsp;";
echo "<input name='Destination' type='text' id='Destination' size='10' class='input' />&nbsp;&nbsp";
echo "<input type='submit'  value='Find'>";
echo "</form><td>";

echo "<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";

echo "<td aligh='right'><form action='r200.php' method='POST'>
<input type='hidden' name='second_search' id='second_search' value='$searchterm'>
<input type='submit' class='style10' value='Visit the Knowledge Center for tips on selecting right $searchterm '>
</form></td></table>";

echo "<table border='1'>
<tr>
<th>Product Photo</th>
<th>Product Information</th>
<th>Supplier Information</th>
<th>Contact Information</th>
</tr>";

 
while($myrow = mysql_fetch_array($result))
  {
  $zipcode = $myrow['Zip'];  
  $miles = $zips[$zipcode]; // return the value for key with the zip code in it. 
   
  echo "<tr>";
  echo "<td><a onclick=\"DescriptionWin(this); return false;\" href=\"" . $myrow["Photo_URL"] . "\"> <img src=\"" . $myrow["Photo_URL"] . "\" border=0 height=150 width=150 alt=\"" . $myrow["Photo_URL"] . "\"></a></td>";
  echo "<td><br /><b>Brief Description: </b>".highlight_search($keywords,'<span>'.$myrow['Description'].'</span>',$colors)."<br />";
  echo "<br /><b>Supplier Product Code: </b>".$myrow['Supplier_Product_Code']."<br />";
  echo "<br />"."<a onclick=\"DescriptionWin(this); return false;\" href=\"" .$myrow['Page_URL']. "\">" . "<b>Click here for more specifications</b>" . "</a>"."<br />"."</td>";
  echo "<td><br /><b>Supplier Name: </b>" . $myrow['Supplier_Name']."<br />";
  echo "<br /><b>Address: </b>".$myrow['Address']."<br />"; 
  echo "<br /><b>Distance: </b>".$miles ." miles"."<br />". "</td>";   
  echo "<td><b><br /> Tollfree: </b>".$myrow['Tollfree']."<br />";
  echo "<br /><b>Local: </b>".$myrow['Phone']."<br />";
  echo "<br /><b>Fax: </b>".$myrow['Fax']."<br />";
  echo "<br /><b>E-mail: </b>"."<a href=mailto:" . $myrow['Email'] . ">" . $myrow['Email']."<br />"."</td>";
  echo "</tr>";  
 }

echo "</table>";
}  

?>

Open in new window

0
 
LVL 40

Accepted Solution

by:
Richard Quadling earned 2000 total points
ID: 26146397
Unrelated ... you are missing some ; for &nbsp; on lines 222 and 223

echo "&nbsp;miles from Zip Code (5-digit)&nbsp;";
echo "<input name='Destination' type='text' id='Destination' size='10' class='input' />&nbsp;&nbsp;";






The notices are important. You are trying to access entries in the $_POST array which do not exist. So the value is undefined - Null.

You should protect yourself. I use the following function ...

/**
 * Returns the requested value from an array based upon the key
 * or the default value if the key does not exist
 *
 * @param   array  $a_Array is the array to examine.
 * @param   mixed  $m_Key is the key or array of nested keys to find in the array.
 * @param   mixed  $m_Default is the value to return if the key cannot be found.
 *
 * @return  mixed  contains the value from the array or the default value if it cannot be found.
 **/
function array_get(array $a_Array, $m_Key, $m_Default = Null) {
      if (is_array($m_Key)) {
            $m_Result = $a_Array;
            
            foreach($m_Key as $m_SingleKey) {
                  if ($m_Result === $m_Default) {
                        break;
                  }
                  $m_Result = array_get($m_Result, $m_SingleKey, $m_Default);
            }
            return $m_Result;
      } else {
            return (False !== $m_Key) && array_key_exists($m_Key, $a_Array) ? $a_Array[$m_Key] : $m_Default;
      }
}


So ...

$second_search = mysql_real_escape_string(array_get($_POST, 'second_search', ''));
if (False !== $second_search) { // Test for not False as empty string
//...


sort of thing
0
 

Author Closing Comment

by:nnrsc
ID: 31670968
Thanks for the suggestions. You did point me to the right direction. I doubled checked my files and found my form was not setup properly, so nothing passed on. It's all fixed not and the site works well now.
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 26152301
Glad to have helped.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month19 days, 15 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question