include - PHP - Unexpected T_VAR when including a variable -


i error when try , include variable external php file: unexpected t_var on line 1

here external php code:

<?php var dbstr = 'host::,username::,password::,database'; ?> 

here php file including it:

if($_post['admincreate'] == "ok") { include('db.php'); $info = explode("::,", dbstr); $con=mysqli_connect($info[0],$info[1],$info[2],$info[3]); mysqli_query($con,"insert admins (id, user, pass) values ('" . $_post['user'] . "', '" . $_post['pass'] . "',0)"); } 

it works if change code to

if($_post['admincreate'] == "ok") { $dbstr = 'host::,username::,password::,database'; $info = explode("::,", $dbstr); $con=mysqli_connect($info[0],$info[1],$info[2],$info[3]); mysqli_query($con,"insert admins (id, user, pass) values ('" . $_post['user'] . "', '" . $_post['pass'] . "',0)"); } 

but need included file.

if change included file to

<?php $dbstr = 'host::,username::,password::,database'; ?> 

i error: parse error: syntax error, unexpected '=' in .../db.php on line 1

and find external php file has changed to

<?php  = 'host::,username::,password::,database'; ?> 

how include string without giving me error?

p.s. external php generated main php file use fopen , fwrite, actual values of host, username, password, , database have been censored because feel better way.

thanks in advance, -p0iz0n

var not valid php

<?php var dbstr = 'host::,username::,password::,database'; ?> 

should

<?php $dbstr = 'host::,username::,password::,database'; ?> 

interestingly enough have right in second example.


Comments