-3

I want to add a class on my td. So i can modify it with css. But everytime i write td class right, my page stops work.

It this possible what im tryin to do? Or do i have to do it some other way?

$test= database_result($queryexe, 'MyDatabase');

Print("<td class="right">$test</td>\n");


td.right{
    text-align: right;"
}
Blisskarthik
  • 1,246
  • 8
  • 20
Mato
  • 5
  • 1
  • 4
  • 1
    Either escape the double quotes or change them to single quotes. `echo "hello \" <-";` or `echo "hello ' <-";` – Charlotte Dunois Aug 24 '16 at 11:44
  • 1
    Possible duplicate of [PHP Parse/Syntax Errors; and How to solve them?](http://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them) – gre_gor Aug 24 '16 at 12:06

3 Answers3

3

You messed up with the " codes try the below one also add table tr td it will work fine

Print("<table><tr><td class='right'>$test</td></tr></table>");
rahul
  • 776
  • 5
  • 30
2

Your Code

Print("<td class="right">$test</td>\n");

Updated Code

Print("<td class='right'>$test</td>\n"); // double quotes changed to single quotes

Also Use error reporting on top of your page to view what errors are ocouring

// should only be used on development servers not on production servers
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
  • 2
    Note: Errors should only be displayed on development servers, **not** on production servers. On production servers all errors should be **logged**. – Charlotte Dunois Aug 24 '16 at 11:46
0

Just for reference XHTML™ 1.0 The Extensible HyperText Markup Language (Second Edition) states that "Attribute values must always be quoted" - even if they are numeric, however despite the fact that the examples show them enclosed in double quotes it is perfectly acceptable to use either double-quotes or single-quotes (the example there is just an example - it's not part of the specification) and most people do use double-quotes even though the standard says you can use either.

So, you don't really have to change them to single-quotes, just put backslashes in front of them:

Print("<td class=\"right\">$test</td>\n");

...which 'escapes' them as Charlotte says so that PHP doesn't get to the quotes at the start of "right" and think that's the end of the string.