Jump to content

Getting parameters from a query


bobo01

Recommended Posts

Hello,

 

I have made some dynamic code that performs a query on the SQL database, I only know that query at run time.

 

However, after reading some more about PHP, I noticed that I need to include the function mysql_real_escape_string before doing this line:

 

@mysql_query( $aStatement);

 

So, how can I read that $aStatement and then call the mysql_real_escape_string function for each needed parameter?

 

Thanks.

 

 

Link to comment
Share on other sites

You have to escape string when you assign the query to $aStatement.  Normally in php apps, the data part for the query will be taken from $_GET or $_POST.  It is always advised to escape string before executing it in DB. 

 

Alternatively you can make use of php's array map function at the start of your code to escape string.

 

$_GET = array_map('mysql_real_escape_string', $_GET);

$_POST = array_map('mysql_real_escape_string', $_POST);

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.