The situation is this, I go on eBay do a search, look at the source code, copy the area that I want to parse, paste it in my script, run the script and get what I want from it.

So basically in my script I have a variable like this

$source = "here I paste the source code that I copied from eBay (after escaping all the double quote)";

I used preg_match_all on the string I just pasted and everything works fine.

Now the problem:

I want to use a form with a textarea where I would paste the source code copied from eBay and than submit to my script (instead of hardcoding in the script than upload the script than run the script).

But

$source = $_POST; does not work, I tried

$source = htmlentities($_POST); and still not working

but if I echo $source the data is all there but it is not getting parse by the script.

So my questions are why is it not working and how to fix it?

Thanks

Hi,

You could try adding slashes to the string addslashes(); You might be using magic quotes to. Use get_magic_quotes_gpc() and if it is false, using the addslashes() function. Example:

if(!get_magic_quotes_gpc())
{
  $source = addslashes($_POST['source']);
}
else
{
  $source = $_POST['source'];
}

For more on the get_magic_quotes_gpc() function, check out http://www.php.net/manual/en/function.get-magic-quotes-gpc.php

I hope this solves your problem,
Kieran :)

Hi Kieran thanks for the reply, I tried both ways with the double quote escaped or not escaped, proven by echoing the post data after manipulation and either way the text is not being parsed by the script.

It is very frustrating because if I copy and paste the text that I just echoed from the post data into the script (hardcoded) and run the script again it would parsed no problem.

Almost like the script would run prior of the data being posted.

I have no idea then, I thought that magic quotes was the answer :(

Sorry

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.