1. If you can't use the support forum then you can contact the admin for support via "kenbrace@live.com".

Wordpress and bbpress error

Discussion in 'General Support' started by dveight, Oct 11, 2016.

  1. dveight

    dveight Member

    Joined:
    Oct 11, 2016
    Posts:
    6
    Likes Received:
    0
    Gender:
    Male
    Hi

    I am running a wordpress site with bbpress on godaddy hosting and I uploaded theforumwheel.php in the same folder as wp-config.php, but the forum wheel can't find the script on my site and when I run theforumwheel.php it gives this error:

    Warning: mysqli_connect(): (HY000/2005): Unknown MySQL server host 'orga3605990566.db.3605990.hostedresource.com:3310' (0) in /home/content/p3pnexwpnas10_data02/90/3605990/html/theforumwheel.phpon line 13

    Warning: mysqli_close() expects parameter 1 to be mysqli, boolean given in /home/content/p3pnexwpnas10_data02/90/3605990/html/theforumwheel.php on line 57

    Can someone help me get started, please?
     
  2. pwarbi

    pwarbi Well-Known Member

    Joined:
    Jul 13, 2016
    Posts:
    73
    Likes Received:
    79
    Gender:
    Male
    Location:
    UK
    @KenBrace is the man you need, he'll be on here later no doubt and will look into it for you.
     
    dveight likes this.
  3. KenBrace

    KenBrace Well-Known Member Administrator

    Joined:
    Apr 11, 2015
    Posts:
    1,161
    Likes Received:
    703
    Hi @dveight. I'm sorry you're experiencing issues.

    Can I have a link to your site so I can check it out?
     
    dveight likes this.
  4. dveight

    dveight Member

    Joined:
    Oct 11, 2016
    Posts:
    6
    Likes Received:
    0
    Gender:
    Male
  5. KenBrace

    KenBrace Well-Known Member Administrator

    Joined:
    Apr 11, 2015
    Posts:
    1,161
    Likes Received:
    703
    What version of Wordpress are you running?
     
    dveight likes this.
  6. dveight

    dveight Member

    Joined:
    Oct 11, 2016
    Posts:
    6
    Likes Received:
    0
    Gender:
    Male
    Version 4.6.1
     
  7. KenBrace

    KenBrace Well-Known Member Administrator

    Joined:
    Apr 11, 2015
    Posts:
    1,161
    Likes Received:
    703
    Alright, great. So just to verify that the script is using the correct definition, go to your server root and open the "wp-config.php" file. Starting at line 22 you should see the following lines of code...
    PHP:
    /** The name of the database for WordPress */
    define('DB_NAME''database_name_here');

    /** MySQL database username */
    define('DB_USER''username_here');

    /** MySQL database password */
    define('DB_PASSWORD''password_here');

    /** MySQL hostname */
    define('DB_HOST''host_here');

    The actual database name, username, etc. will be unique to your site but you should still see the above setup.
     
    dveight likes this.
  8. dveight

    dveight Member

    Joined:
    Oct 11, 2016
    Posts:
    6
    Likes Received:
    0
    Gender:
    Male
    Yes, that's what I have in the wp-config.php, all details are correct there, not sure why theforumwheel.php doesnt like them
     
  9. KenBrace

    KenBrace Well-Known Member Administrator

    Joined:
    Apr 11, 2015
    Posts:
    1,161
    Likes Received:
    703
    I just installed a Wordpress test site with version 4.6.1 and everything worked fine.

    Are you sure you have the right script?

    It should be identical to this...

    PHP:
    <?php

    include_once("wp-config.php");

    $db_host DB_HOST;
    $db_db DB_NAME;
    $db_user DB_USER;
    $db_pass DB_PASSWORD;

    $table $table_prefix "users";
    $table1 $table_prefix "posts";

    $conn mysqli_connect("$db_host""$db_user""$db_pass""$db_db");

    if(isset(
    $_POST['validate'])){
        
    $table $table_prefix "users";
       
        
    $query mysqli_query($conn"SELECT ID FROM $table WHERE ID='1'");
       
        if(
    $query){
            echo 
    "valid";
        }
    }

    if(isset(
    $_POST['subscribe'])){
        
    $username mysqli_real_escape_string($conn$_POST['username']);
        
    $email mysqli_real_escape_string($conn$_POST['email']);
       
        
    $sql "SELECT ID FROM $table WHERE user_login='$username' AND user_email='$email'";
        
    $query mysqli_query($conn$sql);
        if(
    mysqli_num_rows($query) > 0){
            
    $row mysqli_fetch_array($query);
                
    $ID $row['ID'];
               
            echo 
    $ID;
        } else {
            echo 
    "no";
        }
    }

    if(isset(
    $_POST['exchange'])){
        
    $username mysqli_real_escape_string($conn$_POST['user']);
       
        
    $sql "SELECT ID FROM $table WHERE user_login='$username'";
        
    $query mysqli_query($conn$sql);
        
    $row mysqli_fetch_array($query);
            
    $ID $row['ID'];
       
        
    $sql1 "SELECT COUNT(ID) FROM $table1 WHERE post_author='$ID'";
        
    $query1 mysqli_query($conn$sql1);
        
    $rows mysqli_fetch_row($query1);
            
    $posts $rows[0];
       
        echo 
    $posts;
    }

    mysqli_close($conn);

    ?>
     
  10. dveight

    dveight Member

    Joined:
    Oct 11, 2016
    Posts:
    6
    Likes Received:
    0
    Gender:
    Male
    Just double checked and that is the exact same script that I have, copied it from the forum here and uploaded as theforumwheel.php , still the same error. Can this have something to do with the port for database connection?
    Just read on some other forum that maybe there has to be a separate entry for the port here:

    conn = mysqli_connect("$db_host", "$db_user", "$db_pass", "$db_db");
     
  11. dveight

    dveight Member

    Joined:
    Oct 11, 2016
    Posts:
    6
    Likes Received:
    0
    Gender:
    Male
    yep, that's what it was. just tried it like this and it worked: conn = mysqli_connect("actual_host_without_port_number", "$db_user", "$db_pass", "$db_db", "port_number");
     
  12. KenBrace

    KenBrace Well-Known Member Administrator

    Joined:
    Apr 11, 2015
    Posts:
    1,161
    Likes Received:
    703
    Good deal. Yeah the port number should definitely not be included with the host value. Nice troubleshooting skills! :cool:
     

Share This Page