Call Variable for php file name

Asked

Viewed 93 times

-2

I have a problem calling the variable name to the Excel file name. I have to put Variavel’s name on the file. The variable name comes from Select * ...

 //--- Fazendo o preenchimento inicial --------------------------
 $row=mysql_fetch_array($sql);
 //- Definimos o nome do arquivo que será exportado -------------
 $arquivo = 'Empresa Não Autorizada '.$row[1]'.xls';

Give me this error: Parse error: syntax error, Unexpected ''. xls''

  • Hello. Where does the name variable come from? Where is it defined?

  • 3

    The syntax of your code, besides being wrong, shows no relation to your doubt.

  • I want it to be used when it is called by the query below

  • @user3253195 I advise you to edit the question, correct the syntax and explain your question better. The way I read it looks like you’re trying to create the variable $arquivoand cannot.

  • I have a problem placing the file name with the variable $NAME

  • @user3253195 as it has structured code, $Nome can never come from SELECT *. You will need to make a declaration of $arquivo after $row=mysql_fetch_array($sql);. And will remain $arquivo = ' Não Autorizada '.$row.'.xls';. (If I understand you right).

  • @user3253195 missing one point after the $row[1]: $file = 'Unauthorized ' . $Row[1] . '. xls';

  • only one question. Can I have Select with *? or have to set one by one all fields?

  • @user3253195 if you are sure that the BD schema will not change and that the field you want is always at position 1 there is no problem. However consider that you are selecting all columns (can be two or can be 20) when in fact you will only use one.

  • But having several tables does not generate problem?

  • Notice: Undefined offset: 1 in give me this error

  • @user3253195 When you do the Select * from Tabela is only selecting the one table, not several. The * means it will select all columns in the table. For Undefined offset the query can only have one field (PHP arrays start their indices at zero, so if there is only one column in $row would have to be $row[0].

  • 5

    This question seems to be off-topic because it is about a typographical error whose solution benefits no future visitor.

  • And it’s not the same thing you’ve asked in http://answall.com/questions/17371/exportar-dados-excel-php-workbench-variable?

Show 9 more comments

1 answer

3

He’s missing a point before xls:

$arquivo = 'Empresa Não Autorizada ' . $row[1] . '.xls';

Browser other questions tagged

You are not signed in. Login or sign up in order to post.