-3
Good afternoon guys, I’m trying to repair a site that I have access from the company before was Postgresql now I’m trying to upgrade to mysqli, I’m stuck and would like your help:
You’re making the following mistake:
PHP Warning: mysqli_stmt_bind_param(): Number of variables doesn’t match number of Parameters in Prepared statement in
I gave a var_dump, this error appeared!!
Erro na Comunicação com o Banco de Dados!object(mysqli_stmt)#2 (10) { ["affected_rows"]=> int(0) ["insert_id"]=> int(0) ["num_rows"]=> int(0) ["param_count"]=> int(0) ["field_count"]=> int(7) ["errno"]=> int(0) ["error"]=> string(0) "" ["error_list"]=> array(0) { } ["sqlstate"]=> string(5) "00000" ["id"]=> int(1) }
follows the code below:
contact
<?php
/* Conexão com o BD */
include("../lib/connection.php");
$cod_contato = $_GET['contato'];
/* Constitui a string correspondente ao SQL */
$stmt = mysqli_stmt_init($connect);
if (mysqli_stmt_prepare ($stmt, 'SELECT id_contato, nome, assunto, ip_cad_contato, telefone, email, menssagem FROM contato WHERE WHERE id = $id'))
/* atribui os parametros aos marcadores */
mysqli_stmt_bind_param ($stmt, 'issssss', $cod_contato, $nome, $assunto, $ip, $telefone, $email, $menssagem);
/* executa a query */
mysqli_stmt_execute($stmt);
/* atribui as variaveis de resultado */
mysqli_stmt_bind_result ($stmt, $codigo, $nome, $assunto, $ip, $telefone, $email, $menssagem);
/* busca o valor */
mysqli_stmt_fetch($stmt);
/* fecha a declaração */
mysqli_stmt_close($stmt);
include ("tabela_contato.php");
/* Fehca a conexão com o BD */
mysqli_close($connect);
?>
goes below:
Connection.php
Edit the question with the full code and what you’re trying to do.
– Guilherme Rigotti
The first mistake is that you are giving fewer parameters than required by the function. The second error you need to pass the code you are using to analyze.
– Guilherme Rigotti
It’s too vague, buddy. Stop, think. Elaborate better, be more detailed, and point out a part of the code where you’re having trouble. Not only the dump.
– Fabiano Monteiro
ta aee the code Guilherme Rigotti, I do not understand programming friend I just want to fix the site to insert entries, check the register in the database!! sorry if I didn’t put the code but I think it was yes, see if this right this code and what I can do for repair, grateful!!
– Wellingtonstz
The error in the BD connection is probably related to your
connection.php
. Edit the question with him– Guilherme Rigotti
@Wellingtonstz
mysqli_stmt_bind_param ($stmt, 'sssssss', $cod_contato...
The kind to$cod_contato
, wouldn’t be s(string), but yes i (integer). No? Something like:mysqli_stmt_bind_param ($stmt, 'issssss', $cod_contato...
. Not everything that goes white is string. id is not string.– Fabiano Monteiro
so the more I’m able to query in the database, I believe that is not the Connection.php no!! pq used to be Postgresql, but it’s very old the site and hj has updated neh and I am trying to pass to mysqli prepa... how can I insert the other code I have and the table?
– Wellingtonstz
@Guilhermerigotti type I can consult in the normal site more, I can not change to consult several people I can only consult an id and has several id, 1,2,3.. more only appears the 1 to me understood
– Wellingtonstz
@Fabiano put it the way you went, but I can’t consult the other people who registered on the site.. /* assigns parameters to markers */ mysqli_stmt_bind_param ($stmt, 'issssss', $cod_contact, $name, $subject, $ip, $phone, $email, $menssagem);
– Wellingtonstz
@Wellingtonstz That’s why you’re going through a wrong Query. is putting at the end WHERE 1, if you want to query other IDS you need to go to Query.
WHERE id = $id
and not 1– Guilherme Rigotti
@Wellingtonstz In your if, open and close the key signal and let the close the connection from outside the if
if(){ ...} mysqli_close($connect);
Check this oneinclude ("tabela_contato.php");
, whether to stay outside or inside the keys... Also note the comment above @Guilhermerigotti– Fabiano Monteiro
@Guilhermerigotti and pq I had put as this in the database in SQL, but put as you say, not changed anything..
– Wellingtonstz
@Wellingtonstz when you change the code, also changes the question so we can see what you did. Another thing, remove this
mysqli_stmt_prepare
from within theIF
that he’s not checking anything out– Guilherme Rigotti
@Fabianomonteiro did not understand what you gave me. I’m trying to pass a picture here of how this more I can’t get where I can send a picture of the consultation!!
– Wellingtonstz
@Guilhermerigotti edited it in the question I did, more I did not understand about this IF, how can I this taking mysqli_stmt_prepare inside it, I’m trying more of the error!!
– Wellingtonstz
@Guilhermerigotti put that you passed, but I put the table that you did not put in the code and put my normal connection that this all. even so without success
– Wellingtonstz
You didn’t post your file
connection.php
. When posting just edit your question, I recommend deleting the 2 answers you put and only edit your wig.– Guilherme Rigotti
Respect the error. You are saying that there are no such elements on your page. So we need to find out if the connection is working and then if these fields even exist in the table.
– Guilherme Rigotti
then more exists yes on the table can rest assured I put my connection no more I do not know have to be authorized, because it was no longer was the picture of the table more then I will update passing the table to you give a look.. I deleted the two answers that you say!! thanks even for helping me should be simple thing, more for those who do not understand programming is difficult!
– Wellingtonstz
@Guilhermerigotti Good morning, I could not fix the defect yet, sorry this week was run in service.. and in fds, December only fooda parties!!
– Wellingtonstz
some help???
– Wellingtonstz