CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 [SOLVED] preg_replace

Print topic Send  topic

Author Message
caran

Posts: 15
Posted: 09/07/2012, 5:49 AM

Hy there!

Can somebody help to solve my problem:

I have a Text in a db-file called 'vtr_kopftext'
In this text ther is a sign '#'
I want to replace this with a name

global $DBWLPG01;
$vtrnr = $vertrag1->vtr_nr->GetValue();
$betreuernn = CCDLookUp("psn_nachname","personen","psn_id=".$DBWLPG01->ToSQL($vertrag1->vtr_betreuer->GetValue(), ccsInteger), $DBWLPG01);
$betreuervn = CCDLookUp("psn_vorname","personen","psn_id=".$DBWLPG01->ToSQL($vertrag1->vtr_betreuer->GetValue(), ccsInteger), $DBWLPG01);
$betreueran = CCDLookUp("psn_anrede","personen","psn_id=".$DBWLPG01->ToSQL($vertrag1->vtr_betreuer->GetValue(), ccsInteger), $DBWLPG01);
$betreuerarray = array($betreueran, $betreuervn, $betreuernn);
$betreuertext = implode(" ",$betreuerarray);

So i have the Name and now i want to replace it:

// preg_replace($suchmuster, $ersetzungen, $zeichenkette);
$suchmuster = '#';
$vtrkopftext1 = CCDLookUp("vtr_kopftext","vertrag","vtr_id=".$DBWLPG01->ToSQL($vertrag1->vtr_id->GetValue(), ccsInteger), $DBWLPG01);
$vtrkopftext = preg_replace($suchmuster, $betreuertext, vtrkopftext1);
$result = $DBWLPG01->query("update vertrag set vtr_kopftext = '$vtrkopftext' where vtr_nr = " .$vtrnr);

My text would be completly deleted....

Is my way wrong? Is there a better way?
View profile  Send private message
bannedone


Posts: 273
Posted: 09/07/2012, 7:03 AM

Hi

Reading this in German is a little difficult for me.. LOL

If I understand the issue here, why not use str_replace()??

Usually the first parameter to preg_replace() is a regular expression.

Have you tried this??

$vtrkopftext = str_replace($suchmuster, $betreuertext, vtrkopftext1);

8-)

_________________
John Real
CodeCharge Studio Support, Training, Consulting, Development, Web based solutions
http://realsites.biz
http://ccselite.com
Other Banned IDs on this Forum. jjrjr1, jjrjr2
View profile  Send private message
caran

Posts: 15
Posted: 09/07/2012, 7:28 AM

just the variables are german... ;-)

but thanks for your tip with str_replace, now i have my solution!
View profile  Send private message
bannedone


Posts: 273
Posted: 09/08/2012, 10:37 PM

LOL

It was just a little harder figuring out what U were doing with German Variables since mnemonically to me I could not follow easily.

Glad that helped you....

Have fun
8-)
_________________
John Real
CodeCharge Studio Support, Training, Consulting, Development, Web based solutions
http://realsites.biz
http://ccselite.com
Other Banned IDs on this Forum. jjrjr1, jjrjr2
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.