I want to insert a PHP code into a variable.
I want to replace "Some text" with a PHP code.
I found some examples on the internet, but when I try to run my script it isn't working.
This is my current script:
$purchaseID = "Some text";
I want to change "Some text" with the following code:
<?php
echo date('y/m/d');
echo "O";
$link = mysql_connect("localhost", "root", "");
mysql_select_db("db", $link);
$result = mysql_query("SELECT * FROM table", $link);
$num_rows = mysql_num_rows($result);echo "$num_rows"+1;
?>
I have tried:
$purchaseID = <<<END
echo date('y/m/d');
echo "O";
$link = mysql_connect("localhost", "root", "");
mysql_select_db("db", $link);
$result = mysql_query("SELECT * FROM table", $link);
$num_rows = mysql_num_rows($result);
echo "$num_rows"+1;
END;
When I run this I get a error.
How can I fix this and replace "Some text" with the PHP code?
$purchaseID: "2016/06/24O5"(if $num_rows = 4) is that right?