+ Reply to Thread
Results 1 to 2 of 2

Thread: Error: with query id #7

  1. #1
    Tenant is offline x10Hosting Member Tenant is an unknown quantity at this point
    Join Date
    Jan 2009
    Posts
    13

    Error: with query id #7

    I have been receiving the following error Error: with query id #7 and i have been unable to find where the error occurs. This is the code on the page.

    This is the query on the page that is erroring

    Code:
    mysql_connect($db_host, $db_user, $db_pass) or die ('Error: Unable to connect'); 
    mysql_select_db($db_name) or die ('Error: Unable to open the database.'); 
    
    $query = "SELECT * from $db_table ORDER by id DESC LIMIT $from, $limit";
    $result = mysql_query($query);
    $count = mysql_num_rows($result); 
    $table_counter='0';
    if ($count>0) {
        
        while($myrow = mysql_fetch_array($result)){
        
            $comments = $myrow['comments'];
            if (strlen($comments)>95) {$comments = substr($comments,0,95). "..."; }
            $when = explode(" ",$myrow['dated']);
            if ($date_format == '1'){
                $exdate = $when[0];
                list($year, $month, $day) = split('[/.-]', $exdate);
                $when = $month .'-'. $day .'-'. $year;
            }
            else { $when= $when[0]; }        
            $isOK = $myrow['is_approved'];
            $isOKimg = "approved";
            if ($isOK == 0) { $isOKimg = "unapproved";}
            $cap_word = ucwords($isOKimg);
            $image_rating = $myrow['rating'] * 10;
            $star_image = "<img src='../images/stars/blue_".$image_rating.".gif'>";
            if ($select_color == $myrow['id']){
                $tbl_bg='#FFCAE9';
                if ($table_counter == 1){ $table_counter='0'; }
            }
            else{ if ($table_counter == 1){ $tbl_bg='#D6E0EF'; $table_counter='0'; }
                  else { $tbl_bg='#FFFFFF'; $table_counter=$table_counter+1;}
            }
    I can post more if needed but im hoping someone can see my error.
    Last edited by Tenant; 08-17-2009 at 04:54 PM.

  2. #2
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Error: with query id #7

    [quote=Tenant;568595]


    Code:
    mysql_connect($db_host, $db_user, $db_pass) or die ('Error: Unable to connect'); 
    mysql_select_db($db_name) or die ('Error: Unable to open the database.'); 
     
    $query = "SELECT * from $db_table ORDER by id DESC LIMIT $from, $limit";
     
    echo " \$query is $query  <br />\n " ;
    $result = mysql_query($query);
    echo " ran the query <br />\n";
    $count = mysql_num_rows($result); 
    echo "\$count is $count  <br />\n" ;
    $table_counter='0';
    if ($count>0) {
     
        while($myrow = mysql_fetch_array($result)){
    So you can actually see what the query string looks like, not what you think it looks like. $db_table, $from, $limit might be bad values.
    Same for the # of rows returned.
    Also can help you see exactly where the error is happening.
    Nothing is always absolutely so.

+ Reply to Thread

Similar Threads

  1. sql query
    By markl1988 in forum Programming Help
    Replies: 14
    Last Post: 05-30-2009, 05:14 PM
  2. MysQL Query for Master table & child table
    By phpasks in forum Programming Help
    Replies: 8
    Last Post: 08-07-2008, 08:07 AM
  3. A simple PHP query..
    By manuraj.dhanda in forum Programming Help
    Replies: 10
    Last Post: 06-04-2008, 03:43 AM
  4. Replies: 0
    Last Post: 03-18-2008, 12:47 AM
  5. TCP Query port, visor de team speak
    By swoop in forum Soporte
    Replies: 3
    Last Post: 09-03-2007, 01:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers