Jump to content

Newbie help with variable syntax.


Rockas

Recommended Posts

Hi everybody, good morning.

I am trying to set a variable for a piece of code to export XLS files and i have th following variable:

$export->xls ( "localhost" , "database" , "user" , "password" , "SELECT * FROM tabela WHERE filtro = %s ORDER BY Ref ASC" , "ficheiro_excel" );

 

When i run the code i get the following error message in the browser:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%s ORDER BY Ref ASC' at line 1

 

Can anyone help me to fix this?

Thank you and please forgive my english  :-[

Link to comment
https://forums.phpfreaks.com/topic/162741-newbie-help-with-variable-syntax/
Share on other sites

$export is a variable

Not quite true. It's an object, an instantiation of some class or other. Without knowing the actual class, we can only speculate about what it does.

 

xls method exports the results of a query to a Microsoft Excel file format "*.xls"

That we could guess, without knowing any details of how it does it. Your error is coming from somewhere in this black box.... without knowing anything about how the box actually works, we can't do much.

 

% is a filter of the query so i can open the page as example

 

http://export.php?filtro=sample

So where are you defining this filter? What value are you setting it to?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.