cannot connect mqsql database - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

cannot connect mqsql database

maxtalkermaxtalker Posts: 5Member
hi I'm new to PHP. I use WAMP server and tried to connect MYSQL database

I create form which contain 4 text feilds

source:


Phone Number:


Reload:


Vendor:





*******************************************************************
mysql database:test
table: reload_menu
fields:id,phonenumber,vendor;
id is set to ubsigned and autoincrement
user:abc
pass:123
*******************************************************************
here is source code for update.php

<?php

$Pnumber =$_POST['txt_phone'];
$Reload =$POST['txt_reload'];
$Vendor =$POST['txt_vendor'];


$con = mysql_connect("localhost","abc","123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("test", $con);

$sql="INSERT INTO reload_menu (id, phonenumber, reload, vendor)
VALUES
('NULL','$_POST[txt_phone]','$_POST[txt_reload]','$_POST[txt_vendor]')";

if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";

mysql_close($con)

?>
********************

when I'm trying to insert record to table using form following error appears.

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'maxtalker'@'localhost' (using password: NO) in C:wampwwwoneupdate.php on line 8
Could not connect: Access denied for user 'maxtalker'@'localhost' (using password: YES)
***************************

Can anyone tell me whats the wrong with my code?

Comments

  • baebae Posts: 45Member
    $con = mysql_connect("localhost","abc","123");

    i guess try to remove user n passward $con = mysql_connect("localhost","","");

    just test
  • maxtalkermaxtalker Posts: 5Member
    thanks mate. I found the problem. I have create table under the user "root"
    and have tried to access using user abc.I substitute abc and 123 to root and " " it works.
    anyway thanks a lot.
Sign In or Register to comment.