Quotes vs. Single Quote

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi List.
I've mentioned before that I am both just beginning to learn PHP AND I have inherited a number of pages that I'm trying to clean up the w3c validation on.

Something that confuses me is how the code on the page is written where in one instance, it follows this:

echo "<table border='1'><tr>....

And elsewhere on the page it follows:

echo '<table border="1"><tr>....

In what I've read and from many of the suggestions from this board, the latter seems to be the better way to code, generally speaking.

So given that the page has javascript in it, perhaps the reason for the previous developer switching between the two was for ease of incorporating JS?.... Don't really know... but what I would like to know is it considered poor coding switch between the two on a single page or is it perfectly acceptable?

2nd question, in the 3 lines below:

$_SESSION['newpage'] = $newpage;
$checkstat = "select field from table where fieldid = $field_id";
$result1 = @mysql_query($checkstat,$connection) or die("Couldn't execute query");


If I were to recode in the latter style, should they not look like this:

$_SESSION['newpage'] = $newpage;
$checkstat = 'select field from table where fieldid = "'.$field_id.'"';
$result1 = @mysql_query($checkstat,$connection) or die('Couldn\'t execute query');


The focus being here:

 "'.$field_id.'"';
('Couldn\'t execute query')

Is this correct?

Thanks for the help.

--Rick



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux