eleven0 Posted February 22, 2008 Share Posted February 22, 2008 $query = "SELECT * FROM ***** WHERE ID_BOARD='16' ORDER BY posterTime DESC"; $result = mysql_query($query) or die(mysql_error()); // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<div class='tborder45'><div class='tborder22'>{$row['subject']}</div>"; echo "<font face='Trebuchet ms' size='2'>{$row['body']} </face>"; echo "<br />"; } include 'closedb.php'; } This is just asking. Just want to make sure something. code above gets data from my database. I'm having some other problem and I asked a person about it. He asked me why i was using double quotes for echoing. He said I should be using single quotes for echos and double for tables and such. Just to make clear, this code works it gets the data without any problem. I use double quotes because when i'm echoing a text that has a single quote, it works. So Am i using them right? Quote Link to comment Share on other sites More sharing options...
jeremyphphaven Posted February 22, 2008 Share Posted February 22, 2008 IMO it's a matter of preference. I code as your buddy referenced, but like you said, your code works just as well. Having said that, there are certain coding standards overall that you may want to research for PHP Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 22, 2008 Share Posted February 22, 2008 There is a small amount of overhead added by PHP in using double quotes. The reason for this is because you can embed PHP variables in double quotes, like you've done here: echo "<div class='tborder45'><div class='tborder22'>{$row['subject']}</div>"; I also tend to use double quotes for MySQL queries because most queries will contain single quotes somewhere in them. IMO, unless your site is huge in popularity and you can pinpoint major sight slowdown to the extra overhead incurred by using double quotes, then it doesn't really matter. But if your site is so popular that single quotes vs. double quotes is an issue, then you can probably afford a second dedicated server so that Apache can run on one and MySQL can run on the other. Likewise, I've heard about programmers that spent hours modifying code to remove all the double quotes and then the script runs an average of .001ms faster. Big deal. Then you turn around and they're running a query on several hundred thousand rows without an index defined. There are a lot of things you can worry about when optimizing your programs. IMO, single quotes vs. double quotes should not be one of them. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.