Access Database Error

Alles, was MariaDB und MySQL betrifft, kann hier besprochen werden.

Access Database Error

Postby mickeymouse » 26. August 2021 00:06

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:\xampp\htdocs\HA_LogInCheck.php:58 Stack trace: #0 {main} thrown in C:\xampp\htdocs\HA_LogInCheck.php on line 58

$host = "localhost"

$link= mysql_connect($host, <---line 58
$username,
$password);

Where is my error?
Thanks
mickeymouse
 
Posts: 58
Joined: 08. March 2009 06:10
Location: France & Canada
Operating System: Win 7 Family Prem Ed (64 bit?)

Re: Access Database Error

Postby Altrea » 26. August 2021 00:17

the manual is your friend. read especially the information in the red box
https://www.php.net/manual/en/function. ... onnect.php
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Access Database Error

Postby mickeymouse » 26. August 2021 12:15

Thanks.
I've changed to $conn = new mysqli($host, $username, $password); but still can't connect. $password = ""
Am I supposed to have a password? I don't think my DB has a password here.
mickeymouse
 
Posts: 58
Joined: 08. March 2009 06:10
Location: France & Canada
Operating System: Win 7 Family Prem Ed (64 bit?)

Re: Access Database Error

Postby Altrea » 26. August 2021 12:37

output mysqli errors to gr an idea why something went wrong.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Access Database Error

Postby mickeymouse » 26. August 2021 13:43

Can you tell me how to do that?
I've tried with mysqli::$connect_error -- mysqli_connect_error but it doesn't work.
mickeymouse
 
Posts: 58
Joined: 08. March 2009 06:10
Location: France & Canada
Operating System: Win 7 Family Prem Ed (64 bit?)

Re: Access Database Error

Postby Altrea » 26. August 2021 14:47

again, start using the manual:
https://www.php.net/manual/en/mysqli.error.php

it contains a full example of error handling of connection errors.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Access Database Error

Postby mickeymouse » 26. August 2021 17:00

I've tried to go according to the manual but can't get anywhere. I've tried several of the examples and always the same results.

One of my attempts is the following - just like the example - but doesn't work or at least, doesn't give me more info. It in fact tells me I have errors in the code (which is the same as the example so how can I have errors?)

if ($mysqli->connect_errno) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}


Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'homeaccdbnm'@'localhost' (using password: NO) in C:\xampp\htdocs\HA_LogInCheck.php on line 59

Warning: Undefined variable $mysqli in C:\xampp\htdocs\HA_LogInCheck.php on line 61

Warning: Attempt to read property "connect_errno" on null in C:\xampp\htdocs\HA_LogInCheck.php on line 61
mickeymouse
 
Posts: 58
Joined: 08. March 2009 06:10
Location: France & Canada
Operating System: Win 7 Family Prem Ed (64 bit?)

Re: Access Database Error

Postby Altrea » 26. August 2021 17:44

Are you serious?

mickeymouse wrote:Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'homeaccdbnm'@'localhost' (using password: NO) in C:\xampp\htdocs\HA_LogInCheck.php on line 59

This is far more information than you ever gave us. Obviously there is a problem with the database user. Please dounle check in phpmyadmin that the user homeaccdbnm exists and has no password.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Access Database Error

Postby mickeymouse » 26. August 2021 19:52

OK. Per your advice, I did the checking and found the user name to be "root".
Changed my $username to "root" and I'm flying!

It looks like I have more changes to make to upgrade from Version 5 to 7.
I will do best I can (with the documentation) but I suspect I'll need to get back to you.

Many thanks
mickeymouse
 
Posts: 58
Joined: 08. March 2009 06:10
Location: France & Canada
Operating System: Win 7 Family Prem Ed (64 bit?)

Re: Access Database Error

Postby mickeymouse » 29. August 2021 14:30

Haye to bother you but I'm back to the connect problem.
As far as I can see, my code is the same as documentation example.
Have studied, search and tried several things but can't solve this frustrating problem.

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:\xampp\htdocs\HA_LogInCheck.php:58 Stack trace: #0 {main} thrown in C:\xampp\htdocs\HA_LogInCheck.php on line 58

My line 58 code:
$link = mysql_connect('localhost', 'root', '');

$link = mysql_connect('localhost:3307', 'root', ''); = same problem.
mickeymouse
 
Posts: 58
Joined: 08. March 2009 06:10
Location: France & Canada
Operating System: Win 7 Family Prem Ed (64 bit?)

Re: Access Database Error

Postby Altrea » 29. August 2021 16:35

The same issue like in the beginning of the thread, so what might the solution be?
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Access Database Error

Postby mickeymouse » 29. August 2021 17:17

So sorry to have disturbed you!
I had it like the documentation but was looking at the wrong item in the documentation.
Many thanks.
mickeymouse
 
Posts: 58
Joined: 08. March 2009 06:10
Location: France & Canada
Operating System: Win 7 Family Prem Ed (64 bit?)

Re: Access Database Error

Postby mickeymouse » 29. August 2021 21:52

Can you tell me why I get the following errors/messages when my code is the same as what the documentation says?

Warning: Undefined variable $mysqli in C:\xampp\htdocs\HA_LogInCheck.php on line 63
Fatal error: Uncaught Error: Call to a member function query() on null in C:\xampp\htdocs\HA_LogInCheck.php:63 Stack trace: #0 {main} thrown in C:\xampp\htdocs\HA_LogInCheck.php on line 63

Documentation = $result = $mysqli->query("SELECT * FROM City", MYSQLI_USE_RESULT);
MyCode Line 63 = $result = $mysqli->query("SELECT * FROM hausers", MYSQLI_USE_RESULT);
mickeymouse
 
Posts: 58
Joined: 08. March 2009 06:10
Location: France & Canada
Operating System: Win 7 Family Prem Ed (64 bit?)

Re: Access Database Error

Postby Nobbie » 29. August 2021 23:18

No, we cannot tell you, as we dont know your code. Something seems to fail, most probably the connect.
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04

Re: Access Database Error

Postby mickeymouse » 31. August 2021 15:49

Can you help me understand this error message?
I suspect my problem is with the query statement but can't see what's wrong as I'm following documentation.
How can I check if if the $result of my query contains anything? I've tried different things but no success.
Also, isn't the "undefined function" "pg_fetch_all" which to me is a defined function.

Fatal error: Uncaught Error: Call to undefined function pg_fetch_all() in C:\xampp\htdocs\HA_LogInCheck.php:66 Stack trace: #0 {main} thrown in C:\xampp\htdocs\HA_LogInCheck.php on line 66

My code is:
$link= mysqli_connect($host, $username, $password);
if (!$link){die("Not connected : " . mysqli_errno() . MySQL_error());}
$db_selected = mysqli_select_db($link,$database);
if (!$db_selected){die ('Can\'t use ' .$database .':'. mysqli_error());}
print("$db_selected<br>"); //<---------print result = 1 so the connect and database select work.
$result = mysqli_query($link, "SELECT * FROM `hausers` WHERE `userid`='$UserID' || `perid`='$UserID'", MYSQLI_USE_RESULT);

//DOCUMENTATION = $arr = pg_fetch_all($result);
$arr = pg_fetch_all_all($result); //<----------------Line 66
mickeymouse
 
Posts: 58
Joined: 08. March 2009 06:10
Location: France & Canada
Operating System: Win 7 Family Prem Ed (64 bit?)

Next

Return to MariaDB - MySQL

Who is online

Users browsing this forum: No registered users and 37 guests