Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: mysql error  (Read 1982 times)

adi

  • Newbie
  • *
  • Karma: 0
  • Posts: 12
mysql error
« on: September 14, 2007, 02:36:09 pm »

Hi all,

I'm getting errors on my install - http://www.theenvironmentsite.org/guides/ - above the admin login link.

"mysql_query() [function.mysql-query]: A link to the server could not be established" error

It leads to the following code

Quote
function s($variable) {
   $query = "SELECT value FROM ".db('prefix')."settings WHERE name = '$variable'";
   $result = mysql_query($query);
   while ($r = mysql_fetch_array($result)) {$value = $r['value'];}
   return $value;

Any ideas?
Logged

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
Re: mysql error
« Reply #1 on: September 15, 2007, 01:16:24 pm »

could you please post the index.php file, or at least the part that is thowing the wobbly.
Logged
Of all the things I have lost, it is my mind that I miss the most.

adi

  • Newbie
  • *
  • Karma: 0
  • Posts: 12
Re: mysql error
« Reply #2 on: September 15, 2007, 01:26:07 pm »

That is the code that's breaking things in my initial post.
Logged

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
Re: mysql error
« Reply #3 on: September 15, 2007, 02:03:04 pm »

simply put, something has been done that is causing the function posted to fail.

on a further look, it would seem that you are trying to only use a part of snews... yes??
or rather only a part of your site is snews based...yes??
maybe not...

still, more info is required...
standard being, index.php, htaccess, settings part of snews.php (with passwords etc asterixed out)
« Last Edit: September 15, 2007, 02:07:09 pm by philmoz »
Logged
Of all the things I have lost, it is my mind that I miss the most.

adi

  • Newbie
  • *
  • Karma: 0
  • Posts: 12
Re: mysql error
« Reply #4 on: September 17, 2007, 11:18:15 am »

I got this from my host this morning:

Quote
Upon reviewing this, it appears the errors are caused by the function login_link() in snews.php. If you comment out the content of this function, the page seems to load without error. This does not appear to be caused by any sessions issues on the server, as uploading a sessions testing script to your account indicates that the sessions are being properly passed. You will need to review the code for the login_link() function to determine the cause of these errors.
Logged

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
Re: mysql error
« Reply #5 on: September 17, 2007, 01:11:37 pm »

This is the function from snews1.6 (standard issue.. if you are using snewsMU, there may be an issue.)
Code: [Select]
1) function login_link() {
2) $login = '<a href="'.db('website');
3) $login .= $_SESSION[db('website').'Logged_In'] == token() ? 'administration/" title="'.l('administration').'">'.l('administration') : 'login/" title="'.l('login').'">'.l('login').'';
4) $login .= '</a>';
5) echo $login;
6) }
line by line.
1) define function name, begin definition
2) set var $login to value
3) alternate php if statement.
---add to $login, if logged make the link point to admin page,otherwise present link for login.
4) add to $login
5) display result
6) close out function def.

Now, looking at your site, you have a login link which is active...I tested it, and it brings up the login page. If the function was faulty, that simply wouldn't happen.

So, I would tend to think that your host has done what they could to prove their service is ok, but their suggestion is off the mark [refrained from heavier wording out of good taste]

Are you calling anything else just prior to the <?php login_link(); ?> in index.php.
(index.php is one of the bits of info requested above)

« Last Edit: September 17, 2007, 01:15:01 pm by philmoz »
Logged
Of all the things I have lost, it is my mind that I miss the most.

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
Re: mysql error
« Reply #6 on: September 17, 2007, 01:54:53 pm »

Verify the MySQL username, password, and database name and database host are correct for your MySQL server.
That is, make sure you have the correct info provided by your host correct.
« Last Edit: September 17, 2007, 02:10:13 pm by philmoz »
Logged
Of all the things I have lost, it is my mind that I miss the most.

adi

  • Newbie
  • *
  • Karma: 0
  • Posts: 12
Re: mysql error
« Reply #7 on: September 18, 2007, 10:04:36 am »

Hi Phil,

Thanks for your input.  There is no other php code in the segment including the login code.  I'm not really sure what you mean by verifying the db info.  I can log-in to the administration area without any problems so I presume the connection string associated with sNews is working ok.
Logged

piXelatedEmpire

  • MIA
  • ULTIMATE member
  • ******
  • Karma: 37
  • Posts: 1401
  • currently MIA
Re: mysql error
« Reply #8 on: September 19, 2007, 02:16:48 am »

You really aren't supply us with much information at all to assist you here.  Help us help you.  Please provide information about your server config (like the version of php and mysql you have on the server you're using).

Phil is suggesting you make sure the database information you have enetered is correct.  These are the errors you are receiving on your site, which indicate there is an issue with the way you have setup your database info:
Quote
Warning: mysql_query() [function.mysql-query]: Access denied for user 'theen8'@'localhost' (using password: NO) in /home/theen8/public_html/guides/snews.php on line 251

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/theen8/public_html/guides/snews.php on line 251

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/theen8/public_html/guides/snews.php on line 252
These errors suggest something is not right with the way you have setup your database information (such as username or password or the like).

Please copy the following info from your snews.php file and post it here (remove ur password):
Quote
   $db['website'] = 'http://localhost/snews/';
   $db['dbhost'] = 'localhost'; //MySQL Host
   $db['dbname'] = 'snews'; //Database Name
   $db['dbuname'] = 'xxxxxxxx'; //Database Username
   $db['dbpass'] = 'xxxxxxxx'; //Database password
   $db['prefix'] = ''; //Database prefix
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future