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

  • Home
  • SEARCH
  • 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 8745333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:59:25+00:00 2026-06-13T11:59:25+00:00

PHP script running server side to handle queries from Java application. The table has

  • 0

PHP script running server side to handle queries from Java application. The table has 450 results that should be returned but for some reason its going to the no businesses found statement..

For testing im sending the information on the HTTPGet from the android app with the following vals

varQuery2 is a String and = state
varQuery1 is a String and = MS

<?php

$result = mysql_query("SELECT * FROM businessdata WHERE '" 
. mysql_real_escape_string($_REQUEST['varQuery2'])."' =  '" 
. mysql_real_escape_string($_REQUEST['varQuery1'])."'") or die(mysql_error());

// check for empty result
if (mysql_num_rows($result) > 0) {
// looping through all results
// businesses node
$response["businesses"] = array();

while ($row = mysql_fetch_array($result)) {
    // temp user array
$business = array();
$business["bid"] = $row["idbusinessData"];
$business["name"] = $row["name"];
$business["owner"] = $row["owner"];
$business["phone_main"] = $row["phone_main"];



array_push($response["businesses"], $business);
}
// success
$response["success"] = 1;

// echoing JSON response
echo json_encode($response);
} else {
// no businesses found
$response["success"] = 0;
$response["message"] = "No businesses found";

// echo no users JSON
echo json_encode($response);
}
?>

Why is this failing and any ideas how to fix it? Also please note that the entire script worked with static state = ‘MS’ in the select… Even when I call it from a browser window with:

http://address/scriptName.php?varQuery2=state+varQuery1=MS 

I still get the same No Business Found response..

As per comments the below is the table that is being used here..

CREATE  TABLE `test`.`businessData` (
`idbusinessData` INT NOT NULL AUTO_INCREMENT ,
`name` CHAR(255) NULL ,
`owner` CHAR(255) NULL ,
`phone_main` CHAR(10) NULL ,
PRIMARY KEY (`idbusinessData`) );

Just a little update to see if I am on the right track:

switch ($_GET){
case "state":
$result = mysql_query("SELECT * FROM businessdata WHERE state =  '" . mysql_real_escape_string($_REQUEST['varQuery1'])."'") or die(mysql_error());

case "zip";
// zipcode results
case "nothing";
// default results
}
  • 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-13T11:59:25+00:00Added an answer on June 13, 2026 at 11:59 am

    You are trying to select every business for which "state" = "MS", which will of course be false every time (you compare the two strings against each other).

    You should avoid having column names as part of your GET request. Instead, consider using a specific GET field for each column which you’d want to query (e.g. search.php?state=MS), then building the query based on the supplied parameters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP script running on my LAMP server that requires certain files
I'm running a php script from the command line against SQL server 2005 using
I am currently running a PHP script that queries the database and then sends
I have an Apache server running a PHP script that receives data via a
I have a PHP script (running on a Linux server) that ouputs the names
I have a PHP script running on XAMPP in Windows XP that will open
I am working on a site that require a php script running on a
I have a php script that is running in CLI and I want to
I am running a php script from the console. I cannot see any cookies
I am working on php script that may involve a long running task. The

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.