Note that there are some explanatory texts on larger screens.

plurals
  1. POInvalid parameter number error in Codeigniter
    primarykey
    data
    text
    <p>I am working on a process in Codeigniter to take a user-uploaded image (managed using the CI upload library) and insert it into a varbinary(max) field in a SQLServer database. My controller and model code are as follows.</p> <pre><code>if($this-&gt;upload-&gt;do_upload($upload_name)) { //get temp image $tmpName = $config['upload_path'] . $config['file_name']; // Read it into $data variable $fp = fopen($tmpName, 'rb'); $data = fread($fp, filesize($tmpName)); fclose($fp); //insert into DB $this-&gt;the_model-&gt;storeImage($data, $user_id); //delete temp image unlink($config['upload_path'] . $config['file_name']); } /***** Function from the_model ************/ function storePropertyImage($image_data, $user_id) { $my_db = $this-&gt;load-&gt;database('admin'); $stmt = "INSERT INTO my_table (UserID, ImageData) VALUES (" . $my_db-&gt;escape($user_id) . ", " . $my_db-&gt;escape($image_data) . ")"; $insert = $my_db-&gt;query($stmt); return $insert; } </code></pre> <p>This all seems like it should be OK but when I run the code, I get the error: </p> <pre><code>Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters' in {my app path}\helpers\mssql_helper.php on line 213 </code></pre> <p>I've done some googling on this error message and the results seem to indicate this is the result of there being a colon character in the $data value being sent to the model, making the DB think that I am trying to pass a named parameter when I am not. However I haven't been able to find any reports that match my specific use case or that have much info on how to correct the error.</p> <p>I'd appreciate any insight on where I might be tripping up.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload