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
  • 57,326
  • 8
  • 92
  • 123
1

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

'You\'re'
Sitethief
  • 435
  • 5
  • 16
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,099
  • 2
  • 16
  • 29
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,493
  • 13
  • 25
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,729
  • 3
  • 18
  • 34
0
$nestedData[] = '<a href="JavaScript:newPopup('".loghistory.php?logid='".$row['user_id']."'."')"> History("'.$countqry.'")</a>';