1

I am working on a Dockerised container application that is a student grade checker. I need to connect this application to a running SQL container. I have it connected successfully but I am running into issues with how to deal with the input data.

Here is where the input data is submitted:

</head>
<body>
<div id="sgc">
    <div id="logo">
        Student Grade Checker App
    </div>
    <div>
        <textarea class="display-input" id="input-text" rows="5" cols="35" required minlength="2" placeholder="Enter the module names and marks separated by comma [put each module in a new line]" value="">Enter the module names and marks separated by comma [put each module in a new line]</textarea>
    </div>
    <div>
        <textarea class="display-output" id="output-text" rows="5" cols="35" readonly=1 placeholder="Results here..." value="">
        </textarea>
    </div>
    <div>
        <button class="sgcbutton-active" onclick="verify();getTotal();">Total Marks</button>
    </div>
    <div>

The textarea id="input-text" is where I want to take the information from to enter into my database, however the information is not submitted anywhere until other microservices are called such as getTotal.

Here is the PHP that I have so far:

$conn = mysqli_connect($host, $user, $pass, $db, $port);

if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected to MySQL successfully!";

"input_text = document.getElementById('input-text').value";

$ModuleMarks = $conn->real_escape_string($_REQUEST['input_text']);

echo $ModuleMarks;

$insertsql = "INSERT INTO Module_Marks (Module) VALUES('$ModuleMarks')";

$result = $conn->query($insertsql);

if (!$result) {

echo $conn->error;

?>

I am getting "Connected to MySQL successfully!" returned so I believe my database connection is ok.

I am getting an error output: call to a member function real_escape_string() on Boolean.

but my first question is help with how to deal with the input text.

Thanks

kmoser
  • 8,780
  • 3
  • 24
  • 40
NovaBrownie
  • 117
  • 6
  • I think you will discover that `$conn` is boolean `false` and not an object. You can use `mysqli_connect_error()` to see what the problem was. – Jerry Aug 26 '22 at 23:24
  • Your ` – kmoser Aug 27 '22 at 04:37

0 Answers0