CrazyEngineers
  • Unable to connect to database

    Manish Goyal

    Member

    Updated: Oct 26, 2024
    Views: 1.1K
    I have to update a website but i am unable to connect to Mysql server when i try to connect it gives me exception like this

    Could not connect: Can't connect to MySQL server on 'localhost' (10061)PHP Warning: mysql_connect() [#-Link-Snipped-#]: Can't connect to MySQL server on 'localhost' (10061) in D:\Domains\techno-opus2009.co.in\wwwroot\Register.php on line 5

    I am using following php script
    <?php
    $con = mysql_connect("localhost","manish","***");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    // Create database
    if (mysql_query("CREATE DATABASE alu",$con))
      {
      echo "Database created";
      }
    else
      {
      echo "Error creating database: " . mysql_error();
      }
    
    // Create table
    mysql_select_db("alumini", $con);
    $sql = "CREATE TABLE d
    (
    Rollno BIGINT NOTNULL AUTO_INCREMENT,PRIMARY KEY(Rollno),
    Name varchar(25),
    course varchar(25),
    batch int,
    address varchar(150),
    state varchar(25),
    country varchar(25),
    Phoneno BIGINT,
    Mobileno BIGINT,
    Email_Id varchar(30),
    Mychoice varchar(25),
    PresentOrganization varchar(25),
    PresentPosition varchar(25),
    OfficeAddress varchar(150),
    Married varchar(25),
    Mchoice varchar(25)
    )";
    
    // Execute query
    mysql_query($sql,$con);
    
    mysql_close($con);
    ?> 
    
    Please help me ..It is urgent
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Manish Goyal

    MemberMar 12, 2010

    Guys please help me I really need it
    Is there any one here who ever hosts his website and use mysql?
    Are you sure? This action cannot be undone.
    Cancel
  • thechamp

    MemberMar 12, 2010

    make sure you have entered password in webpage same as that saved in your mysql.
    Are you sure? This action cannot be undone.
    Cancel
  • Manish Goyal

    MemberMar 12, 2010

    yes I have checked that also..but no good response 😔
    Are you sure? This action cannot be undone.
    Cancel
  • thechamp

    MemberMar 12, 2010

    the link you provided for MySql connection seems broken.
    Are you sure? This action cannot be undone.
    Cancel
  • Manish Goyal

    MemberMar 12, 2010

    you mean this link
    D:\Domains\techno-opus2009.co.in\wwwroot\Register.php
    If yes ,I have not given this link anywhere it is just coming in the exception
    Are you sure? This action cannot be undone.
    Cancel
  • thechamp

    MemberMar 12, 2010

    try uploading website another time.. might be server problem that time.
    or it could be related to port i guess. i searched on net, it says could be related to your firewall too.i think googling should do it,as i dont think problem is in coding.
    Are you sure? This action cannot be undone.
    Cancel
  • Manish Goyal

    MemberMar 12, 2010

    Thanks champ
    Waiting for more replies ..can anyone help me here ?
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register