stuck

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Reggie

    stuck

    how can i resolve this:

    Warning: mysql_connect() [function.mysql-connect]: Lost connection to
    MySQL server during query in /home/fhlinux169/c/clashoff.co.uk/user/
    htdocs/checklogin.php on line 9
    cannot connect

    this is the script. please help.very stuck

    <?php
    $host="localhos t"; // Host name
    $username=""; // Mysql username
    $password=""; // Mysql password
    $db_name="test" ; // Database name
    $tbl_name="memb ers"; // Table name

    // Connect to server and select databse.
    mysql_connect(" $host", "$username" , "$password" )or die("cannot
    connect");
    mysql_select_db ("$db_name") or die("cannot select DB");

    // username and password sent from signup form
    $myusername=$_P OST['myusername'];
    $mypassword=$_P OST['mypassword'];

    $sql="SELECT * FROM $tbl_name WHERE username='$myus ername' and
    password='$mypa ssword'";
    $result=mysql_q uery($sql);

    // Mysql_num_row is counting table row
    $count=mysql_nu m_rows($result) ;
    // If result matched $myusername and $mypassword, table row must be 1
    row

    if($count==1){
    // Register $myusername, $mypassword and redirect to file
    "login_success. php"
    session_registe r("myusername") ;
    session_registe r("mypassword") ;
    header("locatio n:login_success .php");
    }
    else {
    echo "Wrong Username or Password";
    }
    ?>

  • ELINTPimp

    #2
    Re: stuck

    On Aug 8, 5:44 pm, Reggie <joelregisfo... @hotmail.comwro te:
    how can i resolve this:
    >
    Warning: mysql_connect() [function.mysql-connect]: Lost connection to
    MySQL server during query in /home/fhlinux169/c/clashoff.co.uk/user/
    htdocs/checklogin.php on line 9
    cannot connect
    >
    this is the script. please help.very stuck
    >
    <?php
    $host="localhos t"; // Host name
    $username=""; // Mysql username
    $password=""; // Mysql password
    $db_name="test" ; // Database name
    $tbl_name="memb ers"; // Table name
    >
    // Connect to server and select databse.
    mysql_connect(" $host", "$username" , "$password" )or die("cannot
    connect");
    mysql_select_db ("$db_name") or die("cannot select DB");
    >
    // username and password sent from signup form
    $myusername=$_P OST['myusername'];
    $mypassword=$_P OST['mypassword'];
    >
    $sql="SELECT * FROM $tbl_name WHERE username='$myus ername' and
    password='$mypa ssword'";
    $result=mysql_q uery($sql);
    >
    // Mysql_num_row is counting table row
    $count=mysql_nu m_rows($result) ;
    // If result matched $myusername and $mypassword, table row must be 1
    row
    >
    if($count==1){
    // Register $myusername, $mypassword and redirect to file
    "login_success. php"
    session_registe r("myusername") ;
    session_registe r("mypassword") ;
    header("locatio n:login_success .php");}
    >
    else {
    echo "Wrong Username or Password";}
    >
    ?>
    I can't really see anything obviously wrong...althoug h I like to
    specify my link handles ie. $db = mysqlconnect() and specify $db
    throughout


    run mysqladmin...wh at is the connect_timeout set to?

    Comment

    • allampraveen@gmail.com

      #3
      Re: stuck

      Give username as root and password as null and then check

      Comment

      • Jerry Stuckle

        #4
        Re: stuck

        allampraveen@gm ail.com wrote:
        Give username as root and password as null and then check
        >
        Not his problem - he's connecting just fine.

        And username of root with no password is about as insecure as you can get.

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

        Comment

        • nfantis

          #5
          Re: stuck

          On Aug 8, 5:44 pm, Reggie <joelregisfo... @hotmail.comwro te:
          how can i resolve this:
          >
          Warning: mysql_connect() [function.mysql-connect]: Lost connection to
          MySQL server during query in /home/fhlinux169/c/clashoff.co.uk/user/
          htdocs/checklogin.php on line 9
          cannot connect

          Does your user have privileges in MySQL to do the operation on line 9
          of your code (SELECT database?) I believe you get disconnected if you
          are not authorized to execute a query.

          Comment

          Working...