[PHP] Ascii Value

2002-06-18 Thread James Drabb

Hey *,

In C I can cast a char 'j' to an int and get it's ascii value.  Is there a funciton in 
PHP
to do this with a string containing a single char (i.e. "j")?  I could write a big
switch for all the chars of the alphabet, however I was hoping for a better approach?

Jim Drabb

-- 
-
Never ask a geek why, just nod your head and slowly back away
-----
James Drabb JR
Programmer Analyst
Darden Restaurants
Business Systems
[EMAIL PROTECTED]
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Post

2002-06-20 Thread James Drabb

Hey PHPers,

I was wondering if there is a setting to make PHP not change the posted data?  For
example I am posting a first and Last name and if I put in O'Hara for the last name
PHP returns O\'Hara.  I would prefer getting just O'Hara back and then replacing
the ' with '' myself.  I need to be able to put the posted data into MySQL and MS SQL.
MS SQL doesn't like the O\'Hara format.

Thanks,

Jim Drabb

-- 
-
Never ask a geek why, just nod your head and slowly back away
-----
James Drabb JR
Programmer Analyst
Darden Restaurants
Business Systems
[EMAIL PROTECTED]
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Profiling

2002-06-23 Thread James Drabb

Hello all,

Does PHP have any built in functions to do simple profiling on a page?  Or
should
I just use $time1=time(); do_stuff(); $time2=time(); echo $time2-$time1;?

Thanks,

Jim Drabb

--
-
Never ask a geek why, just nod your head and slowly back away
-
James Drabb JR
Programmer Analyst
[EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] output_buffering

2002-06-23 Thread James Drabb

I was running some speed tests on a page that returns 1000 records from
a db and spits them into a table.  I have output_buffering Off in my
php.ini file because of the statement below:

; Output buffering allows you to send header lines (including cookies) even
; after you send body content, at the price of slowing PHP's output layer a
; bit.  You can enable output buffering during runtime by calling the output
; buffering functions.  You can also enable output buffering for all files
by
; setting this directive to On.  If you wish to limit the size of the buffer
; to a certain size - you can use a maximum number of bytes instead of 'On',
as
; a value for this directive (ex., output_buffering=4096).
output_buffering = Off

However the page takes 7 seconds to load with output_buffering = Off
and 1 second with output_buffering = On!  What is up with that?  Have most
of you found output buffering faster?

Jim Drabb

--
-
Never ask a geek why, just nod your head and slowly back away
---------
James Drabb JR
Programmer Analyst
[EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Truncation

2002-06-25 Thread James Drabb

Hey *,

I am converting an ASP site to use PHP.  Right now I am running
Apache/2.0.36 (Win32) PHP/4.2.1 and connecting to MS SQL 2000.  I plan
on moving to Linux MySQL once finished.  I have one page that shows current
job openings here at our company for internal use.  The job description is stored
in ms sql 2000 and can contain some html markup.  When I pull the page up in
ASP/IIS the Job Description is shown in full (up to 4096 chars).  However, in PHP
the text is being truncated.  Is there something in PHP to stop this?

I changed mssql.textlimit and mssql.textsize in php.in to:

; Valid range 0 - 2147483647.  Default = 4096.
mssql.textlimit = 16384
; Valid range 0 - 2147483647.  Default = 4096.
mssql.textsize = 16384

Thanks for any help,

Jim Drabb

-- 
-
Never ask a geek why, just nod your head and slowly back away
-
James Drabb JR
Programmer Analyst
Darden Restaurants
Business Systems
[EMAIL PROTECTED]
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Re: Stored Procedures

2002-07-06 Thread James Drabb

On Sat, 06 Jul 2002 01:16:28 -0500
"Richard Lynch" <[EMAIL PROTECTED]> wrote:

> > I'm using a postgres datbase for my PHP project, how do I make stored 
> >procedures?  Or if no SPs then what would be recomendation for building 
> >simple/reuseable "Put" and "Get" procedures for my data?
> 
> Well, if nothing else, PostgreSQL does support user-defined functions,
> going'way back.
> 
> Technically not quite the same as a Stored Procedure, but should do what
> you need.
> 
> Of course, *WHY* you want to add such a ridiculous layer of overhead to
> your code is beyond my comprehension, but that's another story... :-)
> 
> I once worked at a place where the head IT guy was convinced Stored
> Procedures were the bomb.
> 
> Alas, he didn't tell me that until after I had coded the most of the ASP
> application without them.
> 
> Meanwhile, deadlines were looming, and I wasn't migrating to Stored
> Procedures, since I was furiously coding all the change requests (well,
> okay, they were really "Features The Client Thought Up During Development
> Because He Didn't Design Anything Beforehand" but they were called change
> requests anyway.
> 
> So a new guy they hired was assigned the task of converting all my:
> 
> <%
>   $query = "select blah, blah, blah";
> %>
> 
> code into Stored Procedures.
> 
> Guess what?
> 
> *ONE* of the pages was a little faster.  The other hundred pages were just
> as fast with $query = "select..."
> 
> Guess what else?
> 
> When we migrated from SQL 6.5 to SQL 7.x, all the Stored Procedures puked.
> 
> Guess what else?
> 
> Before the Stored Procedure conversion, it was trivial to Push from the
> Dev box to the Production box.
> After the conversion, it was a nightmare.  I ended up writing an Admin
> tool to connect to both databases and compare the text of the Stored
> Procedure source (buried in badly-designed Microsoft tables) between the
> Dev Server and the Production Server.
> Of course, in the first round *ALL* the procedures were different, since
> Microsoft added/stripped altered the text of the Stored Procedures while
> copying them from Dev to Server in the first place.
> 
> Guess what else?
> 
> There weren't enough queries "the same" that there was any real code
> re-use.
>  I coded the application and the pages were designed properly in the first
> place, so very seldom were two queries the same.  If they had been the
> same, I would have put those two pages (features) into one.
> 
> Guess what else?
> 
> The new guy was in such a hurry, that in the few instances that two
> queries*were* the same, he didn't bother to figure that out, so we ended
> up with some Stored Procedures that were duplicates of others in
> everything except their name.
> 
> Guess what else?
> 
> The @@INSERT_ID I was using worked differently inside a Stored Procedure,
> so I wasted days tracking down a bug introduced by the Stored Procedures.
> 
> Guess what else?
> 
> When I went to edit the pages he had changed, I'd  have no idea what data
> was coming back from the Stored Procedure, without reading way too many
> lines of code.  With the $query = "select x, y, z" style, I knew exactly
> what I was getting.
> 
> All in all, the company spent 4 weeks of this guys' life, 40 hours a week,
> making the application less portable, less maintainable, and no faster.
> 
> And people wonder why I see little value in Stored Procedures.
> 
> -- 
> Like Music?  http://l-i-e.com/artists.htm
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

Stored procedures are like any other type of programming construct.
You can do them right or you can do them wrong.  When making a stored
procedure you should stick to ansi SQL as much as possible.  Most of
my stored procedures I can move from a SQL Server 2000 box to an Oracle
8i box with not problems at all.   Stored procedures are NOT over head.
If you need to change an SQL statement, then you would have to search
through all your code to make changes intstead of just one stored proc.
If you don't see any speed increase from stored procs then you are doing
something wrong.  Stored procs are compile SQL statements.  Every
time a your php page does something like $query="Select * from MyTable"
the DB needs to parse the query and create an execution plan.  The stored
procs do it only ONCE the first time it is ran and all the other calls to
it save you many millisecond to seconds.  That might not sound like much
but if you have a site with more than 5 users you wil

[PHP] iptables logging

2002-07-06 Thread James Drabb

Hey group,

I have set up iptables based on the BLFS book.  I have a rule like:
# Log everything else:  What's Windows' latest exploitable
# vulnerability?
$IPTABLES -A INPUT -j LOG --log-prefix "FIREWALL:INPUT "
The output is going into /var/log/kern.log is there anyway I can
send it to a seperate file say /var/log/firewall.log?

Thanks,

Jim Drabb

-- 
James Drabb JR - Programmer Analyst - Orlando, FL - [EMAIL PROTECTED]
-

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] iptables logging

2002-07-06 Thread James Drabb

Opps, I sent to the wrong list : )

Sorry,

Jim Drabb

-- 
James Drabb JR - Programmer Analyst - Orlando, FL - [EMAIL PROTECTED]
-

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Re: Stored Procedures

2002-07-06 Thread James Drabb

On Sat, 06 Jul 2002 15:27:47 -0500
"Richard Lynch" <[EMAIL PROTECTED]> wrote:

> Do you have *ANY* idea how quickly:
> 
> "select * from MyTable" can be parsed and an execution plan selected?!
> 
> It's CHUMP CHANGE in time.
> 
> *ONLY* if your SQL is so incredibly complicated that you can't even
> understand it will the parse/compile time of SQL be a factor in
> performance.

It is "CHUMP CHANGE" when you make a tinie web site with 2 users.  Do the
math.  If you have a SQL statement that takes 250 milliseconds to parse
and create an execution plan, then 250 * 1,000,000 page request per week
(which is what the site I finished averages, the company I
work for has 110,000 employees) = ??? This is second grade math.

No matter how you look at it, 10 extra milliseconds here or there
adds up when you work on a big site.  The db's I work with are not
simple "select foo from bar" queries.  An enterprise db is usually pretty
complex.  My main reason for posting a reply was not to start a stupid
flame war with you.  It was from stopping you from filling the heads of
new programmers on this list with bunk.  Stored procedures are not junk!
I wonder why they are the most requested feature for MySQL?  Why would all
the Big DB's (Oracle, DB2, PostgreSQL, SQL Server, etc.) support them
if they had no benifit?  The biggest benifit is SPEED, the second is
the ability to encapsulate the underlying database structure.  A DBA can
change the db structure at will as long as the sproc returns the same
columns.


-- 
James Drabb JR - Programmer Analyst - Orlando, FL - [EMAIL PROTECTED]
-

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php