0

i have a problem using with single and double quotes with brackets in php

$nestedData[] = '<a href="JavaScript:newPopup('loghistory.php?logid='.$row['user_id'].'')"> History('.$countqry.')</a>';
  • 2
    http://stackoverflow.com/questions/3446216/what-is-the-difference-between-single-quoted-and-double-quoted-strings-in-php?rq=1 – Jeff Nov 23 '16 at 12:22

6 Answers6

4

You need to escape the quotes or concat the strings:

$nestedData[] = '<a href="JavaScript:newPopup('loghistory.php?logid='.$row['user_id'].'')"> History('.$countqry.')</a>';
                                              ^ here your string ends

You can change to:

$nestedData[] = '<a href="JavaScript:newPopup(\'loghistory.php?logid='.$row['user_id'].'\')"> History('.$countqry.')</a>';

Or another option:

$nestedData[] = '<a href="JavaScript:newPopup('. "'loghistory.php?logid='" .$row['user_id']. "'" . ')"> History('. $countqry .')</a>';
Dekel
  • 60,707
  • 10
  • 101
  • 129
1

You can escape single and double quotes with \ Like this:

'You\'re'
Sitethief
  • 480
  • 5
  • 17
1
$nestedData[] = '<a href="JavaScript:newPopup('loghistory.php?logid='.$row['user_id'].'')"> History('.$countqry.')</a>';

try the below code:

<a href="JavaScript:newPopup("loghistory.php?logid='.$row['user_id'].'')"> History('.$countqry.')</a>
Manthan Dave
  • 2,137
  • 2
  • 17
  • 31
0

If you wish to output a single tick from within a litteral string then you will need to escape that single quote:

$a = 'Graeme\'s example';
echo $a;

Will output:

Graeme's example

Graeme
  • 1,643
  • 15
  • 27
0
$nestedData[] = "<a href=\"JavaScript:newPopup('loghistory.php?logid='".$row['user_id']."')"."\"> History('".$countqry."')</a>";

Escape the quotes with \

this should do the trick

Masivuye Cokile
  • 4,754
  • 3
  • 19
  • 34
0
$nestedData[] = '<a href="JavaScript:newPopup('".loghistory.php?logid='".$row['user_id']."'."')"> History("'.$countqry.'")</a>';