473,320 Members | 1,857 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Help please: just a simple search..

Thanks for any help in advance. I am using this exact same piece of code on
a server running PHP4, but for some reason when I run it on dreamhost using
PHP5, the search does not register and it just lists all items. There's not
much code, so I'm just putting it all in here. The script calls itself.
Can someone please tell me why the
if(!(isset($search)))
is ignored when the form is posted?

Thanks,

Shane
********************************

Search:<form method="post" action="listitem.php">
<input type="text" name="search">
<input type="hidden" name="count" value="20">
<input type="submit" value="search">
</form><BR>
<?php

if(!(isset($search))){
$query="SELECT * FROM item ORDER BY name DESC";
if(!(isset($count))){
$count=20;
}
}

else{
$query="SELECT * FROM item WHERE name LIKE '%$search%' OR description
LIKE '%$search%' ORDER BY name DESC";

if(!(isset($count))){
$count=20;
}
}
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
$bottom = ($count - 20);
while (($i < $count) && ($i < $num)) {

if ($i < $bottom){
$i++;
}

else{

$name=mysql_result($result,$i,"name");
$location=mysql_result($result,$i,"location");

echo "<LI><A HREF=$location>$name</A>";
echo "</LI<BR><BR>";
$i++;
}
}
if ($count < $num){

$count = ($count + 20);

if(!(isset($search))){
echo "<A HREF=/listitem.php?count=$count>Next 20</A>";
}
else{
echo "<A HREF=/listitem.php?count=$count&search=$search>Next 20</A>";
}

}
?>

****************************************
Aug 11 '06 #1
3 1480
ZafT napisal(a):
Can someone please tell me why the
if(!(isset($search)))
is ignored when the form is posted?
Read about register_globals directive. In php4 default is on, in php5 -
off.

--
Tomasz Rup

Aug 11 '06 #2
snip
>
<?php

if(!(isset($search))){
$query="SELECT * FROM item ORDER BY name DESC";
if(!(isset($count))){

Put

$searh = $_POST['search'];

just after the <?php
Aug 11 '06 #3
Put

$search = $_POST['search'];

just after the <?php
That did it - Thanks!

Shane
Aug 11 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: JT | last post by:
Help me the following C++ question: Write a program to help a local bookshop automate its billing system. The program should do the following: (a)Let the user enter the ISBN, the system will...
8
by: Steph | last post by:
Hi. I'm very new to MS Access and have been presented with an Access database of contacts by my employer. I am trying to redesign the main form of the database so that a button entitled...
4
by: Tarun Mistry | last post by:
Hi all, I have posted this in both the c# and asp.net groups as it applies to both (apologies if it breaks some group rules). I am making a web app in asp.net using c#. This is the first fully OO...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
0
by: Kermitus | last post by:
Hey I was hoping for a little help. I am a Domain reseller for Aplus.net. The problem is they really don't provide an API to automate Domain searches, registering etc... I see much potential in...
83
by: deppy_3 | last post by:
Hi.I am started learning Programm language C before some time.I am trying to make a programm about a very simple "sell shop".This programm hasn't got any compile problem but when i run it i face...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
3
markmcgookin
by: markmcgookin | last post by:
Hi Folks, I have a VB app, and I have been working at it for a while, and I am now at the stage where I want to create a search function. Now don't be scared! It is in the .Net compact framework,...
9
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.