Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: - sql

<?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,:offff,:statttt,:dot,:rd,:ft)";
$q = $db->prepare($sql);
$q>execute(array(':sas'=>$date,':asas'=>$student_ID,':asafs'=>$full_name,':offff'=>$year_section,':statttt'=>$payment_description,':dot'=>$amount,':rd'=>$received_by));
header("location: index.php");
?>
I get the following error:
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
In the code I am also unsure about the meaning of these values:
(:sas,:asas,:asafs,:offff,:statttt,:dot,:rd,:ft);
I downloaded it from sourcecode, so it was not written by me.

There seems to be a field to much in the query. This:
$sql = "INSERT INTO transaction
(date,student_ID,full_name,year_section,payment_description,amount,received_by)
VALUES (:sas,:asas,:asafs,:offff,:statttt,:dot,:rd,:ft)";
should probably be:
$sql = "INSERT INTO transaction
(date,student_ID,full_name,year_section,payment_description,amount,received_by)
VALUES (:sas,:asas,:asafs,:offff,:statttt,:dot,:rd)";
as there is no matching value for the :ft field.
Whether this is because your missing an item in the values or if it's not needed I can't say.

Related

Uncaught PodioBadRequestError: "Must specify either 'embed' or 'url'"

I need to set value for an embed field in Podio, and this is my code:
$field_id='pdf-property-information';
$options=$item->fields[$field_id]->values;
if(empty($options))
$item->fields[$field_id] = new PodioEmbedItemField($field_id);
// Create embed
$embed = PodioEmbed::create(array('url' => $pdf_property_information));
// Set using object
$item->fields[$field_id]->values = $embed;
// Set using associative array
$item->fields[$field_id]->values = array('embed_id' => $embed->embed_id);
And this is the error I get:
Fatal error: Uncaught PodioBadRequestError: "Must specify either
'embed' or 'url'" Request URL: http://api.podio.com/item/826141668
Stack Trace: #0
/home/apibind/public_html/mail_chimp/podio-php-4.3.0/lib/Podio.php(355):
Podio::request('PUT', '/item/826141668', Array) #1
/home/apibind/public_html/mail_chimp/podio-php-4.3.0/models/PodioItem.php(183):
Podio::put('/item/826141668', Array) #2
/home/apibind/public_html/mail_chimp/podio-php-4.3.0/models/PodioItem.php(66):
PodioItem::update(826141668, Array, Array) #3
/home/apibind/public_html/sourcingplatform/trunk/add.php(403):
PodioItem->save() #4 {main} thrown in /podio-php-4.3.0/lib/Podio.php
on line 289
You have to pass the embed_id with array key "embed". Here your final line will be like,
// Set using associative array
$item->fields[$field_id]->values = array('embed' => $embed->embed_id);

Fatal error showing

Fatal error: Uncaught Error: Call to undefined function mysqli_result() in /home/prasanth/projects/ishen1/index.php:49 Stack trace: #0 {main} thrown
how to slove this
according to this answer https://stackoverflow.com/a/17707384/8284461 that function is inefficient, you can use mysqli_fetch_assoc() instead. for example:
while($row = mysqli_fetch_assoc($result)) {
$id = $row['ID'];
$name = $row['name'];
etc..
}

Making a delete DAO -> Uncaught exception 'PDOException'

I'm trying to make a dao which can delete a specific item once you click on the X
How did I try this? I'll begin with showing you the DAO:
public function delete($iddelete){
$sql = "DELETE FROM `wanthave`.`wanthave_items` WHERE `wanthave_items`.`id` = `iddelete` = :iddelete LIMIT 1";
$stmt = $this->pdo->prepare($sql);
$stmt->bindValue(':iddelete', $iddelete);
$stmt->execute();
return $stmt->fetch(PDO::FETCH_ASSOC);
}
This is how I setup my if structure in a controller:
if(isset($_GET['iddelete'])){
$this->itemDAO->delete($_GET['iddelete']);
}
Once I click on the X near the item I want to delete it goes to a page with in the end "&iddelete=(id of the item)". So actually when iddelete is set it's going to delete it.
But unfortunately I get this error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'iddelete' in 'where clause'' in /Applications/MAMP/htdocs/wanthave/dao/ItemDAO.php:56 Stack trace:
#0 /Applications/MAMP/htdocs/wanthave/dao/ItemDAO.php(56): PDO->prepare('DELETE FROM `wa...')
#1 /Applications/MAMP/htdocs/wanthave/controller/ItemController.php(198): ItemDAO->delete('89')
#2 [internal function]: ItemController->delete()
#3 /Applications/MAMP/htdocs/wanthave/controller/Controller.php(9): call_user_func(Array) #4 /Applications/MAMP/htdocs/wanthave/index.php(69): Controller->filter()
#5 {main} thrown in /Applications/MAMP/htdocs/wanthave/dao/ItemDAO.php on line 56
Line 56 = $stmt = $this->pdo->prepare($sql);
Any help?
public function delete($id){
$stmt = $this->pdo->prepare("DELETE FROM wanthave_items WHERE id = ?");
return $stmt->execute([$id]);
}

Rails 2 to Rails 3 - ActiveRecord::StatementInvalid

The following ActiveRecord calls result in InvalidStatement errors. This occurs when I even provide a hard-coded userid. The session dump shows a session variable "user_id" that has a valid value as well. Can someone help?
def index
#nav = []
#user = B2bUser.find(request.session[:user_id])
#privileges = B2bPrivilege.lookup_all request.session[:user_id]
end
## lookup_all method from b2b_privilege model
def B2bPrivilege.lookup_all current_user_id
return B2bPrivilege.find_by_sql("SELECT b2b_privileges.*, vendors.name AS vendor_name FROM b2b_privileges LEFT JOIN vendors ON vendors.id = b2b_privileges.vendor_id WHERE b2b_user_id = ?", current_user_id)
end
Processing by HomeController#index as HTML
Could not log "sql.active_record" event. NoMethodError: undefined method `name' for nil:NilClass
PG::Error: ERROR: zero-length delimited identifier at or near """"
LINE 1: ..."b2b_users".* FROM "b2b_users" WHERE "b2b_users"."" = $1 LI...
^
: SELECT "b2b_users".* FROM "b2b_users" WHERE "b2b_users"."" = $1 LIMIT 1
Completed 500 Internal Server Error in 13ms
ActiveRecord::StatementInvalid (PG::Error: ERROR: zero-length delimited identifier at or near """"
LINE 1: ..."b2b_users".* FROM "b2b_users" WHERE "b2b_users"."" = $1 LI...
^
: SELECT "b2b_users".* FROM "b2b_users" WHERE "b2b_users"."" = $1 LIMIT 1):
app/controllers/home_controller.rb:7:in `index'

NAudio: All mixer inputs must have the same WaveFormat

I converted a WaveProvider16 to a SampleProvider using Pcm16BitToSampleProvider. I then added it to a MixingSampleProvider. The logs did indicate that both are IeeeFloat. But the program halted at the AddMixerInput line and the error was All mixer inputs must have the same WaveFormat.
Any thought of what I have missed?
myWaveProvider = new MyWaveProvider16();
mySampleProvider = new Pcm16BitToSampleProvider(myWaveProvider);
mixerBusWaveFormat = WaveFormat.CreateIeeeFloatWaveFormat(8000, 1);
myMixer = new MixingSampleProvider(mixerBusWaveFormat);
myMixerSampleSource = new MixerSampleSource();
Debug.WriteLine("mySampleProvider waveformat: " + mySampleProvider.WaveFormat.ToString());
Debug.WriteLine("myMixer waveformat: " + myMixer.WaveFormat.ToString());
myMixer.AddMixerInput(mySampleProvider);
Output:
mySampleProvider waveformat: IeeeFloat
myMixer waveformat: IeeeFloat
A first chance exception of type 'System.ArgumentException' occurred in NAudio.dll
An unhandled exception of type 'System.ArgumentException' occurred in NAudio.dll
Additional information: All mixer inputs must have the same WaveFormat
User error: Sample rates mismatched.
This line:
myWaveProvider = new MyWaveProvider16();
should be:
myWaveProvider = new MyWaveProvider16(8000, 1);
Otherwise it defaults to 44100.