MySQL query inside php variable

I am trying to insert this HTML code inside php variable in way that build some file with fopen function. The script produces the file however the generated content is not correct . The variable is this :

<link href="style.css" rel="stylesheet" type="text/css" />
<body> <font face="Arial,Verdana,sans-serif" color="#ff00ff" size="4"><a href="">Web</a> 
 <a href="">Immagini</a><a href="">Maps</a> 
 <a href="">News</a> <a href="">Video</a> 
 <a href="">Meteo</a><font face="Arial,Verdana,sans-serif" color="#ff0000" size="4">
<center><?php  while ($row= mysql_fetch_row($result1)) { echo $row[0]; ?></center> <br />
<strong>Reserve Hotel </strong></font><br />
<table> <tr> <td> <div id="rentacar"> Rent a Car</div> <br /> 
<div id="rentacamper"> Rent a Camper </div></td>
<td> <div id="booking">
<td><div id="booking"><iframe src=<?php $row[1]; } ?> id="booking-engine" name="booking-engine" width="450" height="250" frameborder="1" scrolling="Auto"></iframe></div></td></tr></table><hr>  
<script type="text/javascript" src=""></script>
<script type="text/javascript">setClient("55");</script>
<script type="text/javascript">setActions("clients-noh-it");</script>
<script type="text/javascript">setTargetForm("_blank");</script>

and the rest of function is that :

  while ($row = mysql_fetch_row($result2)) {
  printf("http://www.%s.php<br />", $row[0]);  
  $handle = fopen($row[0].'.php',"w+");  
  fwrite($handle, $content);   

This is one of the php files generated :


Not entirely sure what you are trying to accomplish. I use PDO for database access. Don’t understand why you have those mysql_result calls.

$sql1 = "SELECT id,dominio,URL FROM domains ORDER BY id DESC LIMIT   0,4"; 
$result1= mysql_query($sql1); 
$row = mysql_fetch_array($result1,MYSQL_ASSOC);
echo "{$row['id']} {$row['domino']} {$row['URL']}\

Thank you very much for reply ! the contents are writing fine in the files however i could not fix the loop to get each one page with the your defined fields , “dominio” and “URL” .

 $sql1 = "SELECT id,dominio,URL FROM domains ORDER BY id DESC LIMIT   0,4";    
  $result1= mysql_query($sql1);    
     echo " NOT FOUND!";

 while ($row =mysql_fetch_array($result1))
     echo "<center>www.$row[1]</center><br />"; 
  <iframe src="<?php echo $row[2]; } ?>" id="booking-engine" name="booking-engine" width="400" 
   height="600" frameborder="1" scrolling="Auto"></iframe>

Therefore they are showing the same content in all files, please check this links : .php


You can’t execute php code inside of an assignment, at least not very easily.

Take a look at the output buffering stuff:

You basically want to capture the output of a part of your script and then write it to a file.

<?php ob_start(); ?>
blah blah blah
<center><?php echo your result1 query stuff ?>
  $content = ob_get_clean();
  // Do your fwrite loop