georg           Sun Feb 15 15:23:05 2004 EDT

  Modified files:              
    /php-src/ext/mysqli mysqli_api.c 
  Log:
  fixed several binding problems
  
  
http://cvs.php.net/diff.php/php-src/ext/mysqli/mysqli_api.c?r1=1.70&r2=1.71&ty=u
Index: php-src/ext/mysqli/mysqli_api.c
diff -u php-src/ext/mysqli/mysqli_api.c:1.70 php-src/ext/mysqli/mysqli_api.c:1.71
--- php-src/ext/mysqli/mysqli_api.c:1.70        Wed Feb 11 03:34:07 2004
+++ php-src/ext/mysqli/mysqli_api.c     Sun Feb 15 15:23:05 2004
@@ -15,7 +15,7 @@
   | Author: Georg Richter <[EMAIL PROTECTED]>                                |
   +----------------------------------------------------------------------+
 
-  $Id: mysqli_api.c,v 1.70 2004/02/11 08:34:07 georg Exp $ 
+  $Id: mysqli_api.c,v 1.71 2004/02/15 20:23:05 georg Exp $ 
 */
 
 #ifdef HAVE_CONFIG_H
@@ -111,6 +111,11 @@
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of elements in 
type definition string doesn't match number of bind variables");
        }
 
+       if (argc - start != stmt->stmt->param_count) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of variables 
doesn't match number of parameters in prepared statement");
+               RETURN_FALSE;
+       }
+
        /* prevent leak if variables are already bound */
        if (stmt->param.var_cnt) {
                php_free_stmt_bind_buffer(stmt->param, FETCH_SIMPLE);
@@ -236,6 +241,11 @@
        
        var_cnt = argc - start;
 
+       if (var_cnt != stmt->stmt->field_count) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of bind variables 
doesn't match number of fields in prepared statmement.");
+               RETURN_FALSE;
+       }
+
        /* prevent leak if variables are already bound */
        if (stmt->result.var_cnt) {
                php_free_stmt_bind_buffer(stmt->result, FETCH_RESULT);
@@ -295,7 +305,8 @@
                        case MYSQL_TYPE_TIMESTAMP:
                        case MYSQL_TYPE_DECIMAL:
                                stmt->result.buf[ofs].type = IS_STRING; 
-                               stmt->result.buf[ofs].buflen = (stmt->stmt->fields) ? 
stmt->stmt->fields[ofs].length + 1: 256;
+                               stmt->result.buf[ofs].buflen =
+                                       (stmt->stmt->fields) ? 
(stmt->stmt->fields[ofs].length) ? stmt->stmt->fields[ofs].length + 1: 256: 256;
                                stmt->result.buf[ofs].buffer = (char 
*)emalloc(stmt->result.buf[ofs].buflen);
                                bind[ofs].buffer_type = MYSQL_TYPE_STRING;
                                bind[ofs].buffer = stmt->result.buf[ofs].buffer;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to