1

i updated Ubunto14 to Ubunto 16.04 on my testserver to get compatible with my ISP's server.

My configuration as shown in phpMyAdmin, which runs fine!:

  • Server: Localhost via UNIX socket
  • Server type: MySQL
  • Server version: 5.7.17-0ubuntu0.16.04.1 - (Ubuntu)
  • Protocol version: 10
  • User: root@localhost
  • Server charset: UTF-8 Unicode (utf8)
  • Apache/2.4.18 (Ubuntu)
  • Database client version: libmysql - mysqlnd 5.0.12-dev - 20150407
  • PHP extension: mysqli Documentation
  • PHP version: 7.0.13-0ubuntu0.16.04.1

My test-script below create an empty screen in web-browser:

<?php
$link = mysqli_connect("localhost", "root", "cydb4tsa", "RedGround");

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}else{ echo "connected"; }
mysqli_close($link);
?>

i found no relevant error-message in /var/log/mysql/error.log

mysql runs on the command line including all queries from imported tables:

sebu@sebu-Inspiron-3437:~$ mysql -u root -p<pw> RedGround

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

apache2 runs, browser show default page and

ls /etc/apache2/mods-enabled/ | grep php
php7.0.conf
php7.0.load

php7 runs, browser show all infos

phpMyAdmin runs normally although an error is displayed: Connection for controluser as defined in your configuration failed.

still get empty screen, when i run above php-script. Maybe a communication-error between mysql and php?

sebu@sebu-Inspiron-3437:~$ php -m

[PHP Modules]
calendar Core ctype date dom exif fileinfo filter ftp gd gettext hash
iconv json libxml mbstring mcrypt mysqli mysqlnd openssl pcntl pcre PDO
pdo_mysql Phar posix readline Reflection session shmop SimpleXML sockets SPL 
standard sysvmsg sysvsem sysvshm tokenizer wddx xml xmlreader xmlwriter xsl
Zend OPcache zlib

[Zend Modules]
Zend OPcache

screen of my project after update on my lap, localhost: enter image description here screen of my project online onISP-server: enter image description here

  • 1
    Maybe some PHP module is missing or is not enabled. What is the output of php -m? – pa4080 Jan 24 '17 at 10:49
  • 2
    Add these lines just after your <?php tag to display errors then try again: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); – Parto Jan 24 '17 at 11:06
  • 1
    @Paul I'm looking the screenshot of your project, after update, and I think that I found the problem. By default PHP 7 doesn't support short open tags <? you need to rewrite your code and change them with <?php. Or you can try to enable short tags option in php.ini. Also I've made an experiment. I've run your "test-scrip" on my server and it works. After that I have changed <?php with <? and I've got blank window. – pa4080 Jan 24 '17 at 13:46
  • 1
    I tried to set short_open_tag=on in /etc/php/7.0/apache2/php.ini but for some reason it doesn't works. After that I put php_flag short_open_tag on in /etc/apache2/sites-available/my-site.conf - now the page works. – pa4080 Jan 24 '17 at 16:40
  • 1
    thank you for this hint, i will carefully check and give feedback this morning. – Paul Jan 24 '17 at 23:57
0

SOLVED Browser can disply output with following style:

<?  // should be <?php, but it works anyway because 
    $server     = $_SESSION['database_host'];
    $datenbank  = $_SESSION['database_name'];
    $username   = $_SESSION['database_user'];
    $passwort   = $_SESSION['database_user_pw'];
    $mySQL  =  new mysqli($server,$username,$passwort,$datenbank);
    if ($mySQL->connect_errno) 
    {
        echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
    }
    else
    {
    $sql = "SELECT count(fldID) count from tblPerson";
    // echo"$sql<br>";
    if (!$result = $mySQL->query($sql)) 
    {
        echo "query \"$sql\" failed because $mySQL->error";
        exit;
    }

    if (! $result->num_rows) exit;

    $actor = $result->fetch_assoc();
    $nbr =  $actor['count'];
    echo "nuber is: ".$nbr." persons";

    }
?> 

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.