Why Browser Show an Empty Screen When I Start Php Test-Script in Ubuntu 16.04?
I Updated Ubuntu 14 to Ubuntu 16.04 on My Testserver to Get Compatible with My Isp's Server. My Configuration as Shown in phpMyAdmin, Which Runs Fine!...
i updated Ubuntu 14 to Ubuntu 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: screen of my project online onISP-server:
1 Answer
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";
}
?>