Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP connection issue in mac

Tags:

php

macos

mamp

i'm using MAMP on mac os This is the error while making database connection

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /Applications/MAMP/htdocs/databases.php:3 Stack trace: #0 {main} thrown in /Applications/MAMP/htdocs/databases.php on line 3

Code used

<?php 

$connection = mysql_connect("localhost","root","");

if(!$connection)
{

    die("Database connection failed" . mysql_error());
}
?>
like image 627
Om Komawar Avatar asked Jul 05 '26 18:07

Om Komawar


1 Answers

just change from

$connection = mysql_connect("localhost","root","");

to

$connection = mysqli_connect("localhost","root","");

notice the 'i' in mysqli

like image 69
Omar N Shamali Avatar answered Jul 08 '26 08:07

Omar N Shamali



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!