0

So my problem is that the code (I added it below) works on MAC OS X XAMPP, but doesn't work on Windows XAMPP. Actualy, most of the code works. But It does not echo variables that is taken from database: $rows['pavadinimas'], $rows['metai'] and etc. It seems like it does but they're not visible. Cause something is entered to the table: Example of the table

And in database all the data is written. database example

So something is in there but is invisible. IT IS VISIBLE ON MAC OS X XAMPP, BUT NOT ON WINDOWS. AND ONLY VARIABLES THAT ARE TAKEN FROM DATABASE.

The code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Žurnalai</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="http://fonts.googleapis.com/css?family=Karla:400,700" rel="stylesheet" />
<link href="default.css" rel="stylesheet" type="text/css" media="all" />
<link href="fonts.css" rel="stylesheet" type="text/css" media="all" />
<!--[if IE 6]>
<link href="default_ie6.css" rel="stylesheet" type="text/css" />
<![endif]-->
</head>
<body>
<div id="wrapper">
    <div id="header-wrapper">
        <div id="header" class="container">
            <div id="logo">
                <h1><a href="#">Some text</a></h1>
                <p>Some text</p>
            </div>
            <div id="banner"> <a href="#" class="image"><img src="images/pic01.jpg" alt="" /></a> </div>
        </div>
    </div>
    <div id="page" class="container">
        <div id="content">
            <div class="title">
                <h2>Žurnalai</h2>
                <span class="byline">Some text</span> </div>

    <?php
$host="localhost";
$username="root";
$password="";
$db_name="zurnalas";
$tbl_name="zurnalas";

// Connect to server and select databse.
$mysqli = new mysqli("$host", "$username", "$password", "zurnalas");

$sql="SELECT * FROM $tbl_name";
$result=$mysqli->query($sql);
?>
<form name="form1" method="post" action="">
<table width="500" border="0" cellspacing="1" cellpadding="0">
<tr>
<td><form name="form1" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
<table width="600" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#FFFFFF">&nbsp;</td>
<td colspan="4" bgcolor="#FFFFFF"><strong>Žurnalų sÄ…raÅas</strong> </td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF"><strong>Pavadinimas</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Per metus iÅleidžiama</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Leidykla</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Leidimo Metai</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Kaina</strong></td>
</tr>

<?php
while($rows=$result->fetch_assoc()){
?>

<tr>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['pavadinimas']; ?></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['kiekis'] . " vnt."; ?></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['leidykla']; ?></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['metai'] . " metai"; ?></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['kaina'] . " eurų"; ?></td>
</tr>

<?php
}
?>
    </table>
    </form>
    </table>
    </div>
    </div>
    </div>
    </div>
    </body>
    </html>
PhpNewbie
  • 89
  • 1
  • 9
  • ***Please [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php).*** [These extensions](http://php.net/manual/en/migration70.removed-exts-sapis.php) have been removed in PHP 7. Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) statements for [PDO](http://php.net/manual/en/pdo.prepared-statements.php) and [MySQLi](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php) and consider using PDO, [it's really pretty easy](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard Dec 05 '16 at 18:42
  • Are there any errors in you error logs? – Jay Blanchard Dec 05 '16 at 18:43
  • Just some advice, start using a virtualized environment, like vagrant with homestead, so that way the environment is synchronous across platforms. You should also try and keep your HTML and PHP separate. Often through the use of Models, Controllers, and Views in a very simplistic architecture. – Robert430404 Dec 05 '16 at 18:44
  • Can you clarify a little bit. You're seeing the variables in windows when you inspect but the browser will not render? And are you using IE (which version)? – bos570 Dec 05 '16 at 18:44
  • Your HTML is invalid, and uses presentational attributes that were obsoleted by CSS twenty years ago. You should learn modern HTML and use a [validator](https://validator.w3.org/nu/). – Quentin Dec 05 '16 at 18:45
  • Even in inspect element there is nothing but this ` echo $rows['pavadinimas']; ?>` – PhpNewbie Dec 05 '16 at 18:57

0 Answers0