[TriLUG] PHP strange code question
David McDowell
turnpike420 at gmail.com
Thu Jan 20 13:22:37 EST 2005
solution:
FC3 version of PHP at this moment is 4.3.10-3.2 and it apparently has
a bug or issue with freetds or a bug in itself which doesn't pick up
the returned true from MSSQL when the SQL query properly executes.
You can comment your "or die" statements in mssql_query(); lines where
you will be performing an INSERT, UPDATE or DELETE (as SELECT appears
to work fine and return 1 for true as expected)... OR... you maybe
able to try this (from the php-mssql packager):
--------------
As far as I see it it could be either a bug that will be fixed in next
PHP update or a change in the FreeTDS interface (similar to the one
when they stopped trimming trailing spaces on char(N) values)). If
there is a new bugfix PHP release, there will be a new php-mssql.
you can work around it usint @@ROWCOUNT to test if the record was
really inserted:
add :
$query1 .= '; select @@rowcount as records_added;';
the returned row should have records_added=1 if a record was inserted.
--------------
Anyway... here's my solution... forget trying to use Fedora Core X for
anything in production. Currently I'm installing and configuring
CentOS 3.4 and will be using the php-mssql RHEL 3 package. I haven't
tried the ROWCOUNT thing nor have a finished configuring my first
CentOS install yet, but I'm expecting better results. YMMV.
thanks,
David McD
On Tue, 18 Jan 2005 12:44:47 -0500, David McDowell
<turnpike420 at gmail.com> wrote:
> More follow-up here. I'm curious to know how many of you might be
> running FC3 and PHP and if you are, are you experiencing things that
> don't appear ordinary, or as they were in previous FCx installations?
> (I skipped FC2 for anyone counting) Besides this wacky stuff which
> I'm still working on b/c of MSSQL, other things are going nuts too.
> One of the things I discovered is that PHP in FC3 by default sets:
>
> error_reporting = E_ALL
> display_errors = Off
>
> while FC1 sets:
>
> error_reporting = E_ALL & ~E_NOTICE
> display_error = On
>
> It took me a little bit of learning to figure that out. In FC3 when
> we turned on display_errors (b/c this is our dev box), all our PHP
> code went completely wacky when the notices started popping up on the
> screen, things just out of hand. Finally we figured out we could use
> ~E_NOTICE to exclude them from the error_reporting. It would seem
> they changed a number of defaults which caught us off gaurd here.
> Have others of you come across the same realizations??
>
> (Of course for a production system, you will want display_errors = Off)
>
> thanks,
> David McD
>
> On Mon, 17 Jan 2005 21:36:24 -0500, David McDowell
> <turnpike420 at gmail.com> wrote:
> > Remeber this thread? I finally got through to the rpm packager of the
> > php-mssql stuff from phprpms.sf.net and it would appear he has seen
> > the same issue with machines configured with mod_auth_* particularly
> > ldap... which is the module I have to use for my Apache auth with
> > Active Directory. So, looks like there isn't an answer, I'll be
> > working with him passing around logs and test cases so he can get it
> > figured out.
> >
> > thanks for all the previous thoughts on this one... :)
> > All things mssql work except the execution of the actual query via
> > mssql_query();
> > That's the only one borked which doesn't get a proper response from
> > the MSSQL server. The SQL commands do execute, it's just lacking the
> > response to tell it so, thus invariably, the dir ('the query failed')
> > occurs thus shutting down the rest of the PHP code. If anyone wants
> > me to post when it is fixed, or the workaround, I can, just let me
> > know. (Since I know there aren't many out there doing this.)
> >
> > thanks,
> > David McD
> >
> > On Mon, 10 Jan 2005 13:25:45 -0500, David McDowell
> > <turnpike420 at gmail.com> wrote:
> > > Ok... couple things... there is nothing in /etc/php.d and no other
> > > location for that folder, so I guess nothing is affecting it via that.
> > > I did restart httpd again just to be sure and still no change in
> > > results in the output of phpinfo().
> > >
> > > This particular machine just happens to be one still configured my OLD
> > > way if you are familiar with my LA(MSSQL)P thread.
> > > http://www.turnpike420.net/linux/Apache_PHP_FreeTDS_MSSQL2000.old.txt
> > >
> > > And the new way is something I'm working on moving them to starting today.
> > > http://www.turnpike420.net/linux/Apache_PHP_FreeTDS_MSSQL2000.txt
> > >
> > > SO, maybe something in that wacky config has be borked?? I guess
> > > since I'm also moving all my systems to the new config (hopefully
> > > before this week is over) I'll have to wait and re-address this then?
> > >
> > > thanks for you help so far, wish I knew why it wasn't changing. I'll
> > > still try things if you have other ideas in case others are
> > > interested.
> > >
> > > David
> > >
> > >
> > > On Mon, 10 Jan 2005 10:55:04 -0500, Joseph Tate <dragonstrider at gmail.com> wrote:
> > > > Yes, a restart of httpd is required when you update php.ini. Make
> > > > sure that there's nothing in /usr/local/lib/php.d that would override
> > > > the php.ini values. Like maybe your mssql.ini file?
> > > >
> > > > On Mon, 10 Jan 2005 10:49:43 -0500, David McDowell
> > > > <turnpike420 at gmail.com> wrote:
> > > > > I have turned magic_quotes_gpc = Off and magic_quotes_sybase = On in
> > > > > my /usr/local/lib/php/php.ini file. PHP claims my config path is
> > > > > /usr/local/lib and I don't have any other php.ini files. Yet, when I
> > > > > run phpinfo(); in a web page, those values are not updated... gpc = On
> > > > > and sybase = Off still. Why wouldn't they change? Also, you'd think
> > > > > our application would "break" until we recode it to match this
> > > > > change... the app is still fine as well. So it would appear php.ini
> > > > > is updated but isn't?? (yup, I even restarted httpd for the heck of
> > > > > it)
> > > > >
> > > > > thanks,
> > > > > David
> > > > >
> > > > > On Fri, 7 Jan 2005 17:31:36 -0500, Joseph Tate <dragonstrider at gmail.com> wrote:
> > > > > > On Fri, 7 Jan 2005 16:10:04 -0500, David McDowell <turnpike420 at gmail.com> wrote:
> > > > > > > This does not seem to work or meet our needs (escaping the apostrophe):
> > > > > > > $Event = addslashes($_POST['event']);
> > > > > > >
> > > > > > > I hope I have given enough information for parsing. Anything you see
> > > > > > > you can throw my way would be much appreciated.
> > > > > > >
> > > > > >
> > > > > > There are usually two solutions to the problem you're describing. The
> > > > > > first is to turn magic-quotes on in your php.ini file. Then no
> > > > > > special quoting is necessary for DB inserts, but you may need them at
> > > > > > other points in time i.e. instead of adding quotes everywhere you
> > > > > > insert into the database, you'll need them when you are not inserting
> > > > > > into a database (i.e. writing to a file).
> > > > > >
> > > > > > If you make that change, make sure you test all your other PHP code
> > > > > > for breakage. If magic_quotes_gpc is already on, you may need to
> > > > > > change the quoting type. Look in the ini file for the word sybase.
> > > > > > That should help you figure out which type of quoting you need.
> > > > > >
> > > > > > The second option is to use the DB specific escape_string function
> > > > > > like mysql_escape_string. Unfortunately I don't see one for mssql.
> > > > > > You are probably trying to use addslashes when magic_quotes are on,
> > > > > > which ends up escaping the escapes, so instead of \' going into the
> > > > > > SQL query, you'll have \\\'.
> > > > > >
> > > > > > --
> > > > > > Joseph Tate
> > > > > > Personal e-mail: jtate AT dragonstrider DOT com
> > > > > > Web: http://www.dragonstrider.com
> > > > > > --
> > > > > > TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> > > > > > TriLUG Organizational FAQ : http://trilug.org/faq/
> > > > > > TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
> > > > > > TriLUG PGP Keyring : http://trilug.org/~chrish/trilug.asc
> > > > > >
> > > > > --
> > > > > TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> > > > > TriLUG Organizational FAQ : http://trilug.org/faq/
> > > > > TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
> > > > > TriLUG PGP Keyring : http://trilug.org/~chrish/trilug.asc
> > > > >
> > > >
> > > >
> > > > --
> > > > Joseph Tate
> > > > Personal e-mail: jtate AT dragonstrider DOT com
> > > > Web: http://www.dragonstrider.com
> > > > --
> > > > TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> > > > TriLUG Organizational FAQ : http://trilug.org/faq/
> > > > TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
> > > > TriLUG PGP Keyring : http://trilug.org/~chrish/trilug.asc
> > > >
> > >
> >
>
More information about the TriLUG
mailing list