0

So i installed LAMP, in ubuntu 12.04 LT, and apache, php, phpmyadmin and mysql works fine independently, but for example i have a php file:

$conexion = mysql_connect("127.0.1.1", "root", "password") or die("<p class='error'>Lo             sentimos no se puede conectar a la base de datos.</p>");

$database = 'elBlog';
mysql_select_db($database, $conexion) or die("<p class='error>Lo sentimos, no se puede conectar...</p>");

Also i tried PDO:

try{
    $conn = new PDO('mysql:host=localhost; dbname=elBlog', "root", "password");
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}catch(PDOException $e){
    echo 'ERROR: ' . $e->getMessage();
}

Php just evades this code, i mean is not even display an error message not for php not for mysql. Looking around in the web i installed all the libraries that php and mysql needs. what is wrong with this??

apache works fine, e.g. the phpinfo file for test is working. phpmyadmin also works fine i already create a DB. what else im missing?? Thanx for your help...

Marc Delisle
  • 8,879
  • 3
  • 29
  • 29
Luisinho Rojas
  • 199
  • 4
  • 18
  • 2
    If there's no error message, than what is the problem? – Jessica Dec 12 '13 at 23:38
  • 1
    See [PHP Does Not Display Error Messages](http://stackoverflow.com/q/5680831) – Pekka Dec 12 '13 at 23:38
  • 6
    Also, Don't use `mysql` extension, use `PDO` or `mysqli` – hammus Dec 12 '13 at 23:39
  • 1
    127.0.1.1 -> 127.0.0.1 ??? – robbmj Dec 12 '13 at 23:41
  • 1
    @robbmj [According to this RFC](http://tools.ietf.org/html/rfc3330) all of 12.0.0.0/8 is reserved for loopback on linux systems, so you could basically ping everything from 127.0.0.1 to 127.255.255.254 and it would behave the same, so this shouldn't be a problem. – thormeier Dec 12 '13 at 23:58
  • Indeed, I looked this up after I made my comment and learned a few new things. http://lists.debian.org/debian-devel/2013/07/msg00809.html – robbmj Dec 13 '13 at 00:02
  • The PDO MySQL DSN does not have spaces. Change it to `host=localhost;dbname=elBlog`. That being said, you should have seen the error in your `catch` block. – Phil Dec 13 '13 at 00:31
  • @Phil PDO needs explicit encouragement before making errors public: [How to squeeze error message out of PDO?](http://stackoverflow.com/q/3726505) – Pekka Dec 13 '13 at 02:16
  • @Pekka웃 Really? The PDO constructor should throw an exception on failure. That's been my experience and it's also what the manual says. – Phil Dec 13 '13 at 02:35
  • thnx for the replies... the thing is that... is like php and mysql don't know each other... i changed the 127.0.0.1 and still not working, i already use PDO like i said in the post an also mysqli and still not working... maybe is a config of php.ini or my.conf i dont know... – Luisinho Rojas Dec 13 '13 at 06:55

0 Answers0