Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Pages: 1 [2]

Author Topic: mysql_connection conflict?  (Read 8593 times)

michael kennedy

  • Full Member
  • ***
  • Karma: 3
  • Posts: 207
    • SpektreDesign
mysql_connection conflict?
« Reply #15 on: July 27, 2007, 02:44:24 AM »

Eh, I'll probably try that on a different site when I get a chance. I don't want to break what I finally got to work. Thanks though.

michael kennedy

  • Full Member
  • ***
  • Karma: 3
  • Posts: 207
    • SpektreDesign
mysql_connection conflict?
« Reply #16 on: August 08, 2007, 08:30:48 AM »

Hmm, same result as before.  It is counting to the DB, but not displaying it on the page... I had to  supress all error messages though.

http://www.mzanime.com/starcraft-maps-beta/

Code: [Select]
function showCount($fileID)
{
    global $cnt_sql;
    @mysql_select_db($MYSQL_DB, $cnt_sql);
    $query = "SELECT count FROM dl_count WHERE file = '$fileID'";
    $result = @mysql_query($query, $cnt_sql);
    if(@mysql_num_rows($result) == 0) {
        return 0;
    } else {
        $count = mysql_fetch_row($result);
        return $count[0];
    }
}
@mysql_select_db(db('dbname')) or die(db('dberror'));

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
mysql_connection conflict?
« Reply #17 on: August 08, 2007, 11:30:52 AM »

C'mon, mike ;)

U have declared $cnt_sql as global inside function, but not $MYSQL_DB. And it's not constant but just variable - so accessible inside functions if explicitly declared as global. So, naturally, that @mysql ... ends with nothing  and that @ sign in front of it makes sure that U receive exactly zero error messages about causes of next problems ;)
Logged

michael kennedy

  • Full Member
  • ***
  • Karma: 3
  • Posts: 207
    • SpektreDesign
mysql_connection conflict?
« Reply #18 on: August 09, 2007, 06:09:23 PM »

Adding global $MYSQL_DB doesn't help.  And I was aware of adding the @ error suppressions.

Looks like I'll have to go back to using the iframe workaround. Cheers.  :(

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
mysql_connection conflict?
« Reply #19 on: August 09, 2007, 09:10:42 PM »

Try to find out what's the problem is:
Code: [Select]
function showCount($fileID)
{
    global $MYSQL_DB;
    global $cnt_sql;
    if ( @mysql_select_db( $MYSQL_DB, $cnt_sql ) ) {
        $query = "SELECT count FROM dl_count WHERE file = '$fileID'";
        if ( $result = @mysql_query($query, $cnt_sql) ) {
            if(@mysql_num_rows($result) == 0) {
                return 0;
            } else {
                $count = mysql_fetch_row($result);
                return $count[0];
            }
        }
        else {
            echo 'Failed to execute query';
        }
    }
    else {
        echo 'Failed to select database';
    }
}
@mysql_select_db(db('dbname')) or die(db('dberror'));
If it's failing to select DB then probably You will need to (re)connect to mysql before selecting it.
Logged

michael kennedy

  • Full Member
  • ***
  • Karma: 3
  • Posts: 207
    • SpektreDesign
mysql_connection conflict?
« Reply #20 on: August 10, 2007, 06:18:40 AM »

It says 'Failed to select database' but ah, to hell with it! Something like this is probably better left outside of sNews to begin with.
Pages: 1 [2]