|
Posted by George Webb on 12/29/06 23:49
Curtis, no I'm not a programmer, just someone trying to put a database
on my web site. I do however appreciate your input and will amend my
script accordingly. Many thanks.
GW.
Curtis wrote:
> 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
>
Navigation:
[Reply to this message]
|