php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #54921 Omit the extra line.
Submitted: 2011-05-25 06:51 UTC Modified: 2011-12-08 00:59 UTC
From: bimal at sanjaal dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.3.6 OS: Windows
Private report: No CVE-ID: None
 [2011-05-25 06:51 UTC] bimal at sanjaal dot com
Description:
------------
---
From manual page: http://www.php.net/function.mysql-query#Parameters
---

The following is not true:
The query string should not end with a semicolon.

Please correct the documentation. It works even with or without the ending semicolon.

We can run the query that end with semicolons.
PHP should not try to complete the queries itself with the semicolon.

Test script:
---------------
<?php
error_reporting(E_ALL|E_STRICT);
mysql_connect('localhost', 'root', 'toor');
mysql_select_db('test');

$rs = mysql_query('SELECT NOW() `time`;'); # Query with semicolon at the end
$current = mysql_fetch_assoc($rs);

echo $current['time'];
?>

Expected result:
----------------
Query with semicolon works well.

Actual result:
--------------
none

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-05-26 15:00 UTC] johannes@php.net
A "should" is something else from a "must not." This might fail depending on MySQL server and client lib versions and configuration. You should not rely on it.
 [2011-09-28 10:06 UTC] a at b dot c dot de
The semicolon in SQL is a statement *separator*, not a statement *terminator* (as it is in PHP).

Putting a semicolon at the end of a query effectively means you are making two queries - the second one empty.
 [2011-12-08 00:59 UTC] philip@php.net
It has been determined that this is not be a bug.
 [2011-12-08 00:59 UTC] philip@php.net
-Status: Open +Status: Bogus
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 15:00:01 2026 UTC