I have a form which submits comments onto a page. When the comment is submitted I'm using jQuery to submit the variables and then return me a success message. I have also coded a way of reloading my <div> tag which contains a PHP include file, but I receive a mysql error (shown below) - all variables have been defined:

PHP include code:

<?php

$fresult = mysql_query("SELECT * FROM cmmnts WHERE tusr='$tuid'") 
or die(mysql_error());  
echo "<div id='cmnts'><table width='65%' border='0' cellpadding='4' cellspacing='4' id='table' style='padding-left:20px'>";
while($rhw = mysql_fetch_array($fresult)) {
$cmnt = $rhw['themsg'];
$dte = $rhw['thedate'];
$msgid = $rhw['id'];
$fcom = "(".$cmnt.")<br><hr><br>";
echo "<tr><td id='$msgid'> $fcom </td></tr>";
}
echo "</table></div>";

jQuery code:

success: function(r) { 
    $('.ajaxresult').html(r);
    $('#divcmnts').fadeOut("slow").load('comments.php').fadeIn("slow");

Error:

Warning: mysql_query() [function.mysql-query]: Access denied for user 'usj'@'localhost' (using password: NO) in *MY FILE PATH* on line 6

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in *MY FILE PATH* on line 6
Access denied for user 'usj'@'localhost' (using password: NO)

Any ideas?

Show your error.

First, if that is all code, then $tuid is undefined.

Second, PHP variable names may not start with a digit, so $1result is an invalid name.

Tried the changes you proposed, still nothing. There is a lot, lot more code which is why I only took out the relevant part. The variable $tuid is defined, yes. I also updated my first post with the errors!

Thanks for your reply :)

Check your credentials. Apparently they are incorrect, and the server therefor denies access.

Check your credentials. Apparently they are incorrect, and the server therefor denies access.

The rest of the site functions perfectly correctly with the credentials. When I try and add the database connection function to the include page I get the following error:

Fatal error: Cannot redeclare dbcon() (previously declared in *PATH*/connect.php:4) in *PATH*/connect.php on line 19

connect.php code:

<?php
function dbcon()
		{
		$result = mysql_connect("localhost", "USER", "PASS");
		if(!$result) {
		return false; }
		
		else {
		mysql_select_db("DB");
		}
		
		if(!mysql_select_db("DB")) {
		return false;
		}

		else {
		return $result;
		}
		}

dbcon();
?>

That's because that function already exists in your include file. Perhaps you did not grant that user rights to that specific table. Add error checking to your connect and select DB.

That's because that function already exists in your include file. Perhaps you did not grant that user rights to that specific table. Add error checking to your connect and select DB.

I have tried this, I added error checking on every sql statement run and I gained no information from any of the pages, everything works fine on it.