url rewriting in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nadeem14375
Forum Newbie
Posts: 23
Joined: Sat Oct 30, 2010 2:11 am

url rewriting in php

Post by nadeem14375 »

Dear all,

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

Code: Select all

<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:

Code: Select all

<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:
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:
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: url rewriting in php

Post by Christopher »

nadeem14375 wrote:
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
The error message say the problem is that you are inserting 'my own business.html' into SQL somewhere in your program and MySQL is finding a syntax error. Where do you use $_GET['b_id']?
(#10850)
Post Reply