Class MySQLDB not found error pls look at this

Discussion in 'PHP' started by hindlist, Apr 7, 2010.

  1. #1
    Hello i am getting a error of Class MySQLDB not found on few php validators. The exact line is $myDB = new MySQLDB(); $nav = 1; and also some undefined index error is showing before some lines of this error. the exact line of that is <?php if($_GET['catg'] != '') i.e is very first line of code. I am giving code for ready reference. I have tried and given up. Waiting for reply for the error from some good heart and brain member of this site.

    <?php if($_GET['catg'] != '')
    {
    //if($_GET['grou'] != 'pers' || (isset($_GET['app']) && $_GET['app'] == 1)){
    $myDB = new MySQLDB();
    // echo 'In category';
    $sql = "SELECT scateno, cateno, scatename FROM hl_subcategory WHERE cateno = (SELECT cateno FROM hl_category WHERE catename = '".resetEscapeChar($_GET['catg'])."')";

    //$tarr = array(); $tcount = 0;
    $cateno = 0; $scateno = 0;
    //echo $sql."<br>";
    if(isset($_GET['country'])) $country = $_GET['country']; else $country = '';
    $result = $myDB->executeSQL($sql) or die("could not execute stored proc <br>".mysql_error());
    while ($result_row = mysql_fetch_array($result, MYSQL_ASSOC)){
    //$tarr[$tcount++] = '<a class="link" href="subcategory.php?sub='.$result_row['scatename'].'&catg='.$_GET['catg'].'&country='.$country.'&city='.$_GET['city'].'&grou='.$_GET['grou'].'">'.$result_row['scatename'].'(#)</a><br><br>';
    $cateno = $result_row['cateno'];
    //echo $result_row['scatename'] ." ".strcmp($result_row['scatename'],resetEscapeChar($_GET['sub']))." ".resetEscapeChar($_GET['sub'])."<br/>";
    if(strcmp(trim($result_row['scatename']),trim(resetEscapeChar($_GET['sub'])))==0)
    {
    $scateno = $result_row['scateno'];
    }
    // break;
    }
    mysql_free_result($result) or die("could not close result set <br>".mysql_error());
    $myDB->close();

    $temstr = '';
    $countryname = 'World'; $myDB = new MySQLDB(); $nav = 2;
    $sql = "SELECT artidesc FROM hl_articles";
    if($_GET['country'] != ''){
    $countryname = $_GET['country'];
    if($_GET['city'] != '') $countryname = $_GET['city'];
    $nav = 2;
    }
    $sql .= " WHERE groupid = ".$gid." AND cateno = ".$cateno." AND scateno = ".$scateno." AND navigation = ".$nav;
    //echo $sql;
    $result = $myDB->executeSQL($sql) or die("could not execute stored proc <br>".mysql_error());
    while ($result_row = mysql_fetch_array($result, MYSQL_ASSOC)){
    $temstr = str_replace("|", $countryname, $result_row['artidesc']);
    }
    mysql_free_result($result) or die("could not close result set <br>".mysql_error());
    $myDB->close();

    echo "<div class='message'>".$temstr."</div>";
    }
    else
    {
    $myDB = new MySQLDB(); $nav = 1;
    if($_GET['country'] != '') $countryname = $_GET['country'];
    $sql = "SELECT artidesc FROM hl_articles WHERE navigation = ".$nav;
    $result = $myDB->executeSQL($sql) or die("could not execute stored proc <br>".mysql_error());
    while ($result_row = mysql_fetch_array($result, MYSQL_ASSOC))
    {
    $temstr = str_replace("|",$countryname,$result_row['artidesc']);
    }
    //echo $sql;
    echo "<div class='message'>".$temstr."</div>";
    mysql_free_result($result) or die("could not close result set <br>".mysql_error());
    $myDB->close();
    }
    ?>
     
    hindlist, Apr 7, 2010 IP
  2. javaongsan

    javaongsan Well-Known Member

    Messages:
    1,054
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #2
    you probably need to include the file that contains Class MySQLDB
     
    javaongsan, Apr 7, 2010 IP
  3. hindlist

    hindlist Member

    Messages:
    72
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    Thank you. you said it right and my doubt is where exactly should i include the file and also shall i include it through href .
     
    hindlist, Apr 8, 2010 IP
  4. javaongsan

    javaongsan Well-Known Member

    Messages:
    1,054
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #4
    include it right at the top
    using php
    <?php
    require_once('MySQLDB.php') //or where the file resides
    ?>
     
    javaongsan, Apr 8, 2010 IP
  5. hindlist

    hindlist Member

    Messages:
    72
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #5
    Thankyou for your help and it has worked the most but Now after implementing what you said, now the error is gone but now it is showing as Can't connect to MySQL server on 'hindlist.db.********.hostedresource.com' (nnnnn) in E:\db.php on line 10. Why is it coming this way now after solving the error. Any more ideas pls
     
    hindlist, Apr 8, 2010 IP
  6. javaongsan

    javaongsan Well-Known Member

    Messages:
    1,054
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #6
    Is this your db server? are trying to connect to a remote db server? check your database connection config.
     
    javaongsan, Apr 8, 2010 IP
  7. hindlist

    hindlist Member

    Messages:
    72
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #7
    o.k thank you. i will check the same and see
     
    hindlist, Apr 11, 2010 IP
  8. hindlist

    hindlist Member

    Messages:
    72
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #8
    Thank you I got it right. And also I am very sorry as I responded very late to say Thank you.
     
    hindlist, Apr 28, 2010 IP