Jump to content

Preg_Replace (Space to dash)


hitk

Recommended Posts

Ok. I have ZERO PHP Knowledge, still good in editing php and all that stuff. Only know copy paste and have no knowledge what that means. Still would try to explain my problem.

 

I use variable to fetch data from mysql. Ex. my url is http://www.example.com/venue.php?vcity=New York.

 

Now, I want to replace New York with New-York. The real url I am trying to get is http://www.example.com/venue-new-york.php.

 

For that I added code in htaccess

RewriteRule ^venue-([^/]*)\.php$ /venue.php?vcity=$1 [L]

 

I Know what I added in htaccess is mostly perfect.

 

Now, I am using smarty so would be able to do lower case and replace space with dash. But that would not allow me to fetch data from mysql for some reason. In class file I have following code.

 

 

function getallvenueschedule()
{
	global $db,$smarty;
	$sql = " SELECT * FROM table WHERE vcity = '$this->vcity' AND sch_date >= '$this->sch_date' ORDER BY timestmp ASC";
	$theList	= $db->getAll($sql); 
	return $theList;
}

 

In the php file below is code.

 

 

$vcity = $_GET['vcity'];

 

I hope I provided almost all details. Problem is that whatever data is in variable vcity (examp. if I have new-york in url then it will search new-york in mysql rather new york

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.