tags:

views:

40

answers:

3
A: 

urlencode or rawurlencode, depending on if you want spaces as + or %20.

deceze
I need it to insert a '<' and '>' At th beginning and end
BigMike
`urlencode()` encodes space to + for historic reasons
mvds
@BigMike You should add that to the question. And you can simply do `'<' . rawurlencode($string) . '>'`. Or am I misunderstanding you?
deceze
@mvds Yes, already added that to my answer a while ago...
deceze
+1  A: 

rawurlencode()

because the space must be %20 according to the question.

edit: the question wasn't very clear, but to add < and > before encoding, just do

rawurlencode("<$txt>");

edit: the question has evolved into a mysql question, here's a short answer

$res = mysql_query("SELECT `this` FROM `that`");
$row = mysql_fetch_row($res);
$this = $row[0];

or

$res = mysql_query("SELECT `this` FROM `that`");
$row = mysql_fetch_assoc($res);
$this = $row['this'];
mvds
What's the downvote for?
deceze
didn't seem to work. Here is my code:$pid = mysql_query("SELECT cPushID FROM tblUsers WHERE intUserID='20' AND Length(cPushID) > 70 AND cAlerts = 'All'");$url = rawurlencode("<$pid>");$msg = "test";file_get_contents("http://domain/push.php?msg=$msgThe string in the database is something like <BC34DH DHSO39 HIRD38> as an example. That exact string needs to be send to the push.php script on the remote server for it to run correctly.
BigMike
dude. $pid is a mysql response identifier. If you want the data, do `$row = mysql_fetch_row($pid); $data = $row[0];` and use `$data`.
mvds
A: 

Use urlencode then urldecode it before inserting it to the database.

YouBook