VALUES (:sas,:asas,:asafs,:offff,:statttt,:dot,:rd,:ft)";

[SIZE=2][FONT=microsoft sans serif][B]Can someone help me if what does it means of this?

VALUES (:sas,:asas,:asafs,:offff,:statttt,:dot,:rd,:ft)";
I really don’t know what it is.

This is the original code…


<?php
include('connect.php');

$date = $_POST['date'];
$doc_type = $_POST['doc_type'];
$desc = $_POST['desc'];
$office = $_POST['office'];
$status = $_POST['status'];
$dateo = $_POST['dateo'];
$rb = $_POST['rb'];
$ft = $_POST['ft'];

// query
$sql = "INSERT INTO transaction (date,doc_type,description,office,status,dateout,receive_by,ft) VALUES sas,:asas,:asafs,ffff,:statttt,:dot,:rd,:ft)";
$q = $db->prepare($sql);
$q->execute(array(':sas'=>$date,':asas'=>$doc_type,':asafs'=>$desc,'ffff'=>$office,':statttt'=>$status,':dot'=>$dateo,':rd'=>$rb,':ft'=>$ft));
header("location: index.php");


?>


AND I WANT TO CHANGE THE CODE LIKE THIS...

<?php
include('connect.php');

$date = $_POST['date'];
$student_ID = $_POST['student_ID'];
$full_name = $_POST['full_name'];
$year_section = $_POST['year_section'];
$payment_description = $_POST['payment_description'];
$amount = $_POST['amount'];
$received_by = $_POST['received_by'];

// query
$sql = "INSERT INTO transaction (date,student_ID,full_name,year_section,payment_description,amount,received_by) VALUES sas,:asas,:asafs,ffff,:statttt,:dot,:rd,:ft)";
$q = $db->prepare($sql);
$q->execute(array(':sas'=>$date,':asas'=>$student_ID,':asafs'=>$full_name,'ffff'=>$year_section,':statttt'=>$payment_description,':dot'=>$amount,':rd'=>$received_by));
header("location: index.php");


?>

I AM SO CONFUSED IN THE VALUES(:sas,:asas,:asafs,:offff,:statttt,:dot,:rd,:ft)";???
WHAT IS THIS???

THIS IS THE ERROR WHEN I CLICK SAVE IN MY ADD NEW TRANSACTION…
Fatal error: Uncaught exception ‘PDOException’ with message ‘SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens’ in C:\xampp\htdocs\recordmanagement\main\reg.php:15 Stack trace: #0 C:\xampp\htdocs\recordmanagement\main\reg.php(15): PDOStatement->execute(Array) #1 {main} thrown in C:\xampp\htdocs\recordmanagement\main\reg.php on line 15

THIS CODE IS FOR ADDING A TRANSACTION TO MY RECORD MANAGEMENT SYSTEM.
I JUST DOWNLOAD IT FROM SOURCECODE.COM THEN I JUST EDIT IT .

I HOPE SOMEONE CAN HELP ME ON THIS MATTER… :slight_smile:
THANK YOU VERY MUCH…[/B][/FONT][/SIZE]

I suspect that the error comes because your SQL query needs 8 variables (because you’re adding date for 8 fields:
[date,doc_type,description,office,status,dateout,receive_by,ft)

I can see in your query that when you match the values :sas losses its dots and becomes sas… I suspect that’s not right and that’s the reason that the script doesn’t think is receiving the right amount of variables (which is the error that you’re getting)

To answer your question, those are placeholder values. You can see later where the actual values are associated. I don’t know why the author decided to be so cryptic about it, though.


$q->execute(array(':sas'=>$date,':asas'=>$doc_type,':asafs'=>$desc,'ffff'=>$office,':statttt'=>$status,':dot'=>$dateo,':rd'=>$rb,':ft'=>$ft));