ID: 15477
Updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
-Status: Open
+Status: Closed
Bug Type: Strings related
Operating System: RedHat 7.1
PHP Version: 4.1.1
New Comment:
How stupid am I!?
I was echoing back $sql to a browser.
On viewing the source, it showed that there were some parts of the
string with double spaces (which browsers ignore). Now fixed it.
Previous Comments:
------------------------------------------------------------------------
[2002-02-09 18:40:20] [EMAIL PROTECTED]
The code you have supplied 'as is' works fine.
However, I've got my code inside of a class, after I've done the
ereg_replace I'm assigning $this->sql = $sql; then from the
instantiating php file I'm doing echo $handler->sql - which is where
the problem manifests.
I've tried modifying the string handle from $sql to $sql1 incase thier
is somekind of conflict somewhere, but I still get the same results.
------------------------------------------------------------------------
[2002-02-09 18:26:11] [EMAIL PROTECTED]
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
------------------------------------------------------------------------
[2002-02-09 18:08:39] [EMAIL PROTECTED]
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'
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=15477&edit=1