I want to create dynamically a new php file. Inside the new file i want my sql query. Here's my code
$myfile = "".$file.".php"; // or .php
//echo $myFile;
$fh = fopen($myfile, 'w'); // or die("error");
$stringData = '<?php
$sql = "SELECT * FROM users, epixeir WHERE users.user = ".$_SESSION["user"]." AND user.pass = ".$_SESSION["pass"]." ;";
$result = $conn->query($sql);
?>
';
fwrite($fh, $stringData);
In new file $myfile there is a "Notice: Trying to get property of non-object".
If i edit it to '".$_SESSION["user"]"' working fine, but this i want to do it dinamically. So if i write my above code like
$myfile = "".$file.".php"; // or .php
//echo $myFile;
$fh = fopen($myfile, 'w'); // or die("error");
$stringData = '<?php
$sql = "SELECT * FROM users, epixeir WHERE users.user = '".$_SESSION["user"]."' AND user.pass = '".$_SESSION["pass"]."' ;";
//$sql = "SELECT * FROM users, epixeir WHERE users.user = '".$_SESSION['user']."' AND user.pass = '".$_SESSION['pass']."' ;";
$result = $conn->query($sql);
?>
';
fwrite($fh, $stringData);
Then i receive "Parse error: syntax error, unexpected '"' "
I'm confused and I need your help.