|
Posted by Curtis on 12/28/06 02:54
Just curious, but George, have you programmed in C or C++ before?
For what it's worth, here are some things you can do to increase
performance a bit. In PHP, strings do not need to have double quotes
unless they contain variables or whitespace metacharacters like \t, \n,
\r, etc. If you switch to single quotes, the PHP interpreter won't
execute variable interpolation on strings on which it's not needed.
>if (!$mysql=mysql_connect($host, $user, $password)) {
> printf("Connect failed: %s\n", mysql_connect_error());
> exit();
>
> mysql_close($mysql);
>}
Not related to performance, but after exit() is called, nothing is
executed, so there's no need to close the connection, unless you do it
before. At the very least, you'll get rid of a couple extra lines :P
You also call mysql_fetch_array, which generates two arrays, one
indexed, and one associative array (hash, dictionary, etc.). If you
call mysql_fetch_assoc() instead, you'll also save some time.
I guess this wouldn't affect you too much, unless you had an enormous
amount of data to sort through.
Curtis
[Back to original message]
|