Jump to content

preg_replace


mypopy

Recommended Posts

Hi everyone

 

I've got this error

 

Error: (1064) 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 'sobi2Listing_field_country'>

 

how do I use preg_replace to remove sobi2Listing and leave field_country only.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/40352-preg_replace/
Share on other sites

Hi everyone

 

I've got this error

 

Error: (1064) 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 'sobi2Listing_field_country'>

 

how do I use preg_replace to remove sobi2Listing and leave field_country only.

 

Thanks

 

If you're doing a straight replace like that, I would recommend you use str_replace():

<?php
$query = str_replace('sobi2Listing_', '', $query);
?>

 

If you need to do a more detailed pattern match, preg_replace would be the way to go:

<?php
$query = preg_replace('|sobi2Listing_|', '', $query);
?>

 

Good luck

Link to comment
https://forums.phpfreaks.com/topic/40352-preg_replace/#findComment-195248
Share on other sites

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.