Jump to content

url rewriting in php


nadeem14375

Recommended Posts

Dear all,

 

I have the following php it works fine, and open the detail.php page with correct id.

<a href="contents/details.php?b_id=<?php echo $business["id"]; ?>" style="text-decoration:none; color:#000;"><h1 style="text-transform:capitalize; margin-bottom:5px;"><?php echo $business["name"]; ?></h1></a>

here is the url re-writing rule in .htaccess:

RewriteRule ^b_id-([a-zA-Z0-9_-]+)-([0-9]+).html$ contents/details.php?b_id=$2

now trying to change the above php to work with the rewriterule, here is the updated php:

<a href="contents/details.html?b_id=<?php echo $business["name"]; ?>-<?php echo $business["id"]; ?>.html" style="text-decoration:none; color:#000;"><h1 style="text-transform:capitalize; margin-bottom:5px;"><?php echo $business["name"]; ?></h1></a>

this produce the following RUL and ERROR:

http://localhost/sbd/contents/details.html?b_id=12-Testing%20my%20own%20business.html
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'my own business.html' at line 1

can anyone guide me, where I am wrong?

 

Regards:

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/285927-url-rewriting-in-php/
Share on other sites

thanks Guru,

 

you are right, but at this time, I need to correct this error. can you help me?

 

here is the php code: 

<a href="contents/details.html?b_id=<?php echo $business["name"]; ?>-<?php echo $business["id"]; ?>.html" style="text-decoration:none; color:#000;"><h1 style="text-transform:capitalize; margin-bottom:5px;"><?php echo $business["name"]; ?></h1></a>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.