Error: with query id #7

Tenant

New Member
Messages
13
Reaction score
0
Points
0
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:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
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";
 
[B]echo " \$query is $query  <br />\n " ;[/B]
$result = mysql_query($query);
[B]echo " ran the query <br />\n";[/B]
$count = mysql_num_rows($result); 
[B]echo "\$count is $count  <br />\n" ;[/B]
$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.
 
Top