开发者

Url rewrite using PHP code

开发者 https://www.devze.com 2023-03-09 04:03 出处:网络
I am working on a client\'s application www.islamicaim.com. I have problem in url writing in video section. I was using url something like http://islamicaim.com/video_play.php?id=6 for playing videos.

I am working on a client's application www.islamicaim.com. I have problem in url writing in video section. I was using url something like http://islamicaim.com/video_play.php?id=6 for playing videos. Videos work fine but now according to the new requirement of the client I want to write the url something like http://www.islamicaim.com/category/author/video/title.php for making the SEO friendly url.

I have stored the name of an author in database and name can contain space some thing like mr xyz. While using this name I am facing problem. If any one can suggest me how I can achieve this goal as i am a learner of Php. Thanks.....

Here is my query

$q2="select id from media_author where name='".$author_name."'";
while $author_name has value "mr xyz"
and I am recieving this error
You have an error in your SQL syntax; ch开发者_JAVA技巧eck the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
i have checked this query by running in sql it works fine..

Link where I am having problem is at http://islamicaim.com/media_details.php?category=Talawat-e-Quran&author=Qari%20Syed%20Sadaqat%20Ali


I'm not sure what specific error you are having as you basically just said it presently isn't working for you. But as you said the issue is the url can contain "mr xyz", it's probably that you need to replace the space with a %20.

I don't know PHP but I'm guessing that it, like every other language, has a call to encode a url - call that on your url and that will transform all characters that need to be in the %xx form.


Can't see any problem with your query, unless there is a problem with something else. Have you tried all the possibilities for this? Such as:

$q2 = "SELECT id FROM media_author WHERE name = $author_name";

Or

$q2 = "SELECT * FROM media_author WHERE name = '$author_name'";

Maybe you should add some more related code for us to check.

0

精彩评论

暂无评论...
验证码 换一张
取 消