Re: Does PHP have an end-of-file problem.



Your coding style reminded me of C for some reason (nothing wrong with
that, just an observation).

Good luck with your site,
Curtis

On Dec 29, 3:49 pm, George Webb <nom...@xxxxxxx> wrote:
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

.



Relevant Pages

  • Re: Does PHP have an end-of-file problem.
    ... If you switch to single quotes, ... execute variable interpolation on strings on which it's not needed. ... indexed, and one associative array. ...
    (comp.lang.php)
  • Re: Dynamic directory handles?
    ... Cost to develop code that saves those cycles: ... I use single quotes unless I require one of the two extra ... Some strings contain variables, some strings don't. ...
    (comp.lang.perl.misc)
  • Re: Handling Strings in SQL server
    ... First, if your application has problems with the "O'Malley" issue (imbedded single quotes in strings), you need to address the problem at the root. ... Consider than if your code permits users to enter strings with embedded single quotes, they can also introduce SQL injection attacks. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: How to deal with "{" in system("...command..."); ?
    ... I want to replace all strings of one blank followed by 8 dots ... You could use single quotes instead of double quotes, ... There's perhaps a better and shorter format of this command. ...
    (comp.lang.perl.modules)
  • Re: [PHP] Re: optimilize web page loading
    ... >>> doubles for the email. ... because the strings are not concatenated before output. ... adapting to using echo (to the ob to avaoid printing forty ... So, it looks like for echoing at least then single quotes are actually marginally slower than double quotes, and interpolation is faster. ...
    (php.general)