0

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>';
3
  • 1
    An IDE with syntax highlighting will show you. .$v['id'] Commented Oct 6, 2010 at 20:13
  • You can see the problem from the sole syntax highlighting. Commented Oct 6, 2010 at 20:14
  • Um, what error? (I know what error, but you should at least tell us what error for the benefit of the doubt.) Commented Oct 6, 2010 at 20:15

3 Answers 3

3

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
Sign up to request clarification or add additional context in comments.

Comments

1

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>';

Comments

0
  • 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>';

?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.