accessing database in wamp environment

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • scout3014@gmail.com

    accessing database in wamp environment

    Hi

    I am using WAMP5 to create web applications. I have a problem as far
    as accessing the database is concerned. This following code is used to
    access database:

    $con = mysql_connect(" localhost", "root", "");
    if (!con) {
    die('Could not Connect' . mysql_error());
    }
    mysql_select_db ("Leave", $con);
    $data = mysql_query("SE LECT * FROM loginInfo WHERE username=" .
    $username);
    if(!$data){
    die('Invalid username: ' . mysql_error());
    }
    else{
    ....... //processing login
    .......
    }

    When i activate this code by logging in, the following is shown:
    "Invalid username: No database selected"

    I would like to know if there is anything wrong with my database
    connection for my database is correct. My database name on e
    SQLiteManager is 'Leave' and my table is "loginInfo"

    Help is much appreciated

    Regards
    Eugene

  • Jerry Stuckle

    #2
    Re: accessing database in wamp environment

    scout3014@gmail .com wrote:
    Hi
    >
    I am using WAMP5 to create web applications. I have a problem as far
    as accessing the database is concerned. This following code is used to
    access database:
    >
    $con = mysql_connect(" localhost", "root", "");
    if (!con) {
    die('Could not Connect' . mysql_error());
    }
    mysql_select_db ("Leave", $con);
    $data = mysql_query("SE LECT * FROM loginInfo WHERE username=" .
    $username);
    if(!$data){
    die('Invalid username: ' . mysql_error());
    }
    else{
    ...... //processing login
    ......
    }
    >
    When i activate this code by logging in, the following is shown:
    "Invalid username: No database selected"
    >
    I would like to know if there is anything wrong with my database
    connection for my database is correct. My database name on e
    SQLiteManager is 'Leave' and my table is "loginInfo"
    >
    Help is much appreciated
    >
    Regards
    Eugene
    >
    What's the result of your mysql_select_db call? It returns true/false
    depending on whether the request worked/failed. If you get false back,
    what's the error?

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • Rik

      #3
      Re: accessing database in wamp environment

      On Wed, 25 Jul 2007 05:36:00 +0200, <scout3014@gmai l.comwrote:
      Hi
      >
      I am using WAMP5 to create web applications. I have a problem as far
      as accessing the database is concerned. This following code is used to
      access database:
      >
      $con = mysql_connect(" localhost", "root", "");
      if (!con) {
      die('Could not Connect' . mysql_error());
      }
      mysql_select_db ("Leave", $con);
      $data = mysql_query("SE LECT * FROM loginInfo WHERE username=" .
      $username);
      if(!$data){
      die('Invalid username: ' . mysql_error());
      }
      else{
      ...... //processing login
      ......
      }
      >
      When i activate this code by logging in, the following is shown:
      "Invalid username: No database selected"
      >
      I would like to know if there is anything wrong with my database
      connection for my database is correct. My database name on e
      SQLiteManager is 'Leave' and my table is "loginInfo"
      0. Echo errors on select_db: mysql_select_db ("Leave", $con) or
      die(mysql_error ());
      1. Does the database exist in MySQL? (if not: mysql_query('CR EATE DATABASE
      Leave');)
      2. MySQL can be set to disallow capitals in database/tablenames, check the
      config and/or a more appropriate group like comp.databases. mysql if you
      have trouble with it ...

      --
      Rik Wasmus

      Comment

      • scout3014@gmail.com

        #4
        Re: accessing database in wamp environment

        On Jul 25, 11:45 am, Jerry Stuckle <jstuck...@attg lobal.netwrote:
        scout3...@gmail .com wrote:
        Hi
        >
        I am using WAMP5 to create web applications. I have a problem as far
        as accessing the database is concerned. This following code is used to
        access database:
        >
        $con = mysql_connect(" localhost", "root", "");
        if (!con) {
        die('Could not Connect' . mysql_error());
        }
        mysql_select_db ("Leave", $con);
        $data = mysql_query("SE LECT * FROM loginInfo WHERE username=" .
        $username);
        if(!$data){
        die('Invalid username: ' . mysql_error());
        }
        else{
        ...... //processing login
        ......
        }
        >
        When i activate this code by logging in, the following is shown:
        "Invalid username: No database selected"
        >
        I would like to know if there is anything wrong with my database
        connection for my database is correct. My database name on e
        SQLiteManager is 'Leave' and my table is "loginInfo"
        >
        Help is much appreciated
        >
        Regards
        Eugene
        >
        What's the result of your mysql_select_db call? It returns true/false
        depending on whether the request worked/failed. If you get false back,
        what's the error?
        >
        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstuck...@attgl obal.net
        =============== ===- Hide quoted text -
        >
        - Show quoted text -
        if (!mysql_select_ db("leave", $con)){
        die (mysql_error()) ;
        }

        using the following code, the error message is as shown:
        Unknown database 'leave'

        Like i was saying my database name was "Leave" with capital L so i do
        not know why they put in in small case

        Comment

        • Jerry Stuckle

          #5
          Re: accessing database in wamp environment

          scout3014@gmail .com wrote:
          On Jul 25, 11:45 am, Jerry Stuckle <jstuck...@attg lobal.netwrote:
          >scout3...@gmai l.com wrote:
          >>Hi
          >>I am using WAMP5 to create web applications. I have a problem as far
          >>as accessing the database is concerned. This following code is used to
          >>access database:
          >>$con = mysql_connect(" localhost", "root", "");
          >>if (!con) {
          >> die('Could not Connect' . mysql_error());
          >> }
          >>mysql_select_ db("Leave", $con);
          >>$data = mysql_query("SE LECT * FROM loginInfo WHERE username=" .
          >>$username);
          >>if(!$data){
          >> die('Invalid username: ' . mysql_error());
          >> }
          >>else{
          >>...... //processing login
          >>......
          >>}
          >>When i activate this code by logging in, the following is shown:
          >>"Invalid username: No database selected"
          >>I would like to know if there is anything wrong with my database
          >>connection for my database is correct. My database name on e
          >>SQLiteManag er is 'Leave' and my table is "loginInfo"
          >>Help is much appreciated
          >>Regards
          >>Eugene
          >What's the result of your mysql_select_db call? It returns true/false
          >depending on whether the request worked/failed. If you get false back,
          >what's the error?
          >>
          >- Show quoted text -
          >
          if (!mysql_select_ db("leave", $con)){
          die (mysql_error()) ;
          }
          >
          using the following code, the error message is as shown:
          Unknown database 'leave'
          >
          Like i was saying my database name was "Leave" with capital L so i do
          not know why they put in in small case
          >
          Well, I'm not sure who "they" is - but looks like you need to change the
          mysql_select_db call.

          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          Working...