Click to See Complete Forum and Search --> : rawurldecode to sql query


KingB
11-07-2003, 03:57 PM
I'm a bit of a noob so any code help is greatly appreciated!! I'm trying to have my url array values (sent by a form via GET) get to my sql query. The problem is that the "&" and the "=" are encoded to "%26" and "%3D". I think I need some sort of rawurldecode function prior to my sql. However, whatever I've tried doesn't seem to work and I can't find an exact answer along the forum.

Here's my recordset:

@$phonejoin = " '".join("' OR dnc.phone = '", $HTTP_GET_VARS['ph'])."' ";

$colph_DNC = "1";
if (isset($_GET['ph'])) {
$colph_DNC = (get_magic_quotes_gpc()) ? $_GET['ph'] : addslashes($_GET['ph']);
}
mysql_select_db($database_DNC_01, $DNC_01);
$query_DNC = sprintf("SELECT * FROM dnc WHERE phone = $phonejoin", $colph_DNC);
$DNC = mysql_query($query_DNC, $DNC_01) or die(mysql_error());
$row_DNC = mysql_fetch_assoc($DNC);
$totalRows_DNC = mysql_num_rows($DNC);
?>


Any ideas? Thanks in advance!

pyro
11-07-2003, 04:03 PM
Where's the code where you tried using rawurldecode?

KingB
11-07-2003, 04:05 PM
I left it out because I really did not know what the hell I was doing... And I'm not even sure if rawurldecode is exactly what is needed. :confused:

pyro
11-07-2003, 04:11 PM
Which variable is having the problem?

KingB
11-07-2003, 04:16 PM
there's only one: ph[]
It's an array. Here's a live example.

http://64.65.203.147/intranet/dnc/dnc_master.php?ph%5B%5D=1234567%26ph%5B%5D%3D7654321

It's passed correctly for the first instance (ph%5B%5D=), but susequent are sent as "%26ph%5B%5D%3D" - the sql wants to see "&ph%5B%5D=" or "&ph[]="

pyro
11-07-2003, 04:32 PM
I think your problem must be comming in before any of this happens. I would just try to get it to pass the parameters correctly.

KingB
11-07-2003, 04:50 PM
Hmmm.... You're probably right. There is a textarea that I'm using a bit of javascript to remove the %0D%0A.

Should/could I simply substitute the "%0D%0A" in the url with "&ph[]=" at the recordset?

pyro
11-07-2003, 04:54 PM
I personally would figure out why it is being passed incorrectly, but what you do is up to you.

KingB
11-07-2003, 06:18 PM
Ok! I'll stab in that direction... I guess it beats trying to "fix it in the mix" :cool: Thanks!!!