jx2012 Posted May 15, 2012 Share Posted May 15, 2012 Hi there, I am new to this forum want to say Hi to everyone . I just learn a little bit of PHP. I couldn't figure this out. Could someone please help me? Many thanks. 1. when I ran the 1st code below, it showed me "thank you" in the browser. <?php $title=$_GET[title]; echo $title; ?> 2. when I ran the 2nd code below, I got what I wanted. <?php $sql = "SELECT * FROM mytable WHERE title='thank you' "; ... ?> 3. when I ran the 3rd code below, it showed me a blank page . <?php $title=$_GET[title]; $sql = "SELECT * FROM mytable WHERE title='<?php echo $title; ?>' "; ... ?> How to make the 3rd code work like the 2nd one? It seems a php code under php is NOT working. Quote Link to comment https://forums.phpfreaks.com/topic/262541-_get/ Share on other sites More sharing options...
rythemton Posted May 15, 2012 Share Posted May 15, 2012 If you're in PHP, you can't go further into php. You'll need to concatenate. // with the concatenate operator: $sql = "SELECT * FROM mytable WHERE title='" . $title . "' "; // or even shorter (only works in double quotes): $sql = "SELECT * FROM mytable WHERE title='$title' "; Quote Link to comment https://forums.phpfreaks.com/topic/262541-_get/#findComment-1345495 Share on other sites More sharing options...
jx2012 Posted May 15, 2012 Author Share Posted May 15, 2012 Hehe you are awesome. It works. I just though title!='$title' because $title is a string. I was wrong. Thanks so much! Quote Link to comment https://forums.phpfreaks.com/topic/262541-_get/#findComment-1345498 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.