kat35601 Posted November 16, 2015 Share Posted November 16, 2015 echo "<tr><td><a href='kf_orders_entered_detail.php?id=WHAT GOES HERE'>" . $row['ompCreatedBy'] ."</td>"; I can not getting ompCreatedBy to pass from this statement please help me with (WHAT GOES HERE) Quote Link to comment https://forums.phpfreaks.com/topic/299492-syntax-help-passing-a-variable/ Share on other sites More sharing options...
Solution benanamen Posted November 16, 2015 Solution Share Posted November 16, 2015 (edited) Most likely {$row['id']} Whatever your ID column is named. echo "<tr><td><a href=\"kf_orders_entered_detail.php?id={$row['id']}\">{$row['ompCreatedBy']}</td>"; Edited November 16, 2015 by benanamen Quote Link to comment https://forums.phpfreaks.com/topic/299492-syntax-help-passing-a-variable/#findComment-1526477 Share on other sites More sharing options...
kat35601 Posted November 16, 2015 Author Share Posted November 16, 2015 I left out the { } Thanks Quote Link to comment https://forums.phpfreaks.com/topic/299492-syntax-help-passing-a-variable/#findComment-1526478 Share on other sites More sharing options...
Jacques1 Posted November 16, 2015 Share Posted November 16, 2015 You should use http_build_query() and HTML-escaping instead of relying on string gymnastics: <?php /* Your PHP code goes here */ function html_escape($raw_input, $encoding) { return htmlspecialchars($raw_input, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5, $encoding); } // test data $your_row = [ 'id' => 42, 'ompCreatedBy' => 'foobar', ]; $your_url = 'kf_orders_entered_detail.php?'.http_build_query(['id' => $your_row['id']]); ?> <!-- Your HTML markup goes here --> <tr> <td><a href="<?= html_escape($your_url, 'UTF-8') ?>"><?= html_escape($your_row['ompCreatedBy'], 'UTF-8') ?></a></td> </tr> Not only is this much clearer than messing with PHP strings. It's also much more secure and reliable, because you won't end up with syntax conflicts or even attacks. Quote Link to comment https://forums.phpfreaks.com/topic/299492-syntax-help-passing-a-variable/#findComment-1526482 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.