I understand that the title is a bit confusing but I couldn't find a better way to title this question!
I will try my best to explain it here:
I am creating a page with an extension of .php using another php file. works fine. This php file has only some HTML codes in it. so it is a .PHP file with .HTML codes. this works fine too.
Now, I am trying to put some PHP code at the top of this created PHP file so I can connect to mysql database.
But when I place the PHP code for connecting to the database at the top of the page, and when the page is created, it will only create a blank page! and when I view page source in the browser, there is not a single HTML code in the page!
I hope I haven't confused you guys so far...
this code creates a blank page:
$i=1;
while($file = fopen("untitled$i.php", "r")) { fclose($file); $i++; }
if($file = fopen("untitled$i.php", "w")) {
$html ='<?php
include "config/connect.php";
$dynamicList = "";
$sql = "SELECT DISTINCT filename FROM pages";
$query = mysqli_query($db_conx, $sql);
$productCount = mysqli_num_rows($query); // count the output amount
if ($productCount > 0) {
while($row = mysqli_fetch_array($query, MYSQLI_ASSOC)){
$category = $row["category"];
$dynamicList .= "<li><a href="#">' . $filename . '</a></li>";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
<head profile="http://gmpg.org/xfn/11">
**rest of the HTML code goes here.....................**
this code creates the page as it should and it works fine:
$i=1;
while($file = fopen("untitled$i.php", "r")) { fclose($file); $i++; }
if($file = fopen("untitled$i.php", "w")) {
$html ='
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
<head profile="http://gmpg.org/xfn/11">
**rest of the HTML code goes here.....................**
what am I doing wrong?