Jump to content

[Answered] Mysql Error Message In Php Script.


mlseim

Recommended Posts

I'm getting the message below on a PHP script I'm using. It happens in a part where I'm using an AJAX chainselect drop-down menu. I can't figure out why this is showing up and how to fix this.

 

What is really frustrating is that is doesn't happen all the time. Some selections work and some don't.

 

 

Warning: mysql_query() [function.mysql-query]: Access denied for user 'leamsp'@'localhost' (using password: NO) in /home1/leamsp/public_html/prospect/func.php on line 28

 

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home1/leamsp/public_html/prospect/func.php on line 28

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

 

 

Here is a test page ...

 

http://leamspworldwide.heliohost.org/prospect/

Link to comment
Share on other sites

I figured it out.

 

It turns out that the script I was using it on (not the test script that I listed), connects to the MySQL database and displays data on the web page from that database. The AJAX chainselect menu is also on that page. When you select something, the javascript (AJAX) does a get to another PHP script to display the 2nd tier of the menu. It's at that point where it failed. Both my page data AND the AJAX scripts are using the same database (but different tables).

 

So, to make a long story short ....

I'm essentially connecting twice to the same database.

 

My fix ....

 

On the main page, I am now doing this:

 

mysql_connect("localhost", "lechtes", "mypassword") or die(mysql_error());

mysql_select_db("lechtes_profile") or die(mysql_error());

 

 

On the AJAX script (func.php) that is processing the chainselect, I am now doing this:

 

mysql_connect("localhost", "lechtes", "mypassword",TRUE) or die(mysql_error());

mysql_select_db("lechtes_profile") or die(mysql_error());

 

 

The 2nd connection is a "new link" to the same database (using the new link parameter).

 

That eliminated the MySQL connection errors.

 

Thanks everyone for this forum. I've learned a lot by looking at other posts as well.

Discussions on this forum that I don't find on other forums ... nice!

Link to comment
Share on other sites

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.   Paste as plain text instead

  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...