Loosing it

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
 two words from the form below and one simple query after, doesnt work, what
to do to make it work

<INPUT TYPE=TEXT NAME=search size=20>
<INPUT TYPE=TEXT NAME=search1 size=20>
<INPUT TYPE="submit" VALUE="Proceed query">

//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

  $result = mysql_query($query);
   while($row = mysql_fetch_row($result)){
      echo '<br>';

Re: Loosing it


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

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

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

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

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).


Re: Loosing it

Slawomir Piwowarczyk wrote:
Quoted text here. Click to load it

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 /
== ** ## !! ------------------------------------------------ !! ## ** ==
may bypass my spam filter. If it does, I may reply from another address!

Site Timeline