0

I am getting the following error in browser:

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:\xampp\htdocs\Myshop\inc\phpfunctions.php:3 Stack trace: #0 C:\xampp\htdocs\Myshop\inc\head.php(15): require_once() #1 C:\xampp\htdocs\Myshop\index.php(6): require_once('C:\xampp\htdocs...') #2 {main} thrown in C:\xampp\htdocs\Myshop\inc\phpfunctions.php on line 3

I have put in phpfunctions

<?php
mysql_connect("localhost/8080","root","");
mysql_select_db("leagueofdraven");

?>

In head file

<?php require_once  'inc/phpfunctions.php'; ?>

$_SERVER["DOCUMENT_ROOT"] is not working for me as I have already posted a query here: Error in Localhost

Community
  • 1
  • 1
Ayaz
  • 53
  • 1
  • 1
  • 7
  • 2
    If you visit php.net and check out the documentation for `mysql_connect` you will find that the function has been deprecated and not safe to use, it has been removed from the newer versions of PHP. Switch to PDO or mysqli – Vishnu Nair Apr 09 '16 at 07:57
  • localhost/8080 is that correct? – Sameer Kumar Jain Apr 09 '16 at 07:59
  • That's because `mysql_` functions have died back in 2013 and [the documentation](http://php.net/mysql_connect) has been showing these screaming red boxes saying "don't use this!", but apparently you missed that. Check out [Why shouldn't I use mysql_* functions in PHP?](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) – Oldskool Apr 09 '16 at 08:06
  • this video is uploaded in Jan-15. How this can use it then?https://www.youtube.com/watch?v=os0O7ekuqrI&list=PLQsP7Ksoaqq1JZQqd3K2O5a5ic9R5TUQq&index=1 – Ayaz Apr 09 '16 at 09:25
  • justlocalhost doesnt work so i have to put localhost/8080 – Ayaz Apr 09 '16 at 09:31
  • Why? Is 8080 a directory? In case it's port use localhost:8080 – Sameer Kumar Jain Apr 09 '16 at 09:34
  • Hey its working i have replaced it with mysqli_connect("localhost","root","","leagueofdraven"); – Ayaz Apr 09 '16 at 10:02

0 Answers0