tags:

views:

26

answers:

1

sorry ma question went wrong a bit the alis has value like alias ="Sri Kumaran Children's Home - CBSENothing is as pure and divine as knowledge." but as the url i have given . when i hover over the link it just shows alias=Sri Kumaran Children . how to solve this problem

 $myresult .= "<a href='Schools/{$alias}'><img src='/school/schoolpicdisplay.php?p1={$brand}&p2={$model}' width=\"50\" height=\"80\"></img></a>";
+1  A: 

If you know there will be a single quote, why don't you use double quotes in the first place?

"...<img src=\"/school/schoolpicdisplay.php?p1={$brand}&p2={$model}\"..."

However, since your $model is going to be in a parameter string, you should rawurlencode it.

$encoded_model = rawurlencode($model);
$encoded_alias = rawurlencode($alias);
$myresult .= "<a href='Schools/{$encoded_alias}'>...p1={$encoded_brand}&p2={$encoded_model}...";
KennyTM
sorry ma question went wrong a bit the alis has value like alias ="Sri Kumaran Children's Home - CBSENothing is as pure and divine as knowledge." but as the url i have given . when i hover over the link it just shows alias=Sri Kumaran Children . how to solve this problem
pradeep
@pradeep: (1) edit your question if it went wrong. (2) see update.
KennyTM
okie the rawurlencode worked . is there no other way to tackle this problem ?
pradeep
@pradeep: There are tons of other escaping functions but `urlencode` or `rawurlencode` are the most suitable in your case.
KennyTM
okie. so there is no problem with my php statement. i tot of playing with the quotes in the statement to handle the problem .
pradeep
is it mandatory to rawurldecode the encoded string . if its not done.wht problems might occour?
pradeep
KennyTM
hii..i got a similar problem related to this only .i solved tht quotes problem with the rawurlencode . but i am facing another problem. likethe alias has value like $alias = "Sony DSC-TX1/H"when i am making it an url like 1. <a href="<?php echo ucfirst($value).'/'.rawurlencode($row1['alias']); ?>"><?php echo $row1['property1']; echo " ";echo $row1['property2'] ?></a>its leading to a page not found likeThe requested URL /Cameras/SonyDSC-TX1/H was not found on this server.the / is making a prob .will the rawurlencode take care of slash?http://xyz.com/Cameras/SonyDSC-TX1%2FH
pradeep
@pradeep: Yes it will. If that's not a query component you can use `htmlentities` instead.
KennyTM
its a url component only! but its not handling it . its taking it like a path rather than a single variable!
pradeep
any solutiion to this problem where in the variable with '/' in url is giving problem!
pradeep