473,320 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Adding to database Error

3
Hey guys,

can someone please help me... im gettin this error when im trying to add information to my sql database. I think its to do with the connect.

Does anyone know how to sort this problem out??

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\wamp\www\test\insert_ac.php on line 10
cannot connect


THIS IS MY CODE
insert.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $host="localhost"; // Host name
  4. $username=""; // Mysql username
  5. $password=""; // Mysql password
  6. $db_name="test"; // Database name
  7. $tbl_name="test_mysql"; // Table name
  8.  
  9.  
  10. mysql_connect("$host", "$username", "$password")or die("cannot connect");
  11. mysql_select_db("$db_name")or die("cannot select DB");
  12.  
  13.  
  14. $name=$_POST['name'];
  15. $lastname=$_POST['lastname'];
  16. $email=$_POST['email'];
  17.  
  18.  
  19. $sql="INSERT INTO $tbl_name(name, lastname, email)VALUES('$name', '$lastname', '$email')";
  20. $result=mysql_query($sql);
  21.  
  22.  
  23. if($result){
  24. echo "Successful";
  25. echo "<BR>";
  26. echo "<a href='insert.php'>Back to main page</a>";
  27. }
  28.  
  29. else {
  30. echo "ERROR";
  31. }
  32.  
  33. mysql_close();
  34. ?>
Hope someone can help,

many many thanks
donno
Apr 17 '07 #1
3 1294
Motoma
3,237 Expert 2GB
Take a look at your error message. If you look closely you will see that is your script is trying to authenticate as user "ODBC" with no password.

If you take a look at your corresponding code, you will quickly notice that you have not set a user name and password for your mysql database connection; rather, you have left them as empty strings.
Apr 18 '07 #2
donno
3
Excellent, i got it working.

Thanks Alot!!!!
Apr 18 '07 #3
Motoma
3,237 Expert 2GB
Glad everything worked out.
Apr 18 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Sérgio Almeida | last post by:
Greetings I'm having problems adding records to an access database. What I want to do is very simple. Here is my code. __CODE_START__ dim sqlStatement sqlStatement="insert into...
1
by: Anand | last post by:
Hi i am having trouble adding a recordset into the access database, the code seems to be working fine it passs and parses through all variables just fine without showing any errors and also when i...
1
by: microsoft.public.dotnet.languages.vb | last post by:
Hi All, I am having a serious problem of removing and adding again an user in a database. Microsoft SQL Server 2000 - 8.00.760 (Intel X86) Dec 17 2002 14:22:05 Copyright (c) 1988-2003...
0
by: brijeshmathew | last post by:
Hi I use Visual Basic 6, Service Pack 6, Microsoft ActiveX Data Objects 2.8 Library(msado15.dll) and access 2000 database using JET 4 OLE. I have an application that adds records simultaneously...
3
by: ET | last post by:
I don't know whats the problem, but after I added functions to first verify, then relink linked tables if not found, now I can't convert that database to MDE format. I can split the database, but...
0
by: Lucas Tam | last post by:
Hi all, I posted a message a couple minutes early and I'm not sure if it was too clear. I'm interested in adding custom messages to the validation control - is there an easy way to do this?...
12
by: Art | last post by:
Hi everyone I was hoping someone might be able to help me with this. I'm just starting to try to work with MS Access tables through VB.net. In Access I can take an existing table and add a new...
1
by: Ben Ramsey | last post by:
I'm using PostgreSQL on a Windows 2000 server and cygwin. All is set up just fine. The database works just fine, and ASP is connecting to the database through a DSN just fine. The only problem I...
1
by: chriscely | last post by:
Good day to everybody! I have been having this problem for quite a few times already. I have been trying to add informations to our database, the programs on my add page (entry_schedule.asp) is...
1
by: =?Utf-8?B?TGVvbiBNYXluZQ==?= | last post by:
In a database project in VS2005 (not a datadude project), I need to add about 3,000 stored procedure scripts to my 'Stored Procedures' folder. I've dropped the scripts into the folder in my...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.