0

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.

bumped to the homepage by Community yesterday

This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

  • 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?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 stackoverflow.com/questions/10615436/… – 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
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.