alemapo Posted June 10, 2009 Share Posted June 10, 2009 Hi, I'm using dreamweaver with php. This particular master page is dynamically loading the links to the detail pages based on the type of record. (Calling different update pages). I am trying to pass 2 URL variables with the link that are coming from the database but the way I am trying is apparently too many quotes and double quotes and they are not getting along. Any help or suggestion on a better way to do it would be appreciated! [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/161738-solved-fighting-quotes/ Share on other sites More sharing options...
Hatdrawn Posted June 10, 2009 Share Posted June 10, 2009 I'm not an expert and I also can't really understand the issue but does this help? <td align="center"><?php if ($recordsFound){ echo \'<a href="update_general.php?recordID=$row_current[\'cls_id\'] &cls_item_var=$row_current[\'cls_item\']">Update</a>';}?></td> Quote Link to comment https://forums.phpfreaks.com/topic/161738-solved-fighting-quotes/#findComment-853368 Share on other sites More sharing options...
roopurt18 Posted June 10, 2009 Share Posted June 10, 2009 <td align="center"><?php if ($recordsFound){ echo '<a href="update_general.php?recordID=$row_current['cls_id'] &cls_item_var=$row_current['cls_item']">Update</a>';}?></td> If you want to embed PHP variables inside a string, then the string must be enclosed with double quotes, not single quotes like you have there. Whatever you start your string with (single or double quotes), then that same character must be escaped with a backslash within the string. I.E: You can output a single double quote: echo '"'; // single-quoted string, so no escape sequence necessary for the enclosed double-quote echo "\""; // double-quoted string, so escape sequence is necessary for the enclosed double-quote <td align="center"><?php if ($recordsFound){ echo "<a href=\"update_general.php?recordID={$row_current['cls_id']}&cls_item_var={$row_current['cls_item']}\">Update</a>";}?></td> When placing variables in a double-quoted string, it is good programming practice to enclose the variable in curly brackets. $name = 'Joe'; echo "Hello, $name\n"; // BAD practice echo "Hello, {$name}\n"; // GOOD Quote Link to comment https://forums.phpfreaks.com/topic/161738-solved-fighting-quotes/#findComment-853375 Share on other sites More sharing options...
alemapo Posted June 11, 2009 Author Share Posted June 11, 2009 That took care of it and thank you for the info on good programming practice with curly brackets. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/161738-solved-fighting-quotes/#findComment-853537 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.