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 5947381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:57:21+00:00 2026-05-22T16:57:21+00:00

Starnge problem i cant seem to find the root of, I am using jqgrid

  • 0

Starnge problem i cant seem to find the root of,

I am using jqgrid which submits data for update edit and delete to my page server.php

as sometimes values are empty i have written code for the update/insert functions under a switch statement.

before the switch statement is run i have code that generatess the update and insert statements for the mySQL.

Just before the insert statement is run i echo out the sql call which returns:

my insert = INSERT INTO mapdata_mdt (id_etp,geoaddr_mdt,active_mdt,flag_mdt) VALUES(1 ,'n11hl' ,1 ,1 )

as far as i can acertain thats a valid sql query??? so why does it error with the following:

Error: Query was empty

am puzzled to this so any pointers would be graetly appreciated.

the full code is below:

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

 //get formdata
$fdOper = $_POST['oper'];
$myKeys = array();
$myValues = array();
$myID = GetSQLValueString($_POST['id'], 'int');

if(isset($_POST['id_etp'])){
    if ($_POST['id_etp'] !=''){
        array_push($myKeys, 'id_etp');
        array_push($myValues, GetSQLValueString($_POST['id_etp'], 'int'));
    };
};
if(isset($_POST['displayaddr_mdt'])){
    if ($_POST['displayaddr_mdt'] !=''){
        array_push($myKeys, 'displayaddr_mdt');
        array_push($myValues, GetSQLValueString($_POST['displayaddr_mdt'], 'text'));
    };
};
if(isset($_POST['geoaddr_mdt'])){
    if ($_POST['geoaddr_mdt'] !=''){
        array_push($myKeys, 'geoaddr_mdt');
        array_push($myValues, GetSQLValueString($_POST['geoaddr_mdt'], 'text'));
    };
};
if(isset($_POST['lat_mdt'])){
    if ($_POST['lat_mdt'] !=''){
        array_push($myKeys, 'lat_mdt');
        array_push($myValues, GetSQLValueString($_POST['lat_mdt'], 'text'));
    };
};
if(isset($_POST['lng_mdt'])){
    if ($_POST['lng_mdt'] !=''){
        array_push($myKeys, 'lng_mdt');
        array_push($myValues, GetSQLValueString($_POST['lng_mdt'], 'text'));
    };
};
if(isset($_POST['description_mdt'])){
    if ($_POST['description_mdt'] !=''){
        array_push($myKeys, 'description_mdt');
        array_push($myValues, GetSQLValueString($_POST['description_mdt'], 'text'));
    };
};
if(isset($_POST['website_mdt'])){
    if ($_POST['website_mdt'] !=''){
        array_push($myKeys, 'website_mdt');
        array_push($myValues, GetSQLValueString($_POST['website_mdt'], 'text'));
    };
};
if(isset($_POST['email_mdt'])){
    if ($_POST['email_mdt'] !=''){
        array_push($myKeys, 'email_mdt');
        array_push($myValues, GetSQLValueString($_POST['email_mdt'], 'text'));
    };
};
if(isset($_POST['telephone_mdt'])){
    if ($_POST['telephone_mdt'] !=''){
        array_push($myKeys, 'telephone_mdt');
        array_push($myValues, GetSQLValueString($_POST['telephone_mdt'], 'text'));
    };
};
if(isset($_POST['active_mdt'])){
    if ($_POST['active_mdt'] !=''){
        array_push($myKeys, 'active_mdt');
        array_push($myValues, GetSQLValueString($_POST['active_mdt'], 'int'));
    };
};
if(isset($_POST['flag_mdt'])){
    if ($_POST['flag_mdt'] !=''){
        array_push($myKeys, 'flag_mdt');
        array_push($myValues, GetSQLValueString($_POST['flag_mdt'], 'int'));
    };
};
$keyCount = count($myKeys);
$valCount = count($myValues);
$insertKeyStr ='';
$insertValStr = '';
$insertKeys = '';
$insertVals = '';
$updateStr = '';
$myUpdate = '';
$myInsert = '';
if($keyCount == $valCount){
    echo('Number of keys: '.$keyCount.' matches number of values: '.$valCount.'');
    //generate our sql
    for ( $i = 0; $i <= $keyCount-1; $i++) {
        $insertKeys .= $myKeys[$i].","; // generates list of keys for insert
        $insertVals .= "".$myValues[$i]." ,"; //generates list of values for insert
        $updateStr .= $myKeys[$i] . " = " . $myValues[$i] . ",";

    }
    //strip last comma from strings
    $insertKeys = substr($insertKeys, 0, -1);
    $insertVals = substr($insertVals, 0, -1);
    $updateStr = substr($updateStr, 0, -1);
    $myInsert = "INSERT INTO mapdata_mdt ($insertKeys) VALUES($insertVals)";
    $myUpdate = "UPDATE mapdata_mdt SET $updateStr WHERE id_mdt = $myID";

}else{
    echo('Number of keys: '.$keyCount.' does not match number of values: '.$valCount.'');
}

switch ($fdOper) {
    case 'edit':
        echo('my update = '.$myUpdate);
        if (!mysql_query(mysql_query($myUpdate, $growthConn))){
            die('Error: ' . mysql_error());
        }else{
            echo('Update ok');
        };
    break;
    case 'add':     
        echo('my insert = '.$myInsert);
        if (!mysql_query(mysql_query($myInsert, $growth_conn))){
            die('Error: ' . mysql_error());
        }else{
            echo('Insert ok');
        };
    break;
    case 'delete':
        mysql_query("delete from mapdata_mdt where id_mdt= $myID");
    break;
}
  • 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-05-22T16:57:22+00:00Added an answer on May 22, 2026 at 4:57 pm

    You have mysql_query calling mysql_query:

    if (!mysql_query(mysql_query($myInsert, $growth_conn))){
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As the title suggests, I've got a problem I just cant find a solution
I seem to be having a strange problem which I can't fully understand. This
I have a real annoying problem and I can't seem to find it. Only
There's a strange problem with DotNetZip that I can't seem to find a solution
I have a strange problem that I can't seem to solve. I've quite a
I've got abit of a strange problem, that I just can't seem to solve!
I have a strange problem which I can't fix: A field: private boolean[][][] gaps;
This is a strange LINQ-to-SQL problem which can't evaluate as an Enumerable (in SQL)
I am having a strange problem and I can't seem to figure it out.
I am using Eclipse with the PyDev plugin. I am using xlwt which is

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.