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
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?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.