RE: [PHP] SELECT * FROM
| From: | Jon Haworth | Date: | Wed, 29 Aug 2001 15:35:23 +0000 |
| Subject: | RE: [PHP] SELECT * FROM | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-65036@lists.php.net to get a copy of this message | ||
Couple of other tips for you.
1. SELECT * is bad unless you really need every field. If you don't, specify
which ones you want - the query will perform better.
$s = "SELECT * FROM News"; // bad
$s = "SELECT NewsHeadline, NewsTeaser FROM News"; // better
2. You appear to be connecting to your database (a) as root and (b) without
a password (although you may have modified the code, so I'm not sure). This
is even worse than SELECT * :-)
Cheers
Jon
-----Original Message-----
From: Tarrant Costelloe [mailto:tcostelloe@insur-e.net]
Sent: 29 August 2001 15:55
To: 'php-general@lists.php.net'
Subject: [PHP] SELECT * FROM
Hello all,
I have a designing a website of which people can submit news to, this works
fine. Just on the main page I have the following code (snippet);
<?php
$db = mysql_connect("localhost", "root");
mysql_select_db("tolkiengossip",$db);
$result = mysql_query("SELECT * FROM news",$db);
<snip>
Any help would be gratefully apreciated!
Kind Regards
Tarrant Costelloe (Taz)