Changing Hosts causing PHP problems?

Discussion in 'PHP' started by Darwyn, May 11, 2010.

  1. #1
    I have a dynamic website that display a lot of information from a database. I recently changed hosting providers.

    Since I've made the change, the database data does not appear on the PHP page. The page loads as normal but without the data and no errors are displayed.

    I have made no change to the code.

    What would cause this?
     
    Darwyn, May 11, 2010 IP
  2. jeffdacosta

    jeffdacosta Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I think that is a problem with the BBcode, but I asking to one friend that is a Web Master, and I tell you later.
     
    jeffdacosta, May 11, 2010 IP
  3. live.co.uk

    live.co.uk Banned

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    just let us to see it in action
     
    live.co.uk, May 11, 2010 IP
  4. Darwyn

    Darwyn Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    ok...the URL is here: http://www.musl.net/mainwebsite_html/NewSite/registration.php

    If you click on any of the bottom three links...

    Player Registration Report List of all players on record and their registration status.
    Player Registration Report by Team List of all players on record and their registration status by team.
    Player Registration Report w/o ID List of all players on record and their registration status by team.

    It should generate the appropriate report. but when you click either of them, nothing is displayed. No errors appear either.

    Here is the code for the "Player Registration Report by Team" button...

    <?php
    
    $query  = "SELECT Person.PersonID, AlternateID, LastName, FirstName, PlayerTransaction.PersonID RegisterID, TeamName, Person.Active";
    $query .= " FROM Person ";
    $query .= " LEFT OUTER JOIN PlayerTransaction ON Person.PersonID = PlayerTransaction.PersonID AND PlayerTransaction.TransactionType = 'PR' AND NOW() BETWEEN PlayerTransaction.TransactionDate AND PlayerTransaction.TransactionEndDate";
    $query .= " LEFT OUTER JOIN PlayerTransaction PlayerTeam ON Person.PersonID = PlayerTeam.PersonID AND PlayerTeam.TransactionType = 'TA' AND NOW() > PlayerTeam.TransactionDate AND PlayerTeam.TransactionEndDate IS NULL";
    $query .= " LEFT OUTER JOIN Team ON PlayerTeam.TeamID = Team.TeamID";
    $query .= " ORDER BY TeamName, LastName, FirstName";
    
    $result = mysql_query($query);
    
    ?>
    
    <div id="content_full">
      <div id="content_pane">
        <div id="full">
          <h1>Player Registration Report</h1>
          List of all players on record and their registration status.  Unregistered players are shown in red.  Inactive players are shown in orange italics.
    
          <table>
            <tr span=4>
              <td>&nbsp;</td>
            </tr>
    
    <?php
    
    $teamName = 'Unknown';
    
    while($result AND $RegisterList = mysql_fetch_array($result, MYSQL_ASSOC)) {
      if ($teamName != $RegisterList['TeamName']) {
        $teamName = $RegisterList['TeamName']
    
    ?>
            <tr span=4>
              <td>&nbsp;</td>
            </tr>
    
    <?php
    
        if ($teamName == '') {
    ?>
    
            <tr span=4>
              <td><h2>Unknown</h2></td>
            </tr>
    
    <?php
    
        }
        else {
    
    ?>
    
            <tr span=4>
              <td><h2><?php echo $teamName; ?></h2></td>
            </tr>
    
    <?php
    
        }
      }
    ?>
    
    <?php
    if (STRLEN ($RegisterList['RegisterID']) == 0) {
    ?>
            <tr class="highlight">
    <?php
    }
    elseif ($RegisterList['Active'] == 'N') {
    ?>
            <tr class="highlightitalics">
    <?php
    }
    else {
    ?>
            <tr>
    <?php
    }
    ?>
    
              <td>
                <?php echo $RegisterList['PersonID']; ?>&nbsp;
              </td>
    
              <td>
                <?php echo $RegisterList['AlternateID']; ?>&nbsp;
              </td>
    
              <td>
                <?php echo $RegisterList['LastName']; ?>&nbsp;
              </td>
    
              <td>
                <?php echo $RegisterList['FirstName']; ?>
              </td>
            </tr>
    <?php
    }
    ?>
          </table>
        </div>
    
        <div id="admin_pane_bottom">
        </div>
      </div>
    </div>
    <div class="clear"></div>
    Code (markup):
     
    Darwyn, May 11, 2010 IP
  5. Rory M

    Rory M Peon

    Messages:
    1,020
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Add
    
    if(!$result)
    {
    die(mysql_error());
    }
    
    PHP:
    After the query and see if that gives you more information
     
    Rory M, May 11, 2010 IP
  6. Darwyn

    Darwyn Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Nothing happened. No more information.

    I think the connection to the database works fine. If I make any changes to the login information, it displays an error. Seems the problem is displaying the information. And again, it worked before I copied the site exactly from the old server and uploaded it to the new server.

    I'm just not sure what a change in the server makes to the PHP code that would cause this...
     
    Darwyn, May 11, 2010 IP
  7. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #7
    Change:

    $result = mysql_query($query);
    PHP:
    Too:

    $result = mysql_query($query) or trigger_error("Query Failed: ".mysql_error($con), E_USER_ERROR);
    PHP:
    and add the following line right at the top:

    error_reporting(E_ALL);
    PHP:
    then reply with any errors you see quoting them..
     
    danx10, May 11, 2010 IP
  8. almondj

    almondj Peon

    Messages:
    768
    Likes Received:
    11
    Best Answers:
    1
    Trophy Points:
    0
    #8
    If you changed host, then the database connection information will have changed, have you changed it yet?
     
    almondj, May 11, 2010 IP
  9. Darwyn

    Darwyn Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    danx10 - Here is what came up with the changes you suggested:

    Notice: Undefined variable: con in D:\Hosting\6100168\html\mainwebsite_html\NewSite\Registration\registerReportTeam.php on line 10

    Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in D:\Hosting\6100168\html\mainwebsite_html\NewSite\Registration\registerReportTeam.php on line 10

    Fatal error: Query Failed: in D:\Hosting\6100168\html\mainwebsite_html\NewSite\Registration\registerReportTeam.php on line 10

    and to be sure, here is the new code, as you suggested:

    <?php
    error_reporting(E_ALL);
    $query = "SELECT Person.PersonID, AlternateID, LastName, FirstName, PlayerTransaction.PersonID RegisterID, TeamName, Person.Active";
    $query .= " FROM Person ";
    $query .= " LEFT OUTER JOIN PlayerTransaction ON Person.PersonID = PlayerTransaction.PersonID AND PlayerTransaction.TransactionType = 'PR' AND NOW() BETWEEN PlayerTransaction.TransactionDate AND PlayerTransaction.TransactionEndDate";
    $query .= " LEFT OUTER JOIN PlayerTransaction PlayerTeam ON Person.PersonID = PlayerTeam.PersonID AND PlayerTeam.TransactionType = 'TA' AND NOW() > PlayerTeam.TransactionDate AND PlayerTeam.TransactionEndDate IS NULL";
    $query .= " LEFT OUTER JOIN Team ON PlayerTeam.TeamID = Team.TeamID";
    $query .= " ORDER BY TeamName, LastName, FirstName";

    $result = mysql_query($query) or trigger_error("Query Failed: ".mysql_error($con), E_USER_ERROR);

    ?>


    almondj - yes, the username, password, host name and database name have all been changed to reflect the new database...

    As I mentioned, changing these results in an error on the page. So having no errors indicates to me that there is a connection being made, but no information to display.
     
    Darwyn, May 11, 2010 IP
  10. almondj

    almondj Peon

    Messages:
    768
    Likes Received:
    11
    Best Answers:
    1
    Trophy Points:
    0
    #10
    Seems like your problem is in the query. Maybe create a new page and query one variable from the database (a basic page.) If this works, then something is wrong with the query above.
     
    almondj, May 11, 2010 IP
  11. Darwyn

    Darwyn Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Actually, I've tested the connection to the database via Dreamweaver and it worked fine.

    Unfortunately, I didnt create any of these php files....but the files all worked on the old server and I changed only the database credentials.

    what would cause this problem by simply changing servers?
     
    Darwyn, May 11, 2010 IP
  12. Darwyn

    Darwyn Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    By the way - THANKS everyone for your input so far!
     
    Darwyn, May 11, 2010 IP
  13. musicmasteria

    musicmasteria Peon

    Messages:
    33
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Where are you connecting to the database in your code?

    I see you are querying something on line 10
    $result = mysql_query($query) or trigger_error("Query Failed: ".mysql_error($con), E_USER_ERROR); // btw, $con is the undefined var in that error you posted
    PHP:
    but you never defined the default connection credentials in your code.

    Don't you need a mysql_connent() (http://www.php.net/manual/en/function.mysql-connect.php) somewhere in your code or do you call your script from another file that has already done so?

    I'm assuming, because you are having problems with mysql, that you aren't connecting to the database before the query or if you are you aren't connecting to it properly (wrong credentials, etc.)
     
    musicmasteria, May 11, 2010 IP
  14. Darwyn

    Darwyn Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    I'm not an expert in php...this problem sorta fell to my lap. But anyway, yes, the connection credentials are contained in a separate php file called dbopen.php which is itself called from a file named report.php. the following code is in report.php:

    <?php
    include 'Database/dbconfig.php';
    include 'Database/dbopen.php';
    
    $p=$_GET['type'];
    
    ?>
    PHP:
    If you click the actual link I supplied above, you will see that the URL reads:

    http://www.musl.net/mainwebsite_html/NewSite/report.php?type=registerReportTeam

    And to be sure, the dbopen.php file reads:

    <?php
    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to MUSL database');
    mysql_select_db($dbname,$conn);
    ?>
    
    PHP:
     
    Darwyn, May 11, 2010 IP
  15. Darwyn

    Darwyn Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    I also just noticed a hidden file that wasn't uploaded to the new server. I don't know if this makes a difference or not but its called mysql.php and it sat in a folder called "_mmServerScripts" in the root folder.
     
    Darwyn, May 11, 2010 IP
  16. Darwyn

    Darwyn Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Ok, here's an update (I been working on this all freaking day!). I've connected to the database just fine...so, I've determined that it MUST have something to do with the table set up to display the database. Can someone take a look at the code here, because the display is blank:

    THIS DOESN'T WORK! see blank page here: http://www.musl.net/mainwebsite_html/NewSite/report.php?type=registerReportTeam

    The code for this is:
    <?php
    
    $query  = "SELECT AlternateID, LastName, FirstName, PlayerTransaction.PersonID, TeamName, Person.Active";
    $query .= " FROM Person ";
    $query .= " LEFT OUTER JOIN PlayerTransaction ON Person.PersonID = PlayerTransaction.PersonID AND PlayerTransaction.TransactionType = 'PR' AND NOW() BETWEEN PlayerTransaction.TransactionDate AND PlayerTransaction.TransactionEndDate";
    $query .= " LEFT OUTER JOIN PlayerTransaction PlayerTeam ON Person.PersonID = PlayerTeam.PersonID AND PlayerTeam.TransactionType = 'TA' AND NOW() > PlayerTeam.TransactionDate AND PlayerTeam.TransactionEndDate IS NULL";
    $query .= " LEFT OUTER JOIN Team ON PlayerTeam.TeamID = Team.TeamID";
    $query .= " ORDER BY TeamName, LastName, FirstName";
    
    
    $result = mysql_query($query);
    
    ?>
    
    <div id="content_full">
      <div id="content_pane">
        <div id="full">
          <h1>Player Registration Report</h1>
          List of all players on record and their registration status.  Unregistered players are shown in red.  Inactive players are shown in orange italics.
    
          <table>
            <tr span=4>
              <td>&nbsp;</td>
            </tr>
    
    <?php
    
    $teamName = 'Unknown';
    
    while($result AND $RegisterList = mysql_fetch_array($result, MYSQL_ASSOC)) {
      if ($teamName != $RegisterList['TeamName']) {
        $teamName = $RegisterList['TeamName']
    
    ?>
            <tr span=4>
              <td>&nbsp;</td>
            </tr>
    
    <?php
    
        if ($teamName == '') {
    ?>
    
            <tr span=4>
              <td><h2>Unknown</h2></td>
            </tr>
    
    <?php
    
        }
        else {
    
    ?>
    
            <tr span=4>
              <td><h2><?php echo $teamName; ?></h2></td>
            </tr>
    
    <?php
    
        }
      }
    ?>
    
    <?php
    if (STRLEN ($RegisterList['RegisterID']) == 0) {
    ?>
            <tr class="highlight">
    <?php
    }
    elseif ($RegisterList['Active'] == 'N') {
    ?>
            <tr class="highlightitalics">
    <?php
    }
    else {
    ?>
            <tr>
    <?php
    }
    ?>
    
              <td>
                <?php echo $RegisterList['PersonID']; ?>&nbsp;
              </td>
    
              <td>
                <?php echo $RegisterList['AlternateID']; ?>&nbsp;
              </td>
    
              <td>
                <?php echo $RegisterList['LastName']; ?>&nbsp;
              </td>
    
              <td>
                <?php echo $RegisterList['FirstName']; ?>
              </td>
            </tr>
    <?php
    }
    ?>
          </table>
        </div>
    
        <div id="admin_pane_bottom">
        </div>
      </div>
    </div>
    <div class="clear"></div>
    PHP:

    THIS WORKS! See what it should display here: http://www.freeze-hockey.com/MUSL2/report.php?type=registerReportTeam

    This was set up with Dreamweaver:
    <?php require_once('Connections/musl.php'); ?>
    <?php
    mysql_select_db($database_musl, $musl);
    $query_RegisterList = "SELECT Person.PersonID, Person.AlternateID, Person.LastName, Person.FirstName FROM Person ORDER BY Person.LastName, Person.FirstName";
    $RegisterList = mysql_query($query_RegisterList, $musl) or die(mysql_error());
    $row_RegisterList = mysql_fetch_assoc($RegisterList);
    $totalRows_RegisterList = mysql_num_rows($RegisterList);
    ?>
    
    <div id="content_full">
      <div id="content_pane">
        <div id="full">
          <h1>Player Registration Report</h1>
          List of all players on record and their registration status.  Unregistered players are shown in red.  Inactive players are shown in orange italics.
    
          <table width="400" border="1" cellspacing="2" cellpadding="2">
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <?php do { ?>
        <tr>
          <td><?php echo $row_RegisterList['PersonID']; ?></td>
          <td><?php echo $row_RegisterList['AlternateID']; ?></td>
          <td><?php echo $row_RegisterList['LastName']; ?></td>
          <td><?php echo $row_RegisterList['FirstName']; ?></td>
        </tr>
        <?php } while ($row_RegisterList = mysql_fetch_assoc($RegisterList)); ?>
    </table>
    
        </div>
    
        <div id="admin_pane_bottom">
        </div>
      </div>
    </div>
    <div class="clear"></div>
    <?php
    mysql_free_result($RegisterList);
    ?>
    
    PHP:
     
    Darwyn, May 11, 2010 IP
  17. musicmasteria

    musicmasteria Peon

    Messages:
    33
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Well if you are sure the connection to the db is fine it's probably your query.

    I see the query in your working dreamweaver script is different from your non-working script.
    Do the queries return the same results?
    If so you might want to try replacing the query that's in the non-working script with the query in the working script.
     
    musicmasteria, May 11, 2010 IP
  18. Darwyn

    Darwyn Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #18
    I'll give it a shot and let you know the results...
     
    Darwyn, May 11, 2010 IP
  19. Darwyn

    Darwyn Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #19
    Fixed!

    The problem WAS the query!!! I had to add the variable that appeared in the echo statement to the query command, like this:

    <?php
    
    $query_RegisterList  = "SELECT AlternateID, LastName, FirstName, PlayerTransaction.PersonID, TeamName, Person.Active";
    $query_RegisterList .= " FROM Person ";
    $query_RegisterList .= " LEFT OUTER JOIN PlayerTransaction ON Person.PersonID = PlayerTransaction.PersonID AND PlayerTransaction.TransactionType = 'PR' AND NOW() BETWEEN PlayerTransaction.TransactionDate AND PlayerTransaction.TransactionEndDate";
    $quer_RegisterListy .= " LEFT OUTER JOIN PlayerTransaction PlayerTeam ON Person.PersonID = PlayerTeam.PersonID AND PlayerTeam.TransactionType = 'TA' AND NOW() > PlayerTeam.TransactionDate AND PlayerTeam.TransactionEndDate IS NULL";
    $query_RegisterList .= " LEFT OUTER JOIN Team ON PlayerTeam.TeamID = Team.TeamID";
    $query_RegisterList .= " ORDER BY TeamName, LastName, FirstName";
    
    
    $result = mysql_query($query_RegisterList);
    
    ?>
    PHP:
     
    Darwyn, May 11, 2010 IP
  20. musicmasteria

    musicmasteria Peon

    Messages:
    33
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #20
    Glad to hear you were able to resolve your issue. :)
     
    musicmasteria, May 11, 2010 IP