close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Insert error

Thread began 1/23/2020 7:28 am by María Luisa | Last modified 1/23/2020 1:20 pm by María Luisa | 51 views | 6 replies

María Luisa

Insert error

Hi
I have a simple form: two radio buttons, a text field and a text area.

The idea is that when the user clicks the radio button id moda1, the read-only text field modalidadE (id fijo) becomes available for the insert.

If, on the other hand, you click on the radio button id moda2, the previous field is disabled and the user can enter the text in the text area (id tcontenidoMod).

The corresponding column in the database is always the same: modalidad2. The name of the text field and the text area is ModalidadE.

Here my code.

---
<?php require_once('../webassist/mysqli/queryobj.php'); ?>
<?php require_once('../Connections/conexion.php'); ?>
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>PRUPRU</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<?php
if(isset($_POST['modalidadE'])){
$modalidadE= $_POST['modalidadE'];} ?>
<?php
if (isset($_POST["enviar"]) || isset($_POST["enviar_x"])) {
$InsertQuery = new WA_MySQLi_Query($conexion);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "modensayo2";
$InsertQuery->bindColumn("modalidad2", "s", "".($modalidadE) ."", "WA_DEFAULT");
$InsertQuery->saveInSession("insertado");
$InsertQuery->execute();
$InsertGoTo = "";
if (function_exists("rel2abs")) $InsertGoTo = $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
$InsertQuery->redirect($InsertGoTo);
}
?>
</head>

<body>
<form action="" method="post" name="formulario" id="formulario">
<table>
<tr>
<td>

<input type="radio" name="radioMod" id="moda1" value="0" checked>
</td>
<td><input name="modalidadE" type="text" class="form-control" id="fijo" value="Este texto será siempre el mismo" size="60" readonly="readonly">
</td>
</tr>
<tr>
<td>
<input type="radio" name="radioMod" id="moda2" value="1">
</td>
<td><textarea name="modalidadE" cols="60" rows="3" class="form-control" id="tcontenidoMod" placeholder="Escriba aquí su texto para Modalidad de Ensayo"></textarea>


</td>
</tr>
<tr>
<td></td>
<td>
<input name="enviar" type="submit" value="Enviar">
</td>
</tr>

</table>
</form>
<script>
$(document).ready(function(){
$("input[name='radioMod']").change(function(){
if($(this).val()==1){
$("#fijo").attr("disabled",true);
$("#tcontenidoMod").removeAttr("disabled");
} else{
$("#tcontenidoMod").attr("disabled",true);
$("#fijo").removeAttr("disabled");
}
});
});
</script>

</body>
</html>
---

If I insert with the radio button id moda2, the text inserted in the text area is written to the database correctly. But if I click on the first radio button to insert the default text of the text field into the database first, it gives me a series of errors that I copy below.

---
( ! ) Warning: Wrong parameter count for mysqli_stmt::bind_param() in /Applications/MAMP/htdocs/CST_Fluidos_01/webassist/mysqli/queryobj.php on line 466
Call Stack
# Time Memory Function Location
1 0.0015 365720 {main}( ) .../Prueba_input2.php:0
2 0.0189 530296 WA_MySQLi_Query->execute( ) .../Prueba_input2.php:25
3 0.0192 530704 bind_param ( ) .../queryobj.php:466
There is an error in your SQL syntax.
---

The line 25 in my code is: $InsertQuery->execute();

I do not know what I'm doing wrong. Can someone help me please?

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...