Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Error: UPDATE contracts set `client_type`=?, `client_details`=? WHERE `id`= ?
- You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '?, `client_details`=? WHERE `id`= ?' at line 1
- Updated
- $query = "UPDATE contracts set `client_type`=?, `client_details`=? WHERE `id`= ?";
- <?php
- require("config.php");
- $id = filter_input(INPUT_GET, 'id');
- ?>
- <html>
- <head>
- <title> Submit a Contract </title>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- </head>
- <body>
- <form method="post" action="" enctype="multipart/form-data">
- ID: <input type="hidden" name="id" value="<?php echo $id; ?>" />
- <?php
- $sql = "SELECT * FROM contracts WHERE `id` = $id";
- $result = $con->query($sql);
- $row = $result->fetch_assoc();
- $client_type = $row['client_type'];
- ?>
- <label for = "client1">
- <input type="radio" name="client_type" id = "client1" value="Division" <?php echo ($client_type == 'Division')? "checked" : "" ?> onclick="toggleDivision()"/> Division
- </label>
-                                      
- <label for ="client2">
- <input type="radio" name="client_type" id = "client2" value="External" <?php echo ($client_type == 'External')? "checked" : "" ?> onclick="toggleExternal()"/> External
- </label>
-  
- <input type="text" id="extText" name="client_details2" value="<?php echo $row['client_details']; ?>" disabled />
- <br><br>
- <div id="division">
- Division:
- <select id="mySelect" name="client_details" onclick="enableTextbox()" disabled>
- <option value="Choose" <?php echo $row['client_details'] == 'Choose' ? "selected" : ""; ?> />Choose Division...</option>
- <option value="Distribution" <?php echo $row['client_details'] == 'Distribution' ? "selected" : ""; ?> />Distribution</option>
- <option value="Transmission" <?php echo $row['client_details'] == 'Transmission' ? "selected" : ""; ?> />Transmission</option>
- <option value="Generation" <?php echo $row['client_details'] == 'Generation' ? "selected" : ""; ?> />Generation</option>
- <option value="Procument" <?php echo $row['client_details'] == 'Procument' ? "selected" : ""; ?> />Procument</option>
- <option value="Other" <?php echo $row['client_details'] == 'Other' ? "selected" : ""; ?> />Others</option>
- </select>
- <br><br>
- Others:<input type="text" id="otherTxt" name="client_details1" value="<?php echo $row['client_details']; ?>" disabled />
- <br>
- </div>
- <br>
- <input type="submit" name="submit" value="Submit"/>
- </form>
- <script type="text/javascript">
- function toggleExternal() {
- document.getElementById("extText").disabled = false;
- var divis_el = document.getElementById("division");
- for (var i = 0; i < divis_el.children.length; i++) {
- divis_el.children[i].disabled = true;
- }
- }
- function toggleDivision() {
- document.getElementById("extText").disabled = true;
- var val = document.getElementById("mySelect").selectedIndex;
- var divis_el = document.getElementById("division");
- for (var i = 0; i < divis_el.children.length; i++) {
- divis_el.children[i].disabled = false;
- divis_el.children[5].disabled = true;
- }
- }
- function enableTextbox() {
- var val = document.getElementById("mySelect").selectedIndex;
- if (val == 0 || val == 1 ||val == 2 ||val == 3 ||val == 4) { document.getElementById("otherTxt").disabled = true}
- if (val == 5) { document.getElementById("otherTxt").disabled = false; }
- }
- </script>
- </body>
- <?php
- if(isset($_POST['submit'])) {
- $client_type = isset($_POST ['client_type']) ? $_POST['client_type'] :null;
- $client_details = isset($_POST ['client_details']) ? $_POST['client_details'] :null;
- if($client_type == 'Division'){
- $client_details = isset($_POST ['client_details1']) ? $_POST['client_details1'] :null;
- $client_details = isset($_POST ['client_details']) ? $_POST['client_details'] :null;
- } else {
- $client_details = isset($_POST ['client_details2']) ? $_POST['client_details2'] :null;
- }
- if($client_details == 'Other') {
- $client_details = isset($_POST ['client_details1']) ? $_POST['client_details1'] :null;
- }
- $query = "UPDATE contracts set `client_type`=?, `client_details`=? WHERE `id`= ?";
- $stmt = $con->prepare($query);
- $stmt->bind_param("ssi", $client_type, $client_details, $id);
- $stmt->execute();
- if ($con->query($query) === TRUE) {
- echo "<br><br> Updated successfully <br>";
- echo $query;
- } else {
- echo "Error: " . $query . "<br>" . $con->error;
- }
- if ($stmt->errno){
- echo "FAILURE!!! " . $stmt->error;
- } else {
- echo "<br>Updated";
- }
- $stmt->close();
- $con->close();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement