Hey there,
var favorites = 'Array (
[0] => [" 6 "," 1 "," 2 "," 5 "," 3 "," 4 "]
[1] => [" 6 "," 1 "," 2 "," 5 "," 3 "," 4 "]
[2] => [" 6 "," 1 "," 2 "," 5 "," 3 "," 4 "]
)
';
I've been encountering a syntax error - an unterminated string literal when I try to display the above content using console.log in JavaScript. I tried changing some characters and using regex patterns, but it seems like multi-line strings are causing an issue.
This dilemma began with an SQL query as seen below...
$favLinks = [];
$favQuery = "SELECT * FROM userfavorites WHERE users = '$username'";
$favResults = mysqli_query($conn, $favQuery);
while($row = mysqli_fetch_assoc($favResults)) {
array_push($favLinks, $row['fav_id']);
Then, I attempted this...
var favorites = <?php print_r ($favLinks); ?>
which resulted in the earlier mentioned problem.
If you have any suggestions on fixing this syntax error, I'd greatly appreciate it. Thanks!