Warning: mysql_query():

Discussion in 'PHP' started by agifer, Oct 1, 2005.

  1. #1
    I'll be greatfull if you could help , the message is:Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /home/www/elcl.coconia.net/header.php on line 11

    Warning: mysql_query(): A link to the server could not be established in /home/www/elcl.coconia.net/header.php on line 11
    Coooooooooouldn't get file list

    MY DB_connect file is:
    <?php
    
    require the PEAR:B classes.
    
    require_once 'DB.php';
    
    $db_engine = 'mysql';
    $db_user = 'alvada';
    $db_pass = 'SX123456';
    $db_host = 'localhost';
    $db_name = 'alvada_league';
    
    $datasource = $db_engine.'://'.
    $db_user.':'.
    $db_pass.'@'.
    $db_host.'/'.
    $db_name;
    
    
    $db_object = DB::connect($datasource, TRUE);
    
    
    
    /* assign database object in $db_object, 
    
    if the connection fails $db_object will contain
    
    the error message. */
    
    // If $db_object contains an error:
    
    // error and exit.
    
    if(DB::isError($db_object)) {
    die($db_object->getMessage());
    }
    
    $db_object->setFetchMode(DB_FETCHMODE_ASSOC);
    
    // we write this later on, ignore for now.
    
    include('check_login.php');
    
    ?>
    PHP:
    and my header file is:
    <?php
    require('db_connect.php');
    
    
    $dbQuery = "SELECT * "; 
    
    
    
    
    $dbQuery .= "FROM admin "; 
    $result = mysql_query($dbQuery) or die("Coooooooooouldn't get file list");
    while($row = mysql_fetch_array($result))
    
    { 
    
    
    
    $col_back = $row["col_back"];
    $col_text = $row["col_text"];
    $col_link = $row["col_link"];
    $col_table_row = $row["col_table_row"];
    $col_table_row2 = $row["col_table_row2"];
    $col_table_header = $row["col_table_header"];
    $col_table_header_2 = $row["col_table_header_2"];
    $col_table_border = $row["col_table_border"];
    $col_table_border_2 = $row["col_table_border_2"];
    $col_table_row_text= $row["col_table_row_text"];
    $col_table_header_text = $row["col_table_header_text"];
    $currency = $row["currency"];
    $logo_pos = $row["logo_pos"];
    $texture = $row["texture"];
    $admin_message = $row["admin_message"];
    $title_message = $row["title_message"];
    $theme_col = $row["theme_col"];
    $site_url = $row["site_url"];
    $admin_email = $row["admin_email"];
    
    
    
    ?>
    
    <html>
    <head>
    <body background="textures/<?php echo "$texture" ?>.jpg">
    <body bgcolor="#<?php echo "$col_back"; ?>">
    <p align="<?php echo "$logo_pos" ?>"> <img src="images/logo.gif"> 
    <br><br>
    <center>
    <H4>
    <?php
    
    if ($logged_in == 0) {
    echo "<center>"; echo "<font color='#$col_text'>Welcome Guest"; 
    }
    else{
    echo "<center>"; echo "<font color='#$col_text'>Welcome "; echo (ucfirst("$_SESSION[username]"));?> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp <? echo date(" d M Y");
    }
    ?>
    <br>
    <?php
    
    
    $dbQuery = "SELECT rights "; 
    
    $dbQuery .= "FROM users WHERE username = ('$_SESSION[username]')"; 
    $result = mysql_query($dbQuery) or die("Couldn't get file list");
    while($row = mysql_fetch_array($result))
    {
    
    $permission = "$row[rights]"; // get access level
    $_SESSION["perm"] = "$permission"; // make session variables 
    
    
    session_start();
    if (($_SESSION['perm'] >= "3")) { 
    ?> <a href="admin.php"><font color="#<?php echo $col_link ?>">Administration Screen</font></a></font>
    <?php
    }
    }
    ?>
    
    <table border="1" cellpadding="0" cellspacing="0" bordercolorlight="#<?php echo "$col_table_border" ?>" bordercolordark="#<?php echo "$col_table_border_2" ?>" width="100%" id="topborder" height="1">
    <tr>
    <td width="100%" height="1" bgcolor="#<?php echo "$col_table_header" ?>">
    
    </tr>
    </table>
    </center>
    
    
    
    <a href="login.php"><font color="#<?php echo $col_link ?>">Login</font></a>&nbsp;&nbsp;&nbsp;&nbsp
    </font>
    <a href="editprofile.php"><font color="#<?php echo $col_link ?>">Edit Profile</font></a>&nbsp;&nbsp;&nbsp;&nbsp
    </font>
    <a href="team.php"><font color="#<?php echo $col_link ?>">Team</font></a>&nbsp;&nbsp;&nbsp;&nbsp
    </font>
    <a href="viewfixtures.php"><font color="#<?php echo $col_link ?>">Fixtures</font></a>&nbsp;&nbsp;&nbsp;&nbsp
    </font>
    <a href="leaguetable.php"><font color="#<?php echo $col_link ?>">League Table</font></a>&nbsp;&nbsp;&nbsp;&nbsp
    <a href="viewresults.php"><font color="#<?php echo $col_link ?>">View Results</font></a>&nbsp;&nbsp;&nbsp;&nbsp
    </font>
    <a href="main.php"><font color="#<?php echo $col_link ?>">Main Page</font></a>&nbsp;&nbsp;&nbsp;&nbsp
    </font>
    
    
    <a href="logout.php"><font color="#<?php echo $col_link ?>">Logout</font></a>&nbsp;&nbsp;&nbsp;&nbsp
    </font>
    
    
    <table border="1" cellpadding="0" cellspacing="0" bordercolorlight="#<?php echo "$col_table_border" ?>" bordercolordark="#<?php echo "$col_table_border_2" ?>" width="100%" id="topborder" height="1">
    <tr>
    <td width="100%" height="1" bgcolor="#<?php echo "$col_table_header" ?>">
    
    </tr>
    </table>
    
    
    </H4>
    <?php
    
    }
    ?>
    </head>
    
    </html>
    PHP:

    Please Advise.

    Cheers
     
    agifer, Oct 1, 2005 IP
  2. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #2
    Are you sure you have MySQL running on localhost?
     
    digitalpoint, Oct 1, 2005 IP
  3. agifer

    agifer Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Well, It is being hosted in another server, is this the right address for the serer? www/elcl.coconia.net

    or home//www/elcl.coconia.net

    or www/elcl.coconia.net

    Am a little :confused:
     
    agifer, Oct 2, 2005 IP
  4. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #4
    You should use the IP address of the server then, and not localhost.
     
    digitalpoint, Oct 2, 2005 IP
  5. boccio

    boccio Peon

    Messages:
    82
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    In that case make sure MySQL accepts connections from remote server.
     
    boccio, Oct 6, 2005 IP
  6. obrusoft

    obrusoft Peon

    Messages:
    79
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Too Confused, I can't read all of your code
     
    obrusoft, Oct 7, 2005 IP