Hi,
I have a small search button on a website which does a really basic search on the MySQL database. However, the form tags keep disappearing. This seems really strange. The search button should look like this:
I have never known something like this to happen before so don’t even know where to start in finding the problem. Has anyone had any experience of this before or know how to fix this problem???
And then all the other tags close at the bottom of the page.
Any ideas on this? It is so strange. If I open the page directly, so not as an include, using its actual address, the <form> tags appear as normal but when looking at it once its been included sometimes the <form> tags are there and sometimes they’re not, and there doesn’t seem to be any rhyme or reason to why this is!
I have error_reporting on but there are not any errors showing. Besides, I believe that the problem can’t be PHP related as although the pages are in php and the form is part of an include, all of the actual tags are written in PHP and I am using no PHP functions for this form.
To see this in action. The code is on two different pages.
The really strange thing is how they sometimes seem to work perfectly and other times not at all. For instance, the first time the page is visited and a search is done using the box on the right, quite often the script will work and the search will be done. However, if you try and do a search again on the next page, pretty much everytime I have tried it it will not work, and if you look at that script you will see that the <form> tags have disappeared. Plus, the Bramcote Bulbs site seems to work the majority of the time, with just occasionally this happening. I have looked at both scripts in minute detail and they are identical so I just can’t work out how this is happening. Any help would be so much appreciated!!!
I don’t know much about PHP, but I just use simple includes that never fail me. Could you just try include instead of require_once? Maybe for some reason it is not including a second time because already used?? I know this shouldn’t happen across different pages, but…
I got it do that with a NULL search value if that is any help? After that it decided to do it every time it basically has to be the PHP. Yes, without looking at the PHP we don’t stand much chance.
I tried using include instead of require_once and still get the same results.
Well, the only actual PHP coding other than the includes is for the catalogue page and for showing each item. This starts like this:
include 'library/config.php';
include 'library/opendb.php';
$rowsPerPage = 5;
$pageNum = 1;
if(isset($_GET['page']))
{
$pageNum = $_GET['page'];
}
$offset = ($pageNum - 1) * $rowsPerPage;
$self = $_SERVER['PHP_SELF'];
$catalogue_query = "Product_ID, New_Release, FrontPage_NRelease, Genus, Division, Common_Name, Special_Offer, Description, Price, SO_Price, Description_Code, In_Stock, pricing, ImageName, multi1a, multi1b, multi2a, multi2b, multi3a, multi3b, multi4a, multi4b FROM products";
if (!empty($_GET['qsearch'])) {
$search = mysql_real_escape_string( trim($_GET['qsearch']) );
$catalogue_query .=" WHERE Common_Name LIKE '%$search%' OR Genus LIKE '%$search%'";
}
And then has a couple more IF clauses and then the while clause which contains the code for each catalogue item. The actual form and all the coding on the right-hand side of the page, except for the Shopping Basket, which is generated by PHP, is written in HTML.
I also tried getting rid of all the includes by pasting all my code into the one document. I have tried this on the index.php and catalogue.php and it made no difference. After doing this it meant that the only php code on my page was the code to load up my database configurations, code to generate the items in the New Releases box on the left, code used to generate the items in the catalogue and also the shopping basket on the right.
Generally I am testing this on the www.showglads.com site as this is the one that has the biggest problem. It seems that it is okay to search on the Index page but as soon as the catalogue.php page loads up the <form> tags have already disappeared and it’s impossible to do another search. By getting rid of these ‘include’ statements it means that the <form> is in no possible way being generated by PHP, it is all in HTML and this is why this thing is so confusing. I’ve never know anything like this to happen before!!!
I tried to replicate the error but the form tags always showed up for me so no help there.
The PHP code is for getting info from the db. What exactly does the code involved with
<div class="block">
<br />
Search the catalogue for a keyword.
<form name="form" action="catalogue.php" method="get">
<input type="text" name="qsearch" size="15"/>
<br />
<input type="submit" name="Submit" value="Search" width="6" size="6" height="6"/>
</form>
</div>
look like? Thats all in a hard-coded include file? If so, what does the code at and before the include() line look like? Everything except only the form tags alone still gets shown OK?
It’s within the search results. Below the item heading and above the item description.
<h4>WHITE ICE (Jones 1987)</h4>
<form action="" method="post" name="form2">
<br/>
<p>Still in the Top Ten American cultivars, this great exhibition variety...
Ahh, I tried searches for “red” and then “white” and I see the other “form2” tags. They are paired with closing tags, but the tags are not nested correctly.
<div class="catalogue">
<div class="catalogue_left" align="center">
<img height="82" width="122" src="images/no_image-122x82.jpg" />
<br />
<p>Hover over image to enlarge</p>
</div>
<div class="catalogue_right">
<h4>CHERRY BERRY (Fredericks 2007)</h4>
<form action="" method="post" name="form2">
<br/>
<p>A very attractive formal glad, rose red with a deeper red throat. Opens 7 of 22 buds on a 22" flower head. Florets are 3" in size with medium ruffling. Red cards at BGS Midland show. </p>
<div style='float:right;'>
<a href="basket.php?action=add&id=227"><img height="17" width="79" border="0" src="images/addtobasket.jpg" /></a>
</form>
</div>
<h5>2.50 each</h5>
</div>
</div>
I don’t see why any form tags are needed there anyway, the links are GET.