2

i recently installed lamp on ubuntu and now i got problems with them (i think that can not connected to database)

I did the following tests :

  1. i tested mysql with call phpMyAdmin and that's done :

phpMyAdmin screanShot

  1. i tested php with phpInfo and that's done too :

phpInfo screanshot

  1. i tested simple code for to test the database connection

my simple code this is :

<?php
//phpinfo();

$servername = "localhost";
$username = "root";
$password = "3cret";

// Create connection
$conn = new mysql($servername, $username, $password);

// Check connection
if ($conn->connect_error) {
   die("Connection failed: " . $conn->connect_error);
} 
echo "Connected successfully";

?>

And the result was:

The localhost page isn’t working

localhost is currently unable to handle this request. 500

Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43
saman
  • 305
  • 2
  • 4
  • 17

3 Answers3

1

There's either an error within your mod_php or your general PHP setup, I owuld also advise using mysqli over mysql as it is much better, use this code:

<?php
$conn = mysqli_connect("localhost","root","3cret","database_name");

// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
?>
iJamesPHP
  • 173
  • 1
  • 12
1

This problem was due to disabled virtual Directory Support and that's solved with this command :

sudo chmod -R 755 /var/www
saman
  • 305
  • 2
  • 4
  • 17
0

Solution: In config/settings.inc.php

Replace this line:

define('_PS_CACHE_ENABLED_', '1');

with this:

define('_PS_CACHE_ENABLED_', '0');

Enjoy!

Prasad Khode
  • 6,602
  • 11
  • 44
  • 59