Click here to Skip to main content
16,018,294 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello,

I know very little about programming, means what ever learn, i learnt it from the you tube, so in order to explain my problem i am writing every thing so when i get the reply i can understand it.

first i try to download apache, mysql and phpmyadminn but did not succed.

after that i downloaded XAMPP 1.7.7

In XAMPP 1.7.7 I gave this information for my security

MYSQL SECTION: "ROOT" PASSWORD (This line was already there as a heading)

MYSQL super user : root (it was already there so i cant change)
password : bluebus
PhpMyAdmin authentification: http or cokie (i select cokie),
Safe plain password in text file? ((File: C:\xampp\security\security\mysqlrootpasswd.txt): there was a check box i did not click,

XAMPP DIRECTORY PROTECTION (.htaccess) (this line was already there as a heading)

User: bus
Password : bluebuss,
Safe plain password in text file? ((File: C:\xampp\security\security\mysqlrootpasswd.txt): there was a check box i did not click,

after that i went to phpmyadmin

user : root
password: redbus

after this i created a database, DATABASE NAME: CAR,

After this i added a new user for this database, NEW USER NAME: CAR, and password i gave again "redbus", and i created a table,

after this i created a new file in notpad++, the coding is

1. 2.
3. define ('DB_NAME', 'car');
4. define ('DB_USER', 'car');
5. define ('DB_PASSWORD', 'redbus');
6. define ('DB_HOST', 'localhost');
7. 
8. $link= mysql_connect (DB_HOST,DB_USER,DB_PASSWORD);

9. if (!$link) {
10. die ('could not connect:' . mysql_error () );
11. }
12.
13. $db_selected=mysql_selected_db (DB_NAME, $link);
14.
15. if (!$db_selected) {
16. die ('cant user' . ':' . mysql_error ());
17. }
18. 
19. $value = $_post ['input1'];
20.
21. $sql= "INSERT INTO demo (input1) VALUES ('$value')";
22.
23. if (!mysql_query ($sql)) {
24. die ('error:' . mysql_error () );
25. }
26.
27. mysql_close ();
28. ?>



when i try to run it its give me this error and i dont understand why


[Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'car'@'localhost' (using password: YES) in C:\xampp\htdocs\PhpProject1\index.php on line 8
could not connect:Access denied for user 'malakiarif'@'localhost' (using password: YES)


please help me guys, i try to found out the answer by googling and wasted my whole week but could not find answer, please help me and tell me what i need to correct.

thanks
Posted
Updated 25-May-12 22:10pm
v2
Comments
Mohibur Rashid 26-May-12 4:27am    
did you flush the privileges?
this is the command, if you didnt
flush privileges;

and you also have to make sure that you set privileges to bus for accessing db
arifsuhail 26-May-12 4:53am    
i think i was doing some stupid mistake, as may be cause i dont know much this time what i did in database car, i created a new user name : member and grant him all privillages. so according to this i changed my coding accordingly.... now its like all the things are some but the changes are on line 4 and on line 5 cause i give the new password to my new user too its. redblue... so now the coding is
1.


and i check the privillage for this new user: member as well its says, type-golbal, database specific, privillage-all privillage, grant-yes,

but after running now its showing me this error

Fatal error: Call to undefined function mysql_selected_db() in C:\xampp\htdocs\PhpProject1\index.php on line 14

thanks
arifsuhail 26-May-12 5:04am    
i think i was doing some stupid mistake so this time i added a new user name: member, password: redblue and changed the coding accordingly on line 4 and and five now its look like ......
define ('DB_USER', 'member');
define ('DB_PASSWORD', 'redblue');
but after running it is giving me the error **Fatal Error:** Call to undefined function mysql_selected_db() in C:\xampp\htdocs\PhpProject1\index.php on line 14
line 14 is $db_selected=mysql_selected_db (DB_NAME, $link);...
thanks for help
Mohibur Rashid 27-May-12 9:18am    
its mysql_select_db not mysql_selected_db
arifsuhail 27-May-12 15:51pm    
thx for reply, yah your are right, thanks for help

bye take care

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900