diff options
author | Andrey Hristov <andrey@php.net> | 2005-08-06 16:38:48 +0000 |
---|---|---|
committer | Andrey Hristov <andrey@php.net> | 2005-08-06 16:38:48 +0000 |
commit | 313ff9998ea882b4ba33d06825d099570711c6ac (patch) | |
tree | 9dbe20201cc2be6198ea2a94842469ecd4992559 /ext | |
parent | dcc18b6d6f77b60211c54e82a9a708fc04cee207 (diff) | |
download | php-git-313ff9998ea882b4ba33d06825d099570711c6ac.tar.gz |
add error checking
Diffstat (limited to 'ext')
-rw-r--r-- | ext/mysqli/mysqli_nonapi.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c index 7387b2e60b..a1ce0079d3 100644 --- a/ext/mysqli/mysqli_nonapi.c +++ b/ext/mysqli/mysqli_nonapi.c @@ -213,11 +213,21 @@ PHP_FUNCTION(mysqli_query) MYSQL_RES *result; char *query = NULL; unsigned int query_len; - unsigned long resultmode = 0; + unsigned long resultmode = MYSQLI_STORE_RESULT; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|l", &mysql_link, mysqli_link_class_entry, &query, &query_len, &resultmode) == FAILURE) { return; } + + if (!query_len) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty query"); + RETURN_FALSE; + } + if (resultmode != MYSQLI_USE_RESULT && resultmode != MYSQLI_STORE_RESULT) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid value for resultmode"); + RETURN_FALSE; + } + MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL*, &mysql_link, "mysqli_link"); MYSQLI_DISABLE_MQ; |