0

I have the following code in a PHP file so I can Update some items from a database (I'm using webhost for the database)

<?php

    include_once 'conexao.php';
    
    $Name = $_GET['Name'];
    $Type = $_GET['Type'];
    $Size = $_GET['Size'];
    $Quantity = $_GET['Quantity'];
    $Cost = $_GET['Cost'];
    $ID = $_GET['ID'];
    
    $sql = "UPDATE MenClothDB SET Name = '$Name', Type = '$Type', Size = '$Size', Quantity = '$Quantity', Cost = '$Cost' WHERE ID = '$ID'";
    
    if ($dbcon->query($sql) === TRUE) {
        echo "Record updated successfully";
    } else {
        echo "Error updating record: " . $conn->error;
    }
?>

and if I try typing the whole url (for example, https://xxx.000webhost.com/UpdateCloth.php?Name=Example.....&ID=6) it works perfectly fine, the row gets updated. But when I try using that in App Inventor (code/blocks shown below) the Response Code is "400 Bad Request" enter image description here

Reed
  • 14,703
  • 8
  • 66
  • 110
Zirus12
  • 15
  • 3
  • Also, small note I forgot to add, global ID is correct, I checked – Zirus12 Jan 02 '21 at 17:56
  • 3
    Note that your code is insecure and vulnerable to SQL Injection. Please see [https://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php](https://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) – Reed Jan 02 '21 at 18:07
  • Do you have the "?" at the end of your url in the first text block ? Also, try uriEncoding each of your textbox entries, including the global ID – Metric Rat Jan 10 '21 at 01:17

0 Answers0