Variable after WHERE

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DaedalusShadow
    New Member
    • Mar 2007
    • 8

    Variable after WHERE

    I've got a piece of script that works that looks like this:
    _______________ _______________ _______________ ______________

    $username="daed alus_admin";
    $password="test ";
    $database="daed alus_db";

    mysql_connect(l ocalhost,$usern ame,$password);
    @mysql_select_d b($database) or die( "Unable to select database");

    $query="SELECT * FROM user WHERE username='daeda lus";
    $result=mysql_q uery($query);

    $num=mysql_numr ows($result);
    _______________ _______________ _______________ ______________

    I want to change it to this so that I can use a variable from a session at a later date:
    _______________ _______________ _______________ ______________

    $schque="daedal us"

    $username="daed alus_admin";
    $password="test ";
    $database="daed alus_db";

    mysql_connect(l ocalhost,$usern ame,$password);
    @mysql_select_d b($database) or die( "Unable to select database");

    $query="SELECT * FROM user WHERE username='$schq ue";
    $result=mysql_q uery($query);

    $num=mysql_numr ows($result);
    _______________ _______________ _______________ ______________

    But as soon as I change the criteria of the WHERE to $schque the page stops working and comes up blank, i've tried it without the ' round it but it still doesn't work, I'm really confused any help would be appriecated.
  • mainul
    New Member
    • Sep 2006
    • 51

    #2
    Originally posted by DaedalusShadow
    I've got a piece of script that works that looks like this:
    _______________ _______________ _______________ ______________

    $username="daed alus_admin";
    $password="test ";
    $database="daed alus_db";

    mysql_connect(l ocalhost,$usern ame,$password);
    @mysql_select_d b($database) or die( "Unable to select database");

    $query="SELECT * FROM user WHERE username='daeda lus";
    $result=mysql_q uery($query);

    $num=mysql_numr ows($result);
    _______________ _______________ _______________ ______________

    I want to change it to this so that I can use a variable from a session at a later date:
    _______________ _______________ _______________ ______________

    $schque="daedal us"

    $username="daed alus_admin";
    $password="test ";
    $database="daed alus_db";

    mysql_connect(l ocalhost,$usern ame,$password);
    @mysql_select_d b($database) or die( "Unable to select database");

    $query="SELECT * FROM user WHERE username='$schq ue";
    $result=mysql_q uery($query);

    $num=mysql_numr ows($result);
    _______________ _______________ _______________ ______________

    But as soon as I change the criteria of the WHERE to $schque the page stops working and comes up blank, i've tried it without the ' round it but it still doesn't work, I'm really confused any help would be appriecated.

    use

    $a=$_REQUEST['$schque'];
    $query="SELECT * FROM user WHERE username='$a'";

    Comment

    • DaedalusShadow
      New Member
      • Mar 2007
      • 8

      #3
      Originally posted by mainul
      use

      $a=$_REQUEST['$schque'];
      $query="SELECT * FROM user WHERE username='$a'";
      Thanks this works perfectly, I owe you one.

      Comment

      • mainul
        New Member
        • Sep 2006
        • 51

        #4
        You are welcome.

        Comment

        Working...