Note that there are some explanatory texts on larger screens.

plurals
  1. POMSSQL PHP Error: invalid precision value hy104
    text
    copied!<p>Have been trying to debug this for hours and no outcome. Please help. Environment: PHP5.3 talking to MSSQL2005/8 with Microsoft MSSQL Driver for PHP SQL Query: </p> <pre><code>INSERT INTO [dbo].[Enquiry] ([FullName], [FirstName], [Surname], [ContactPhone], [WorkPhone], [ContactMobile], [EmailAddress], [Callwhen], [LoanType], [EnquiryDate], [Suburb], [State], [PostCode], [HiddenField], [CFIssue01], [CFIssue02], [CFIssue03], [CFIssue04], [ProductID]) VALUES ('asdf asdf','asdf','asdf','03 12312312','02 12312312', '','','10:12 AM 02/08/11','CF','2011-08-02 10:12:45', 'asdf','NSW','1231','245678','asdfasdf1222','','','','CF') </code></pre> <p>If I run this query with <code>sqlsrv_query()</code> and it works well. </p> <p>To prevent SQL Injection, I prefer to use prepared statement <code>sqlsrv_prepare()</code> and <code>sqlsrv_execute()</code>.</p> <p>To do prepared statement, I have:</p> <pre><code>INSERT INTO [dbo].[Enquiry] ([FullName], [FirstName], [Surname], [ContactPhone], [WorkPhone], [ContactMobile], [EmailAddress], [Callwhen], [LoanType], [EnquiryDate], [Suburb], [State], [PostCode], [HiddenField], [CFIssue01], [CFIssue02], [CFIssue03], [CFIssue04], [ProductID]) VALUES "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,)" </code></pre> <p>Then I have params:</p> <pre><code>$params = array( &amp;$mm_fullname, &amp;$mm_firstname, &amp;$mm_surname, &amp;$mm_contactphone, &amp;$mm_workphone, &amp;$mm_contactmobile, &amp;$mm_emailaddress, &amp;$mm_callwhen, &amp;$mm_loantype, &amp;$mm_enquirydate, &amp;$mm_suburb, &amp;$mm_state, &amp;$mm_postcode, &amp;$mm_hiddenfield, &amp;$mm_cfissue01, &amp;$mm_cfissue02, &amp;$mm_cfissue03, &amp;$mm_cfissue04, &amp;$mm_productid ); </code></pre> <p>Then prepare the statement:</p> <pre><code>$stmt = sqlsrv_prepare( $conn, $tsql, $params)) </code></pre> <p>Then run the statement: <code>sqlsrv_execute( $stmt)</code> ......... ban! error here: </p> <pre><code>[0] =&gt; HY104 [SQLSTATE] =&gt; HY104 [1] =&gt; 0 [code] =&gt; 0 [2] =&gt; [Microsoft][SQL Server Native Client 10.0]Invalid precision value [message] =&gt; [Microsoft][SQL Server Native Client 10.0]Invalid precision value </code></pre> <p>Not sure what am I doing wrong..</p> <p>Update #1: convert all params to string - same error:</p> <pre><code>/* Assign parameter values. */ $mm_fullname = strval($firstname . " " . $lastname); $mm_firstname = strval($firstname); $mm_surname = strval($lastname); $mm_contactphone = strval($homenumber); $mm_workphone = strval($worknumber); $mm_contactmobile = strval($mobilenumber); $mm_emailaddress = strval($email); $mm_callwhen = strval(date('h:i A d/m/y')); $mm_loantype = strval("CF"); $mm_enquirydate = strval(date('Y-m-d H:i:s')); $mm_suburb = strval($suburb); $mm_state = strval($state); $mm_postcode = strval($postcode); $mm_hiddenfield = strval("245678"); $mm_cfissue01 = strval($creditissue1); $mm_cfissue02 = strval($creditissue2); $mm_cfissue03 = strval($creditissue3); $mm_cfissue04 = strval($creditissue4); $mm_productid = strval("CF"); $params = array( &amp;$mm_fullname, &amp;$mm_firstname, &amp;$mm_surname, &amp;$mm_contactphone, &amp;$mm_workphone, &amp;$mm_contactmobile, &amp;$mm_emailaddress, &amp;$mm_callwhen, &amp;$mm_loantype, &amp;$mm_enquirydate, &amp;$mm_suburb, &amp;$mm_state, &amp;$mm_postcode, &amp;$mm_hiddenfield, &amp;$mm_cfissue01, &amp;$mm_cfissue02, &amp;$mm_cfissue03, &amp;$mm_cfissue04, &amp;$mm_productid ); </code></pre>
 

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