lingo5 Posted March 22, 2012 Share Posted March 22, 2012 Hi, I am using this to output a limited amount of text from my DB: <?php echo substr($row_texts_RS['descripcion_'.$_SESSION['session_idioma'].''],0,450).'<a href="detail.php"> ... read more</a>';?> as you can see I am also creating the link "read more" that takes you to detail.php. This works fine...but I need to also pass the record id to the detail page. I have tried this: <?php echo substr($row_texts_RS['descripcion_'.$_SESSION['session_idioma'].''],0,450).'<a href="detail.php?id_item=$row_texts_RS['id_item']"> ... read more</a>';?> ...but all I get is a blank page...what am I doing wrong? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/259504-please-help-with-syntax/ Share on other sites More sharing options...
AyKay47 Posted March 22, 2012 Share Posted March 22, 2012 problem lies here: '<a href="detail.php?id_item=$row_texts_RS['id_item']"> ... read more</a>' variables are not interpolated within single quotes, either switch to double quotes or use concatenation. Quote Link to comment https://forums.phpfreaks.com/topic/259504-please-help-with-syntax/#findComment-1330241 Share on other sites More sharing options...
lingo5 Posted March 22, 2012 Author Share Posted March 22, 2012 Thanks AyKay47, I have tried double quotes like so: <?php echo substr($row_texts_RS['descripcion_'.$_SESSION['session_idioma'].''],0,450)."<a href="detail.php?id_item=$row_texts_RS['id_item']"> ... read more</a>";?> But still getting blank page.... Quote Link to comment https://forums.phpfreaks.com/topic/259504-please-help-with-syntax/#findComment-1330243 Share on other sites More sharing options...
AyKay47 Posted March 22, 2012 Share Posted March 22, 2012 "<a href=\"detail.php?id_item=$row_texts_RS['id_item']\"> ... read more</a>" Quote Link to comment https://forums.phpfreaks.com/topic/259504-please-help-with-syntax/#findComment-1330246 Share on other sites More sharing options...
lingo5 Posted March 22, 2012 Author Share Posted March 22, 2012 Sorry....still no luck. There must be something wrong with the whole thing <?php echo substr($row_texts_RS['descripcion_'.$_SESSION['session_idioma'].''],0,450)."<a href=\"detail.php?id_item=$row_texts_RS['id_item']\"> ... read more</a>";?> Quote Link to comment https://forums.phpfreaks.com/topic/259504-please-help-with-syntax/#findComment-1330252 Share on other sites More sharing options...
AyKay47 Posted March 22, 2012 Share Posted March 22, 2012 see what a view source shows. Quote Link to comment https://forums.phpfreaks.com/topic/259504-please-help-with-syntax/#findComment-1330264 Share on other sites More sharing options...
lingo5 Posted March 22, 2012 Author Share Posted March 22, 2012 Parse error: parse error, expecting `','' or `';'' in C:\wamp\www\newsroom.php on line 250 Line 250 is <?php echo substr($row_texts_RS['descripcion_'.$_SESSION['session_idioma'].''],0,450)."<a href="detail.php?id_item=$row_texts_RS['id_item']"> ... read more</a>";?> Quote Link to comment https://forums.phpfreaks.com/topic/259504-please-help-with-syntax/#findComment-1330279 Share on other sites More sharing options...
smerny Posted March 22, 2012 Share Posted March 22, 2012 "<a href="detail.php?id_item=$row_texts_RS['id_item']"> ... read more</a>" double quotes within double quotes.. you gotta escape the inner double quotes "<a href=\"detail.php?id_item=$row_texts_RS['id_item']\"> ... read more</a>" Quote Link to comment https://forums.phpfreaks.com/topic/259504-please-help-with-syntax/#findComment-1330285 Share on other sites More sharing options...
lingo5 Posted March 22, 2012 Author Share Posted March 22, 2012 Thanks smerny but.... Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in C:\wamp\www\newsroom.php on line 250 Quote Link to comment https://forums.phpfreaks.com/topic/259504-please-help-with-syntax/#findComment-1330288 Share on other sites More sharing options...
smerny Posted March 22, 2012 Share Posted March 22, 2012 "<a href=\"detail.php?id_item={$row_texts_RS['id_item']}\"> ... read more</a>" Quote Link to comment https://forums.phpfreaks.com/topic/259504-please-help-with-syntax/#findComment-1330291 Share on other sites More sharing options...
lingo5 Posted March 22, 2012 Author Share Posted March 22, 2012 Thanks smerny that worked !!!! Why the curly brackets? Quote Link to comment https://forums.phpfreaks.com/topic/259504-please-help-with-syntax/#findComment-1330307 Share on other sites More sharing options...
AyKay47 Posted March 22, 2012 Share Posted March 22, 2012 Thanks smerny that worked !!!! Why the curly brackets? Ah, i forgot to include the braces, I'm going to QQ in a corner. Array indices inside of double quotes need those braces to be interpolated correctly. Quote Link to comment https://forums.phpfreaks.com/topic/259504-please-help-with-syntax/#findComment-1330308 Share on other sites More sharing options...
lingo5 Posted March 22, 2012 Author Share Posted March 22, 2012 mmmm...good to know. Thanks guys. Quote Link to comment https://forums.phpfreaks.com/topic/259504-please-help-with-syntax/#findComment-1330310 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.