SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member prinzeLobitana's Avatar
    Join Date
    Feb 2014
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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

    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 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... :)
    THANK YOU VERY MUCH...

  2. #2
    #titanic {float:none} silver trophy
    molona's Avatar
    Join Date
    Feb 2005
    Location
    from Madrid to Heaven
    Posts
    8,220
    Mentioned
    237 Post(s)
    Tagged
    1 Thread(s)
    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)

  3. #3
    SitePoint Evangelist
    Join Date
    Oct 2005
    Location
    Michigan, USA
    Posts
    434
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    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.
    PHP Code:
    $q->execute(array(':sas'=>$date,':asas'=>$doc_type,':asafs'=>$desc,'ffff'=>$office,':statttt'=>$status,':dot'=>$dateo,':rd'=>$rb,':ft'=>$ft)); 
    - Robert


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •