473,566 Members | 3,342 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.p hp 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($qu ery);
while($row = mysql_fetch_row ($result)){
print_r($row[0]);
echo '<br>';
....
Jul 17 '05 #1
2 1370
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($qu ery);


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

$result = mysql_query($qu ery) 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
2045
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 want to see filled in form and a plot. don't know why i'm loosing all the data. when user adds data to the form i'm doing something like that:
11
3326
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 that question? What browsers does that apply to? My database stores some information based on the session id, would there be another, (better),...
3
1607
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 records to a database. Before it finishes SqlDataReader and Connection I are being closed. There are no global varaibles. All is inside that...
5
1861
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 saving the data, but this seems impossible, so a warning like 'the things you just typed must be entered again probably' is good enough. I prefere...
13
1585
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 idea althoug I'd like to know what will be the future of this wonderful language called Python?????? Regards,
1
1552
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 the next. I have used "InProc" on my development machine and the session variable values are being maintained between pages. I copied two of the...
3
1699
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 try to retrieve the username from the session variable I get nothing; the value is null I have tried all the Session modes and set cookies off ...
8
1149
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
985
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 += new System.EventHandler(this.btnAssignTeam_Click); Has anyone encountered a similar problem before ?
1
1649
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 my country my citylist is refreshed ok. I want to be able to then click on my city and jump to a specific page without loosing state; and i dont know...
0
7584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7893
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7645
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7953
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2085
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 we have to send another system
1
1202
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
926
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.