nadeem14375 Posted February 4, 2014 Share Posted February 4, 2014 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: Quote Link to comment https://forums.phpfreaks.com/topic/285927-url-rewriting-in-php/ Share on other sites More sharing options...
requinix Posted February 4, 2014 Share Posted February 4, 2014 You're open to SQL injection and it has nothing to do with your URL rewriting (which I don't think you're using quite the way you wanted to use... but more on that later). What's your PHP code? Quote Link to comment https://forums.phpfreaks.com/topic/285927-url-rewriting-in-php/#findComment-1467676 Share on other sites More sharing options...
nadeem14375 Posted February 4, 2014 Author Share Posted February 4, 2014 (edited) 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> Edited February 4, 2014 by nadeem14375 Quote Link to comment https://forums.phpfreaks.com/topic/285927-url-rewriting-in-php/#findComment-1467680 Share on other sites More sharing options...
requinix Posted February 4, 2014 Share Posted February 4, 2014 I meant the code having to do with searching your database. Because that's where the problem is. Quote Link to comment https://forums.phpfreaks.com/topic/285927-url-rewriting-in-php/#findComment-1467684 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.