Jump to content

Strange mysql_connect problem


deceevn

Recommended Posts

Hi,

 

I get this error when I load the page, but after hitting ctrl f5 to refresh.. the error goes away and the page works perfectly.  I have edited out my details.

 

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'user'@'localhost' (using password: YES)

Access denied for user 'user'@'localhost' (using password: YES)

 

I know everything is set right.. I just don't get it.. I am going crazy of this. Ive cleared my browser cache.. even tried it on my android phone and it does the same thing.

 

Thanks,

Deceevn

 

 

Link to comment
Share on other sites

Here is the code. It's just weird it works after hittin refresh.. makes no sense to me

 

mysql_connect("localhost", "vikingde_lapalm", "pass") or die(mysql_error());

$category = mysql_real_escape_string($_GET['cat']);

$products = mysql_query("SELECT id, prod_name, prod_img_thumb FROM vikingde_lapalm.products WHERE prod_cat='$category'");
$prod_num_rows = mysql_num_rows($products);

					if ($prod_num_rows==0)
						echo "Not A Valid Category!";
					else {
					$i = 0;

					while($row = mysql_fetch_array($products)){
					$i++;
					$id = $row['id'];
					$prod_name = $row['prod_name'];
					$prod_img_thumb = $row['prod_img_thumb'];
        
					$additionalClass = ($i % 3) == 0 ? " nomargin" : "";
					echo "<li class='boxshadow " . $additionalClass . "'><br />";
					echo "<a href='products_desc.php?id=$id'><img src='$prod_img_thumb' alt='' /></a>";
					echo "<br />";
					echo "<h5><a href='products_desc.php?id=$id'>$prod_name</a></h5>";
					echo "</li>";
						}
					}

 

Also here is the link to the live page:

 

http://vikingdevelopment.us/millenia/index.php

Link to comment
Share on other sites

I don't see any major problem with the code.  Just looks like a case of there not being permissions for that user or the password not matching.  Do you have a shell on the host, where you can try logging in with the mysql command line client? 

Link to comment
Share on other sites

Use the command:

mysql -u vikingde_lapalm -p vikingde_lapalm

It will prompt you for a password, enter the MySQL password you use in the script. If you are successful, then your credentials are correct.

Link to comment
Share on other sites

This is what i got:

 

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

 

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 5143036

Server version: 5.1.54-log MySQL Community Server (GPL)

 

Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.

This software comes with ABSOLUTELY NO WARRANTY. This is free software,

and you are welcome to modify and redistribute it under the GPL v2 license

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

Link to comment
Share on other sites

Yea I added it to the db.. its very strange.. I just noticed my other scripts are giving the same error so there has to be something going on with my hosting company or something has changed on the server that is breaking my code. Anyway.. thanks everyone for your help. I'll keep you updated if something new comes up.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.