1

I have ubuntu server 14.04 installed along side Apache, PHP5 and MySQL server all together. I can gain access to the server using putty and the mysql database using Heidi Sql remotely.

On my laptop, using xampp to write and read from the database on the server works perfectly fine using PHP, but when the same code on the server is ran nothing happens the code stops at $connect = mysql_connect($host,$user,$pass) or die('Connection error');

After the code is run off the server the page remains blank and does not even show the Connection Error message in the die section.

Note: Apache, PHP and MySQL works fines because all my web pages are in PHP.

Parto
  • 15,325
  • 24
  • 86
  • 117
user294159
  • 29
  • 1
  • 3
  • Did you change your $host variable to localhost when you run it from the server? To show error messages, add this line before the $connect part: ini_set('display_errors',1);. Run the code again and include any error messages here. – Parto Jun 16 '14 at 21:02
  • I get the following error after placing that code. Fatal error: Call to undefined function mysql_connect() in /var/www/html/Typit/Login.php on line 24 – user294159 Jun 16 '14 at 21:25
  • Did you restart apache in the server after installing it?http://askubuntu.com/questions/6358/how-do-you-restart-apache – Parto Jun 16 '14 at 21:29
  • Solved the issue it turned out i never had php5-mysql module http://stackoverflow.com/questions/10615436/fatal-error-call-to-undefined-function-mysql-connect – user294159 Jun 16 '14 at 21:31
  • Cool. Lemme answer the question and you can mark it as solved. – Parto Jun 16 '14 at 21:32

1 Answers1

1

To display errors in your PHP environment, enter this line at the top of your config file - preferably before any code is run.

ini_set('display_errors',1);

To hide the errors, like when you go live, change the 1 to 0.


In case of this error Fatal error: Call to undefined function mysql_connect() in /var/www/html/Typit/Login.php just install the php5-mysql module using this command:

sudo apt-get install php5-mysql

Note:

The mysql_connect() extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used.

Source: http://www.php.net//manual/en/function.mysql-connect.php

Parto
  • 15,325
  • 24
  • 86
  • 117