+ 1

why am i getting this error

Uncaught Error: Call to undefined function mysql_connect() in /home1/upscalf7/public_html/user_log/connection.php:7 Stack trace: #0 /home1/upscalf7/public_html/user_log/log_exec.php(6): require_once() #1 {main} thrown in /home1/upscalf7/public_html/user_log/connection.php on line 7 also this Access denied for user 'root'@'localhost' <?php $host = "localhost"; $dbuser = "root"; $dbpass = ""; $db = "upscalf7_aec"; $prefix = ""; $conn =mysql_connect("$host","$dbuser","$dbpass","$db") or die("Could not connect database"); $link =new mysql_select_db($conn, $db) or die("Could not select database"); ?>

26th Aug 2018, 12:21 AM
Keeva McGhee
Keeva McGhee - avatar
11 Respostas
+ 2
It's fine. What happens when you try to authenticate to mysql from a command prompt: Assuming Windows and that mysql is in the path (Linux / others just start a terminal): start | run | cmd.exe mysql -u root -p (press enter) If your password is truly blank, press enter at the password prompt. If it is not blank and it's not accepting your password, you can still reset the password (but you need host privileges). For this I'll need to send you to the database parts of StackExchange. If command prompt / terminal isn't working for you, you can download MySQL Workbench from the mysql official site (just skip the registration requirement), which gives you a nice GUI.
26th Aug 2018, 12:44 AM
Kirk Schafer
Kirk Schafer - avatar
+ 1
Does phpinfo() show that the mysql module is loaded? (it's perplexing that you're getting both 'undefined' and 'access denied')
26th Aug 2018, 12:25 AM
Kirk Schafer
Kirk Schafer - avatar
+ 1
Run this code and search the output for mysql and what module seems to be associated: <?php phpinfo(); ?> Also, what PHP version?
26th Aug 2018, 12:32 AM
Kirk Schafer
Kirk Schafer - avatar
+ 1
mysql_connect has been removed in PHP 7. Two alternatives at this link: https://stackoverflow.com/questions/34088373/call-to-undefined-function-mysql-connect-after-upgrade-to-php-7 Essentially: mysqli_connect() ... or ... PDO::__construct()
26th Aug 2018, 12:36 AM
Kirk Schafer
Kirk Schafer - avatar
+ 1
i changed it to mysqli do you know why it wont take root as the username anymore forgive me i am so new at this
26th Aug 2018, 12:39 AM
Keeva McGhee
Keeva McGhee - avatar
+ 1
cool great again thanks
26th Aug 2018, 1:26 AM
Keeva McGhee
Keeva McGhee - avatar
0
how do i find out that info about phpinfo()
26th Aug 2018, 12:29 AM
Keeva McGhee
Keeva McGhee - avatar
0
i got the first one due to the fact that i did not have mysqli only mysql and then i got the second error
26th Aug 2018, 12:31 AM
Keeva McGhee
Keeva McGhee - avatar
0
php version 7.0.31 mysql version 5.6.32-78.1
26th Aug 2018, 12:34 AM
Keeva McGhee
Keeva McGhee - avatar
0
it use to take “root” did something change
26th Aug 2018, 12:35 AM
Keeva McGhee
Keeva McGhee - avatar
0
changing it to the pdo thanks
26th Aug 2018, 12:42 AM
Keeva McGhee
Keeva McGhee - avatar