473,500 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Loosing it

two words from the form below and one simple query after, doesnt work, what
to do to make it work
<FORM ACTION=search.php METHOD=POST>
<INPUT TYPE=TEXT NAME=search size=20>
<INPUT TYPE=TEXT NAME=search1 size=20>
<INPUT TYPE="submit" VALUE="Proceed query">
</FORM>
<?
//this one works fine: "select * from table_1 where dane like '%$search%'"
//but i wanna the one below to work
$query = "select * from table_1 where dane (like '%$search%') or dane (like
'%search1%')";
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^
//DOESNT WORK, WHY?

$result = mysql_query($query);
while($row = mysql_fetch_row($result)){
print_r($row[0]);
echo '<br>';
....
Jul 17 '05 #1
2 1366
Hi,

$query = "select * from table_1 where dane (like '%$search%') or dane
(like
'%search1%')";

well first of all you dont have $ in front of the search1 variable.
also, why put the brackets there? this should be:

$query = "select * from table_1 where dane like '%$search%' or dane
like
'%search1%'";

not only that, but this query should be further improved to:

$query = "select * from table_1 where dane like '%".$search."%' or dane
like
'%".$search1."%'";

and you should always make sure that the variables you pass into the
query are escaped (the default setting of magic quotes varies from host
to host).

George

Jul 17 '05 #2
Slawomir Piwowarczyk wrote:
<?
//this one works fine: "select * from table_1 where dane like '%$search%'"
//but i wanna the one below to work
$query = "select * from table_1 where dane (like '%$search%') or dane (like
'%search1%')";
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^
//DOESNT WORK, WHY?

$result = mysql_query($query);


Because you don't check the return from mysql_query(). Try

$result = mysql_query($query) or die('Bad query: ' . mysql_error());

You could also try to make $query have a valid syntax.
Hint: the parenthesis are badly positioned.

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Jul 17 '05 #3

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

Similar topics

10
2036
by: Piotr Wolski | last post by:
hello, as always i have a problem:-) i'm using HTML form. User is adding some date to this form and after that i'm generating plot. When plot is generated i can see en empty form and a plot. I...
11
3307
by: Sims | last post by:
Hi, I heard that there was a chance of 'loosing' a session ID between pages, (when the user clicks from one link to another). Is it really possible? Where could I find a definitive answer to...
3
1592
by: Marius Horak | last post by:
Hi, I have a window program (C#) with 2 buttons, 2 labels and timer running under Win2K (DotNet 1.1). On Tick (every 30 mins) it will execute a procedure that reads a number of files and add...
5
1855
by: My4 | last post by:
Dear Sirs, I want to give the user of my intranet a warning that if he uses the explorers right corner 'X' to close the browser he looses his information. I tried to prevent him from closing, or...
13
1573
by: Fcamattti | last post by:
Hello for everybody???? So I have a doubt. I'd like to know what do you think about the joint of efforts of Sun Microsystems and the Google to create a office web based. I sincerely enjoy the...
1
1546
by: Jonk Eidersteldvr | last post by:
Hi, I am using a web application -asp, ado, C#, using CodeBehind files etc.. I am using "InProc" session state and find that session variables are loosing their values between one web form and...
3
1694
by: Windjammer | last post by:
I seem to be loosing my session variable as I move from one application to another The first application presents a menu of applications the user is authed for When I call the next application and...
8
1145
by: robrod1970 | last post by:
Check out this link: http://tinyurl.com/5nele It should read "Web.config" but someone at Microsoft managed to type it as "Config.web" in the entire article. :) --
4
975
by: Irfan Akram | last post by:
Hey, This Visual Studio.NET keeps playing up. It is acting strange. It keeps loosing the colors of the fonts, and sometimes it doesnt even add events like these.. this.btnAssignTeam.Click +=...
1
1645
by: Owen Richardson | last post by:
I have an asp.net website where i have a quick search facility built into my master page. the search is a web control, with a drop down country box and a list box full of cities. When i select...
0
7136
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7182
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6906
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7397
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4611
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3110
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1430
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
672
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
316
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.