0
<?php
$host="localhost";
$db="project";
$user="root";
$pass="";
$conn=mysql_connect($host,$user,$pass) or die("Mysql is not Connected");

mysql_select_db($db,$conn) or die("DB is not Connected");
mysql_set_charset('utf8',$conn);
?>

Error: Call to undefined function mysql_connect() in E:\Programs\wamp64\www\ayar.php on line 6

it is a error about connecting to data base this project worked in 2014 but it is not working now.

7
  • Which php version you are using? mysql_* lib has been removed from PHP v7. please switch to PDO or mysqli. Commented Mar 17, 2019 at 12:28
  • please migrate to mysqli_ or any more modern connectors. mysql_ has many security flaws and it is not maintained anymore Commented Mar 17, 2019 at 12:29
  • wampserver3.1.4_x64 i installed it. Commented Mar 17, 2019 at 12:30
  • Should i change my all query to mysqli or PDO ? there are a lot of codes :/ Commented Mar 17, 2019 at 12:31
  • Yes you should, I know it's pain in the a** but at some point in the future, you have to do it anyway. Commented Mar 17, 2019 at 12:33

2 Answers 2

2

First check your PHP version first if it's greater 5.5 then the above code won't work. Since PHP 5.5 has removed support for MySQL extension in favour of mysqli. So you need to do some changes into your code i.e shown below:

<?php
$host="localhost";
$db="project";
$user="root";
$pass="";
$conn=mysqli_connect($host,$user,$pass) or die("Mysql is not Connected");

mysqli_select_db($conn,$db) or die("DB is not Connected");

?>
Sign up to request clarification or add additional context in comments.

Comments

0

or you can install earlier version of wampserver on which you can run php v=<5.5

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.