Recent Topics

[3.3.3] Getting MySQL message when linking from a banner to

Started by on Feb 22, 2010 – Contents updated: Feb 22, 2010

Feb 22, 2010 01:39    

My b2evolution Version: 3.3.3

Hi!, I´m sorry if this problem is linked to some other topic, but I could not find it.

I put a banner on a forum system which links to a blog.
The whole blog program works fine, I use 3.3.3

Link to the forum:

http://www.zoetecnocampo.com/cgi-bin/ubbcgig/Ultimate.cgi

You´ll see a banner on the right side in orange with a blue logo, animated gif.

I linked it to the blog:

http://www.zoetecnocampo.com/evolution/blogs/index.php?blog=7

but, when I click I get this message:

"Información adicional acerca de este error:
MySQL error!

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where blog_stub like 'evolution'' at line 1(Errno=1064)

Your query:

select blog_ID from where blog_stub like 'evolution'"

then, if I JUST hit Enter when seeing this error page, I get the blog correctly, not with the refresh.

I have tried with the example blogs too, just in case I had done some error, and also with the stub php file too...

May be it´s very simple problem, but I can not solve it!

Any help will be greatly appreciate.

Thanks. Rosa

Feb 22, 2010 05:09

Hi again, I found the problem.
I had installed a hack.php file which I copied from "somewhere" here, and I don´t even remember what it was supposed to do.
It´s the only file the has this line:

select blog_ID from

This file was also causing the same problem with links in twitter, but I thought it was just me and twitter "affair"... I don´t use it.

I don´t know if I should post the code here.

Well, if somebody is interested...

Bye. Rosa

Feb 22, 2010 17:38

Welcome to the forums.

Please post the content of hacks.php here. Remove any personal info from it ;)

Feb 23, 2010 00:56

Hi Sam, thanks!

<?php
if( (!empty($_SERVER['HTTP_REFERER'])) && (strpos( $_SERVER['HTTP_REFERER'],$baseurl) !== 0) && (strpos( $ReqURI , '&hack=autoforward' ) == 0) )
{
     $pos = strpos( $ReqURI, $baseurl );
     // echo "ReqURI = $ReqURI <br />";
     $path_string = substr( $ReqURI, $pos );
     // echo "path=$path_string <br />";
     $path_elements = explode( '/', $path_string, 20 );     // slice it
     $i=1;
     // echo $path_elements[$i];
     if( isset( $path_elements[$i] ) && ($path_elements[$i] == 'index.php') )
     { // Ignore index.html
          $i++;
     }
 
     // echo "path_element[$i] = $path_elements[$i] <br />";
     if( isset( $path_elements[$i] ) )
     {
          //echo "query = select blog_ID from $tableblogs where blog_stub like '".$path_elements[$i]."'";
          $db_blog_id = $DB->get_row("select blog_ID from $tableblogs where blog_stub like '".$path_elements[$i]."'");
          if( $db_blog_id )
          { // Ignore stub file
               $i++;
          }
     }
 
     // echo $path_elements[$i];
     if( isset( $path_elements[$i] ) && is_numeric( $path_elements[$i] ) )
     {     // We'll consider this to be the year
          $m = $path_elements[$i++];
          // echo "m = $m <br />";
          // echo "path_element[$i] = $path_elements[$i] <br />";
          if( isset( $path_elements[$i] ) && is_numeric( $path_elements[$i] ) )
          {     // We'll consider this to be the month
               $m .= $path_elements[$i++];
 
               if( isset( $path_elements[$i] ) && is_numeric( $path_elements[$i] ) )
               {     // We'll consider this to be the day
                    $m .= $path_elements[$i++];
 
                    if( isset( $path_elements[$i] ) && (!empty( $path_elements[$i] )) )
                    { // We'll consider this to be a ref to a post
                     // We are accessing a post by permalink
                     // Set a lot of defaults as if we had received a complex URL:
                         $m = '';
                         $more = 1; // Display the extended entries' text
                         $c = 1;  // Display comments
                         $tb = 1;  // Display trackbacks
                         $pb = 1;  // Display pingbacks
 
                         if( preg_match( "#^p([0-9]+)$#", $path_elements[$i], $req_post ) )
                         {     // The last param is of the form p000
                              // echo 'post number';
                              $p = $req_post[1];                                             // Post to display
                         }
                         else
                         { // Last param is a string, we'll consider this to be a post urltitle
                              $title = $path_elements[$i];
                              // echo 'post title : ', $title;
                         }
                    }
               }
          }
          elseif( isset( $path_elements[$i] ) && substr( $path_elements[$i], 0, 1 ) == 'w' )
          {     // We consider this a week number
               $w = substr( $path_elements[$i], 1, 2 );
          }
     }
     
     if( (empty($p)) && (empty($title)) && (empty($preview)) )
     {
          $ref = $_SERVER['HTTP_REFERER'];
          if( ($pos_question = strpos( $ref, '?' )) == false )
          {
               //echo '[', T_('not a query - no params!'), ']';
          }
          else
          {
               $ref_params = explode( '&', substr( $ref, $pos_question+1 ) );
               foreach( $ref_params as $ref_param )
               {
                    $param_parts = explode( '=', $ref_param );
                    if( $param_parts[0] == 'q' or $param_parts[0] == 'query' or $param_parts[0] == 'p' or $param_parts[0] == 'kw' or $param_parts[0] == 'qs' )
                    { // found "q" query parameter
                         $q = urldecode($param_parts[1]);
                         if( strpos( $q, 'Ã' ) !== false )
                         {     // Probability that the string is UTF-8 encoded is very high, that'll do for now…
                              //echo "[UTF-8 decoding]";
                              $q = utf8_decode( $q );
                         }
                         $qwords = explode( ' ', $q );
                         foreach( $qwords as $qw )
                         {     
                              if( strlen( $qw ) > 30 ) $qw = substr( $qw, 0, 30 )."…";     // word too long, crop it
                              $kwout .= $qw.'+';
                         }
                         $blog = 2;
                         //log_hit();
                         echo "<a href=http:". $_SERVER['SERVER_NAME']. "/index.php?s=" . $kwout . "&sentence=AND&submit=Search&blog=1&hack=autoforward >Possible issue with redirection, please click here for article</a>";
                         Header("Location: http://". $_SERVER['SERVER_NAME']. "/index.php?s=" . $kwout . "&sentence=AND&submit=Search&blog=1&hack=autoforward"); 
                         die();
                    }
               }
          }
     }
}
 
?>

I´m sorry I can´t remember. It was at the very beginning of the installation some days ago. I just created the hack.php file and copied the code.
Cheers. Rosa

Feb 23, 2010 18:02

Thanks Sam, I got the problem solved as I said, when I deleted the file.
It´s a little bit messy for begginers to deal with the different versions.
Cheers. Rosa


Form is loading...

Build your own website! – This forum is powered by b2evolution CMS, a complete engine for your website.