Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I have this error when I run the code:
Error:
Invalid parameter number: number of bound variables does not match number of tokens - Line: 106
Code:
$data_cadastro = date("Y-m-d G:i:s");
$query = "INSERT INTO FRETES (VENDA_CLIENTE_ID_CLIENTE, VENDA_ID_VENDA, DT_COLETA, DT_ENTREGA, LINK, TRANSPORTADORA, POSICAO, VALIDA, DT_CADASTRO)
VALUES (:id_cliente, :id_venda, ':dt_coleta', ':dt_entrega', ':link', ':transportadora', ':posicao', :validacao, ':dt_cadastro')";
$banco = $this->pdo->prepare($query);
try {
$banco->execute(
array(
':id_cliente' => $this->id_cliente,
':id_venda' => $this->id_venda,
':dt_coleta' => $dados['DTcoleta'],
':dt_entrega' => $dados['DTentrega'],
':link' => $dados['linkFrete'],
':transportadora' => $dados['transportadora'],
':posicao' => $dados['posicaoFrete'],
':validacao' => $dados['validacao'],
':dt_cadastro' => $data_cadastro
)
);
} catch (PDOException $exception) {
die("Execução da Query com erro (inserir novo frete): " . $exception->getMessage() . ' - Linha: ' . $exception->getLine());
}
Where i wrong?
Remove the quotes around the placeholders
$query = "INSERT INTO FRETES
(VENDA_CLIENTE_ID_CLIENTE, VENDA_ID_VENDA, DT_COLETA,
DT_ENTREGA, LINK, TRANSPORTADORA, POSICAO, VALIDA, DT_CADASTRO)
VALUES (:id_cliente, :id_venda, :dt_coleta, :dt_entrega, :link,
:transportadora, :posicao, :validacao, :dt_cadastro)";
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I have this PHP code:
$uniqueSessionID = 'd41740fd9dc75cb8a3eeee27165d2323';
$returnUrl = 'http://qapache.us.oracle.com:15671/OA_HTML/OA.jsp?OAFunc=ICX_\nCAT_PUNCHOUT_CALLBACK&OAHP=ICX_POR_HOMEPAGE_MENU&OASF=ICX_CAT_PUNCHOUT_\nCALLBACK&transactionid=1577779317'
$timestamp = $conn->real_escape_string('2016-02-10 07:57:21');
$cxmlVersion = $conn->real_escape_string('1.1.007');
$payloadID = $conn->real_escape_string('20040316032452.913060910.144270#ap6172rt.us.oracle.com');
$sql2 = "INSERT INTO return_cart_url (`sessionid`, `timestamp`, `version`, `return_url`, `payloadID`)
VALUES ('{$uniqueSessionID}','{$timestamp}', '{$cxmlVersion}' '$returnUrl', '{$payloadID}')";
if ($conn->query($sql2) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql2 . "<br>" . $conn->error;
}
And i get this error:
Column count doesn't match value count at row 1
All my columns are varchar. In the beginning i only had the columns uniqueSessionID and returnURL, and with these 2 it worked. It happened when I added the timestamp, cxmlVersion and payloadID.
Anyone who can explain me why this happens?
You forgot 1 comma :
'{$cxmlVersion}','$returnUrl'
you forget one , after cxmlVersion
$sql2 = "INSERT INTO return_cart_url (`sessionid`, `timestamp`, `version`, `return_url`, `payloadID`)
VALUES ('{$uniqueSessionID}','{$timestamp}', '{$cxmlVersion}', '$returnUrl', '{$payloadID}')";
I am guessing it is because you are missing the brackets in the values definition of the return Url, and there is a missing colon after cxmlVersion.
VALUES ('{$uniqueSessionID}','{$timestamp}', '{$cxmlVersion}' '$returnUrl', '{$payloadID}')";
Becomes:
VALUES ('{$uniqueSessionID}','{$timestamp}', '{$cxmlVersion}', '{$returnUrl}', '{$payloadID}')";
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I have a PDO PHP file making use of just one $_POST value stored on the $data array, and if an statement is true, a second value is added to that array to make a new query with two values:
<?php
session_start();
include("../conexionbbdd.php");
if($_SESSION['estado'] == 'activo' && $_SESSION['rol'] == '1'){
$data = array(
'us_id' => $_POST['us_id'],
);
$selectUsers= "SELECT * FROM ws_users WHERE us_id= :us_id";
$statementSelectUsers = $pdo->prepare($selectUsers);
$statementSelectUsers->execute($data);
$result = $statementSelectUsers->fetch(PDO::FETCH_ASSOC);
$us_fk_ui_id = $result['us_fk_ui_id'];
if($us_fk_ui_id==='1'){
$data['us_credits']=$_POST['us_credits'];
$updateUser = mysqli_query($con,"UPDATE ws_users SET us_credits = :us_credits, us_access = '1' WHERE us_id = :us_id");
$statementUpdateUser = $pdo->prepare($updateUser);
$statementUpdateUser->execute($data);
}
Everything goes fine untill the $statementUpdateUser->execute($data); line (34), where I get the usual error
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1065
Query was empty in C:\wamp\www**********\actions\ad_updateUserInfo.php on
line 34
As far as I've seen, this should be due to the unexistance of one of the placeholders on the array, but if I print the array values after the $data['us_credits']=$_POST['us_credits']; it seems to be correct, having the 2 expected values needed for my query:
Array (
[0] => 2
[1] => 1.5 )
How could I check where the mistake is? There's no possibility of echoing the query as it is an object unable to transform on string.
$updateUser = mysqli_query($con,"UPDATE ws_users SET us_credits = :us_credits, us_access = '1' WHERE us_id = :us_id");
^^^ WTF??
You have to pay more attention to the code you write. Stack Overflow is NOT the service for finding typos for you.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
Can someone help me to find what is wrong in the $secret line ?
$secret should give :
{"name":"JustAname","extra":"1","password":"ASD123","report":"http:\/\/website.com\/dev\/gamereport\/0001.php"}
here's the PHP code:
<?php
date_default_timezone_set('America/Montreal');
$name = 'JustAname';
$extra = '1';
$password = 'ASD123';
$reception = 'http:\/\/website.com\/dev\/gamereport.php';
// Code de génération de la base64
$secret = '{"name":"'.$name'","extra":"'.$extra'","password":"'.$password'","report":"'.$reception'"}';
$encodedSecret = base64_encode($secret);
$tournementLink = 'pvpnet://lol/customgame/joinorcreate/map1/pick6/team5/specALL/'.$encodedSecret;
echo $tournementLink;
?>
I got: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in [...] on line 20
You're incorrectly concatenating strings, as #hobbs suggests. You're also using the undefined variable $Tournament, which I think should be $name. Try this:
$secret = '{"name":"' . $name . '","extra":"' . $extra . '","password":"' . $password . '","report":"' . $reception . '"}';
On a side note, a slightly nicer way to create JSON in PHP is to use an array and json_encode():
$secret = json_encode(array(
'name' => $name,
'extra' => $extra,
'password' => $password,
'report' => $reception));
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
I am trying to run this SQL Query using PHP PDO:
$stmt = $pdo_conn->prepare("select * from billing_pdf_archive where invoice_number = :invoice_number and sequence = :sequence ");
$stmt->execute(array(
':invoicenumber' => $_GET["inv"],
':sequence' => $_GET["seq"]
)
);
$result = $stmt->fetch();
Note: $_GET["inv"] and $_GET["seq"] show data when echoed
but i am getting this error
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: parameter was not defined' in /home/integra/public_html/lifeline/billing/resendpdfinvoice.php:94 Stack trace: #0 /home/integra/public_html/lifeline/billing/resendpdfinvoice.php(94): PDOStatement->execute(Array) #1 {main} thrown in /home/integra/public_html/lifeline/billing/resendpdfinvoice.php on line 94
i cannot work out what is wrong with it
where invoice_number = :invoice_number
^---- underscore here
$stmt->execute(array(':invoicenumber' => $_GET["inv"],
^---no underscore here
See here
invoicenumber!=invoice_number
It appears that your query contains :invoice_number when your execution statement asks for :invoicenumber. Try setting them to the same value (:invoice_number for example)
$stmt = $pdo_conn->prepare("select * from billing_pdf_archive"
. " where invoice_number = :invoice_number and sequence = :sequence ");
$stmt->execute(array(
':invoice_number' => $_GET["inv"],
':sequence' => $_GET["seq"]
));
$result = $stmt->fetch();
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
i am trying to run this PDO Prepared statement
$stmt = $pdo_conn->prepare(
"INSERT into email_attachments (email_seq, attachment)
values (:email_seq, :attachment) ");
$stmt->execute(array(
':email_seq' => $admin_email_sequence,
':attachment' => $_SERVER["DOCUMENT_ROOT"].'/'.$settings["ticket_files_folder"].'/'.$ticketnumber.'-'.$currentDate.'-'.$at[filename], $at[attachment]
));
but I'm getting this error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens' in /home/integra/public_html/autocheck/support_emails.php:662 Stack trace: #0 /home/integra/public_html/autocheck/support_emails.php(662): PDOStatement->execute(Array) #1 {main} thrown in /home/integra/public_html/autocheck/support_emails.php on line 662
At the very end of the :attachment entry you have a comma instead of what I assume should be a period.
.$at[filename], $at[attachment]
^-- here
This causes the Exception because you have 2 labels in your query, and 3 elements in your array.
You have an extra ) inside your execute array, also you have an extra array element ($at[attachment])
Try this code
$stmt = $pdo_conn->prepare("INSERT into email_attachments (email_seq, attachment) values (:email_seq, :attachment) ");
$stmt->execute(array(
':email_seq' => $admin_email_sequence,
':attachment' => $_SERVER["DOCUMENT_ROOT"] . '/' . $settings["ticket_files_folder"] . '/' . $ticketnumber . '-' . $currentDate . '-' . $at[filename]
));