ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Upgrade 2.2.2 to 2.4 Issues - PHP Errors

March 09, 2012 8:20pm

Subscribe [1]
  • #1 / Mar 09, 2012 8:20pm

    marsdesign

    3 posts

    There are snippets where sql code that gets evaluated by the system and executed.
    If I browse the front end of the site as an admin, I get an db connection error, derived of the code in the snippets. The snippets show a connection string with a certain db server, but this error is showing a totally different db server than specified in the connection string in the snippet (a database server called weink.net)

    Typical Error

    <h4>A PHP Error was encountered</h4>
    
    <p>Severity: Warning<br />
    Message:  mysql_connect() [<a href="http://function.mysql-connect">function.mysql-connect</a>]: Access denied for user 'reelabilities_mu'@'weink.net' (using password: YES)<br />
    Filename: libraries/Functions.php(659) : eval()'d code<br />
    Line Number: 30</p>
    
    <p></div><div></p>
    
    <h4>A PHP Error was encountered</h4>
    
    <p>Severity: Warning<br />
    Message:  mysql_select_db(): supplied argument is not a valid MySQL-Link resource<br />
    Filename: libraries/Functions.php(659) : eval()'d code<br />
    Line Number: 32</p>
    
    <p></div>

    I’ve searched the database and code for weink.net and found nothing. No idea where this is coming from.

    Saving the snippet fixes the problem for all users, until the admin browses the front end again, upon which the errors start again.

    An example of the snippet code is here (with actual database values replaced)

    <?php
    
     $conx = mysql_connect("SERVER HERE","USER HERE","PASSWORD HERE");
     
     mysql_select_db("DB NAME HERE",$conx);
     
     $cities = mysql_query("select * from exp_channel_titles where channel_id='119' and status = 'open' order by title asc");
    
     while($city = mysql_fetch_object($cities))
     {
      $style="";
      $site_short_name = "{site_short_name}";
      if($site_short_name == $city->url_title)
      {
       $style = "style=\"color:#F90\"";
      }
      echo 
      '
       <div class="city"><a class="city">url_title . '.reelabilities.org"><span>'.$city->title.'</span></a></div>
      ';
    
     }
    
     
    ?>
  • #2 / Mar 10, 2012 1:06pm

    marsdesign

    3 posts

    This appears solved now as well -
    I commented out the mysql_connect line and the mysql_select_db line and no more errors.
    I guess the system has already connected to the db and there’s no need to specify in the snippet.

    Still a mystery as to where or how the other database server value was ever part of the mysql_connect function.

    //$conx = mysql_connect(’server’,'user','pass');
     
     $the_city = "{site_short_name}";
     $the_domain_name = "reelabilities.org";
     
     //mysql_select_db("reelabilities_multisite_db_final",$conx);

    Mod edit: changed connection values for security.

  • #3 / Mar 11, 2012 12:08am

    Dan Decker

    7338 posts

    Hi mshvartsur,

    You’re 2 for 2, on a roll!

    I’m glad to see you were able to sort this one out as well.

    If you need us in the future, just let us know.

    Cheers!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases