|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-02-09 18:08 UTC] lee dot bolding at ukonline dot co dot uk
the following script fails to work with both ereg_replace and str_replace.
$sql = "select table.id, table.user, table.pass, FROM table, WHERE table.id='1234' AND table.user='lee' AND ORDER BY table.id DESC";
This is being automatically generated based on the amount of arguments passed to the script (which explains the superflous ,'s and ANDs). So, I'm using ereg_replace to remove them like so:
$sql = ereg_replace(', FROM', ' FROM', $sql);
$sql = ereg_replace(', WHERE', ' WHERE', $sql);
$sql = ereg_replace('AND ORDER', 'ORDER', $sql);
$sql should be modified to:
select table.id, table.user, table.pass FROM table WHERE table.id='1234' AND table.user='lee' ORDER BY table.id DESC
However, it remains unchanged. With more investigation, the problem seems to be with any pattern that contains a space or special character.
PHP configured as follows:
'./configure' '--with-apache=../apache_1.3.22' '--prefix=/usr/local/apache/php' '--with-mysql' '--enable-track-vars' '--enable-ftp' '--with-curl' '--with-openssl=/usr/local/ssl' '--with-gd' '--enable-wddx' '--with-xml' '--enable-trans-id' '--with-sablot' '--with-ldap=/usr/local' '--enable-sysvsem' '--enable-sysvshm' '--with-pcre' '--enable-sockets' '--with-mm=/usr/local/lib/mm'
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 23:00:01 2025 UTC |
I can't reproduce this on 4.2.0-dev. What does the following script give you? (The output it gives me is below it.) <?php error_reporting(E_ALL); $sql = "select table.id, table.user, table.pass, FROM table, WHERE table.id='1234' AND table.user='lee' AND ORDER BY table.id DESC"; echo "Before: $sql\n"; $sql = ereg_replace(', FROM', ' FROM', $sql); $sql = ereg_replace(', WHERE', ' WHERE', $sql); $sql = ereg_replace('AND ORDER', 'ORDER', $sql); echo "After: $sql\n"; $sql = "select table.id, table.user, table.pass, FROM table, WHERE table.id='1234' AND table.user='lee' AND ORDER BY table.id DESC"; echo "Before: $sql\n"; $sql = str_replace(', FROM', ' FROM', $sql); $sql = str_replace(', WHERE', ' WHERE', $sql); $sql = str_replace('AND ORDER', 'ORDER', $sql); echo "After: $sql\n"; ?> Output: Before: select table.id, table.user, table.pass, FROM table, WHERE table.id='1234' AND table.user='lee' AND ORDER BY table.id DESC After: select table.id, table.user, table.pass FROM table WHERE table.id='1234' AND table.user='lee' ORDER BY table.id DESC Before: select table.id, table.user, table.pass, FROM table, WHERE table.id='1234' AND table.user='lee' AND ORDER BY table.id DESC After: select table.id, table.user, table.pass FROM table WHERE table.id='1234' AND table.user='lee' ORDER BY table.id DESC Torben