ktm
ktm

Reputation: 6085

why this php string giving error?

hi friends why this php string error ?

echo  '<div id="album_list"><a href="view_gallery/album_pix/ .$v['id']. ">' . $i . ' ' . $v['album_name']. '</a></div>';

Upvotes: 0

Views: 109

Answers (3)

rrrfusco
rrrfusco

Reputation: 1119

  • Single quote the string with the double quotes and attributes
  • Single space and concatenate with the period .
  • Change $var['key'] to $var, or $var["key"]

I'd change your variable names to reduce the confusion. As someone said above syntax highlighting will turn all the strings one color, and the variables another. Stack Overflow even displays code as such.

<?php

$v_id         = $v['id'];
$v_album_name = $v['album_name'];

echo  '<div id="album_list"><a href="view_gallery/album_pix/' . $v_id . '">' . $i . ' ' . $v_album_name . '</a></div>';

?>

Upvotes: 0

pferate
pferate

Reputation: 2107

You are missing a single-quote after album_pix/ and before the closing bracket.

echo  '<div id="album_list"><a href="view_gallery/album_pix/' .$v['id']. '">' . $i . ' ' . $v['album_name']. '</a></div>';

Upvotes: 1

mcrumley
mcrumley

Reputation: 5700

You have some missing single quotes.

echo  '<div id="album_list"><a href="view_gallery/album_pix/ .$v['id']. ">' . $i . ' ' . $v['album_name']. '</a></div>';
//                             you need a single quote here ^          ^ and here

Upvotes: 3

Related Questions