Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8826515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:09:23+00:00 2026-06-14T07:09:23+00:00

so this is my problems short version: This works: $query = mysql_query(SELECT * FROM

  • 0

so this is my problems short version:

This works:

$query = mysql_query("SELECT * FROM `some_table` 
                     WHERE IF (LENGTH('$some_variable') > 0, `$other_variable` LIKE
                               '%$some_variable%' , 0)");

I get a result go through it with a while pack it all in an array and with json_encode send it back to my ajax file, where i list the result. And it works perfectly.

But when i ad one more thing to the query it just gives back empty, so this doesn’t work:

$query = mysql_query("SELECT * 
                      FROM `some_table` 
                      WHERE `something` = `some_other_thing` AND 
                          IF (LENGTH('$some_variable') > 0, `$other_variable` 
                               LIKE '%$some_variable%' , 0)");

So with that AND things just don’t work, but only whit ajax, i mean if i simply print the array out php works superbly.

Thanks in advance.

This is the rest of my php

while ($value = mysql_fetch_array($query)) {

$result[] = array
            (       
                gyarto => $value['gyarto'],
                termekcsalad => $value['termekcsalad'],
                kiszereles => $value['kiszereles']
            );
}

echo json_encode($result);

and my jquery:

$.ajax({
                    url:"updates/isu.php",
                    type:"POST",
                    data: form,
                    dataType: "json",
                    success: function(data) {


                    $.each(data, function(i)                            
                    {
                       $("#result table").append('<tr><td>'+data[i].gyarto+' '+data[i].termekcsalad+' '+data[i].kiszereles+'</td></tr>');

                    }); 

                }
            });

        });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:09:24+00:00Added an answer on June 14, 2026 at 7:09 am
    I think you are mixing php language in a mysql query.
    

    Try:

    $query = mysql_query("SELECT * FROMsome_table WHEREsomething=some_other_thing AND  (LENGTH('$some_variable') > 0 AND '$other_variable` LIKE '%$some_variable%')");  
    

    Also here is an exemple on how to use the mysql_fetch_array

    mysql_connect("localhost", "mysql_user", "mysql_password") or
        die("Could not connect: " . mysql_error());
    mysql_select_db("mydb");
    
    $result = mysql_query("SELECT id, name FROM mytable");
    
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        printf("ID: %s  Name: %s", $row["id"], $row["name"]);
    }
    
    mysql_free_result($result);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So the wonderful low down on this doozie of a problem: short version: We
Short version of Problem Autocomplete works when the input string matches the result string,
Short Version I want to extend SoapClient so it does this internally when accessing
I am having problems with the DictWriter and non-ascii characters. A short version of
Possible Duplicate: Getting a value from HttpServletRequest.getRemoteUser() in Tomcat without modifying application Short version:
Super-short version: I solved this problem when I was nearly finished writing the question.
The short version is that this doesn't appear to be a code problem (though
The short version of this question is: How can I take data that only
Short version: After inserting a select element with options into the DOM with an
Short version : does Android reboot the phone (literally reboot) to get rid of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.