Error from Database? |
Error from Database? |
tudsy |
Sep 13 2017, 02:00 AM
Post
#1
|
Advanced Member Group: Members Posts: 248 Joined: 30-September 14 Member No.: 21,611 |
Hi
I have been trying to delete an email address from a database and I get this error. I have checked the password and its ok. Error Message: SQLSTATE[42000] [1044] Access denied for user 'ecovibdc_tudsy66'@'localhost' to database 'ecovib2d_Subscribers' Back to my blog - Try again ! 3-Sep-2017 06:52:14 UTC] PHP Notice: Undefined variable: conn in /home/ecovibdc/public_html/ECOVIB2D/unsubscribe/unsubscribe.php on line 69 [13-Sep-2017 06:52:14 UTC] PHP Warning: mysql_close() expects parameter 1 to be resource, null given in /home/ecovibdc/public_html/ECOVIB2D/unsubscribe/unsubscribe.php on line 69 Thanks. Attached image(s) Attached File(s) unsubscribe__2_.php ( 2.07k ) Number of downloads: 1404 Unsubscribe.php ( 1.55k ) Number of downloads: 1401 Sorrytoseeyougo.html ( 1.02k ) Number of downloads: 1352 |
CharlesEF |
Sep 13 2017, 07:08 PM
Post
#2
|
Programming Fanatic Group: Members Posts: 1,984 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
Most of your problems are PHP scope related, among other things. You define $conn inside the Delete() function then you try to use it outside of that function. You can't do that in PHP or any other language I know about. Variables defined in functions are only available to that function (unless you return the value). Also, in PHP global scope is different than in Javascript.
You create a database connection using PDO but then you try to use 'mysql*' methods. PDO has it's own methods, use them instead. You didn't post the correct page for the 1st error message so I can't look into that. |
tudsy |
Sep 14 2017, 12:06 AM
Post
#3
|
Advanced Member Group: Members Posts: 248 Joined: 30-September 14 Member No.: 21,611 |
Most of your problems are PHP scope related, among other things. You define $conn inside the Delete() function then you try to use it outside of that function. You can't do that in PHP or any other language I know about. Variables defined in functions are only available to that function (unless you return the value). Also, in PHP global scope is different than in Javascript. You create a database connection using PDO but then you try to use 'mysql*' methods. PDO has it's own methods, use them instead. You didn't post the correct page for the 1st error message so I can't look into that. Hi Thanks for that. I still get this error: Error Message: SQLSTATE[42000] [1044] Access denied for user 'ecovibdc_tudsy66'@'localhost' to database 'ecovib2d_Subscribers' Back to my blog - Try again ! Unsubscribe.php ( 1.55k ) Number of downloads: 1557 unsubscribe1.php ( 2.01k ) Number of downloads: 1521 Sorrytoseeyougo.html ( 1.02k ) Number of downloads: 1532 |
CharlesEF |
Sep 14 2017, 01:30 AM
Post
#4
|
Programming Fanatic Group: Members Posts: 1,984 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
That is a database connection error message. Make sure your host, user name and password are correct.
|
CharlesEF |
Sep 14 2017, 12:41 PM
Post
#5
|
Programming Fanatic Group: Members Posts: 1,984 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
Instead of creating your database connection in a function I would recommend you create a class and use it. This is a nice tutorial of doing that, here. You still have a lot of research to do concerning PHP.
|
Lo-Fi Version | Time is now: 27th September 2024 - 03:55 AM |