Page 1 of 1

url rewriting in php

Posted: Tue Feb 04, 2014 3:55 am
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:

Re: url rewriting in php

Posted: Tue Feb 04, 2014 2:49 pm
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']?