iOS Question b4a -> php mysql error

gerredtor

Active Member
Licensed User
hello i have a php mysql script

mysql.php:

B4X:
<?PHP
    function connection()
    {
        $con = mysqli_connect(************);  
      
        mysqli_set_charset('utf8',$con);
      
        return $con;
    }
  
    function my_sql_load_wert($tabelle, $index, $indexwert, $suche)
    {
        $con = connection();
      
        $query = mysqli_query($con, "SELECT `".$suche."` FROM `".$tabelle."` WHERE `".$index."` = '".mysqli_real_escape_string($con,$indexwert)."'");
                              
        while($row = mysqli_fetch_assoc($query))
        {
            return $row[$suche];
        }
      
        return $query;
    }
  
    function my_sql_load_wert2($tabelle, $index, $indexwert, $index2, $indexwert2, $suche)
    {
        $con = connection();
  
        $query = mysqli_query($con, "SELECT `".$suche."` FROM `".$tabelle."` WHERE `".$index."` = '".mysqli_real_escape_string($con,$indexwert)."' AND `".$index2."` = '".mysqli_real_escape_string($con,$indexwert2)."'");
  
        while($row = mysqli_fetch_assoc($query))
        {
            return $row[$suche];
        }
  
        return $query;
    }
      
    function my_sql_update_wert($tabelle, $index, $indexwert, $update, $updatewert)
    {
        $con = connection();
      
        mysqli_query($con, "UPDATE `".$tabelle."` SET `".$update."` = '".mysqli_real_escape_string($con,$updatewert)."' WHERE `".$index."` = '".mysqli_real_escape_string($con, $indexwert)."'");
      
        return true;
    }
  
    function my_sql_new_wert($tabelle, $index, $indexwert)
    {
        $con = connection();
      
        $st = mysqli_query("INSERT INTO `".$tabelle."` (`".$index."`) VALUES ('".mysqli_real_escape_string($con,$indexwert)."')");
      
        return mysqli_insert_id($con);
    }
  
    function my_sql_exists_wert($tabelle, $index, $indexwert)
    {
        $con = connection();
      
        $st = mysqli_query($con, "SELECT `".$index."` FROM `".$tabelle."` WHERE `".$index."` = '".mysqli_real_escape_string($con,$indexwert)."'");
        $arr = mysqli_fetch_assoc($st);
      
        return count($arr) > 0;
    }
  
    function my_sql_exists_wert2($tabelle, $index, $indexwert, $index2, $indexwert2)
    {
        $con = connection();
      
        $st = mysqli_query($con, "SELECT `".$index."` FROM `".$tabelle."` WHERE `".$index."` = '".$indexwert."' AND `".$index2."` = '".$indexwert2."'");
        $arr = mysqli_fetch_assoc($st);
      
        return count($arr) > 0;
    }
  
    function my_sql_array_count($tabelle, $suche)
    {
        $con = connection();
      
        $st = mysqli_query($con, "SELECT `".$suche."` FROM `".$tabelle."`");
        $arr = mysqli_fetch_assoc($st);
      
        return count($arr);
    }
?>

and my run script:

B4X:
    function setPro($username, $password, $secID, $rID, $appID)
    {
        if($secID != "***************")
        {
            return "0";
        }
      
        if(pruefeRID($rID))
        {
            $userID = my_sql_load_wert("users", "email", $username, "id");
            $id = my_sql_new_wert("buy_data", "receipt", $rID);
            my_sql_update_wert("buy_data", "id", $id, "userID", $userID);
            my_sql_update_wert("buy_data", "id", $id, "valid", "true");
            my_sql_update_wert("buy_data", "id", $id, "type", $appID);

            return "1";
        }else{
            return "3";
        }
    }

he return "1" but he dont change it in the db. the db data are correct, and he can only read datas from the db
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…