php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33331 PHP doesn't like the MySQL RIGHT() command
Submitted: 2005-06-14 04:40 UTC Modified: 2005-06-14 08:57 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: internet at cratemedia dot com Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 4.3.10 OS: Linux web2 2.4.27
Private report: No CVE-ID: None
 [2005-06-14 04:40 UTC] internet at cratemedia dot com
Description:
------------
PHP will not successfully execute the RIGHT() command in 
a mysql_query(). It executes successfully, affects 1 
row, but doesn't actually substring the field from the 
right. The same query works, directly in MySQL, but not 
through the mysql_query() offered in PHP.

Example: UPDATE sales SET ccnum=RIGHT(ccnum,4) WHERE 
ID=3301 LIMIT 1

Reproduce code:
---------------
$sql="UPDATE sales SET ccnum=RIGHT(ccnum,4) WHERE ID=$ID LIMIT 1";
$results = mysql_query($sql);

Expected result:
----------------
It should shorten the ccnum field to 4 characters 
starting at the right. Others have suggested just using 
the SUBSTRING() mysql command, but that doesn't work 
from the right, which is what I need.

Actual result:
--------------
Executes without error, but doesn't shorten the string.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-14 05:25 UTC] internet at cratemedia dot com
The RIGHT() command works on columns that are of the 
type 'text' but not on biging(20).
 [2005-06-14 08:57 UTC] georg@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Aug 07 06:00:03 2025 UTC