Jump to content

Recommended Posts

am getting this error:

<br />
<b>Warning</b>:  mysql_query() [<a href='function.mysql-query'>function.mysql-query</a>]: Access denied for user 'ODBC'@'localhost' (using password: NO) in <b>C:\wamp\www\EMO\validate.php</b> on line <b>123</b><br />
<br />
<b>Warning</b>:  mysql_query() [<a href='function.mysql-query'>function.mysql-query</a>]: A link to the server could not be established in <b>C:\wamp\www\EMO\validate.php</b> on line <b>123</b><br />
Access denied for user 'ODBC'@'localhost' (using password: NO)

 

This happens when ajax uses the validate.php to check the database on the background. Its not the connection that is the problem, there is something else.

 

this is the function:

function validateReceiptNumber($val)
{
global $continueSubmit ;
$conn = mysql_connect("localhost", "root", "");
  mysql_select_db("emobase2");
 $check = "select `Receipt Number` from members where `Receipt Number` = '$val';"; 
  $qry = mysql_query($check, $conn) or die (mysql_error());
      $num_rows = mysql_num_rows($qry); 
 echo $num_rows;
if ($num_rows != 0) 
           { $continueSubmit = false;
	   echo "Sorry, the Receipt Number is already available.<br>";  

 }else{ echo "Thank You";} 

}

 

There error on line 123 should be an issue because when $val in the function above is changed to another value like 1, the error is "0Thank You" and if $val = 4923, the error is the one above and if $val= 12, the error is "1Sorry".

 

Is there a problem in my function?

 

regards,

Joseph

Link to comment
https://forums.phpfreaks.com/topic/127523-error/
Share on other sites

There is no connection to a mysql server at the time the mysql_query() executed and the mysql_query attempted to create a connection using all default values.

 

If this varies depending on a value, than something in the remainder of the code in the file that you did not post is causing this or the posted code is not the actual code.

 

Your code has absolutely no error checking logic (test for errors), no error reporting logic (display a meaningful message), no error logging logic (log what did happen so you have a record for troubleshooting), and no error recovery logic (what does the code do when an error occurs) so it is impossible for you to know if the mysql_connect or mysql_select_db function calls in that function were successful.

Link to comment
https://forums.phpfreaks.com/topic/127523-error/#findComment-659777
Share on other sites

Its funny,

The code now works after i deleted temporary internet files.

But the message its supposed to echo is short, i.e its supposed to be "Sorry, the Receipt number........." but its giving "0Sorry" if the value exists and "1Thank You" if the value does'nt exist in database" You realise i added a 0 (Zero) and a 1 (one) after the message, It is the system which is giving this values and they are not in my echo message. I dont know how to get rid of them.

 

All this errors i think its from AJAX, the legth of the echo message should be short i think because AJAX requires short time to process things (i dont understand there but told somewhere). The values also i think its an AJAX problem.

 

Regards

Joseph

Link to comment
https://forums.phpfreaks.com/topic/127523-error/#findComment-659868
Share on other sites

function validateReceiptNumber($val)

{

global $continueSubmit ;

$conn = mysql_connect("localhost", "root", "");

  mysql_select_db("emobase2");

$check = "select `Receipt Number` from members where `Receipt Number` = '$val';";

  $qry = mysql_query($check, $conn) or die (mysql_error());

      $num_rows = mysql_num_rows($qry);

>>>  echo $num_rows;  <<<

if ($num_rows != 0)

           { $continueSubmit = false;

   echo "Sorry, the Receipt Number is already available.<br>"; 

 

}else{ echo "Thank You";}

 

}

Link to comment
https://forums.phpfreaks.com/topic/127523-error/#findComment-659877
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.