|
-
Jan 24th, 2011, 05:13 PM
#1
Thread Starter
Hyperactive Member
char replace
hi
im trying to change char in a text block but i cant get it to work.
can somone please help
the text is taken of another website and formatted. taking out any links and doubling " and ' so it can be added to my database (mysql)
i got this
PHP Code:
$Temp = strip_tags($plot[1], '<br>');
$Temp2=str_replace('"','""',$Temp);
$plott[1]=str_replace("'","''",$Temp2);
programming pc: laptop. running xp pro and vb.net..
media centre xp pc: dual core 6000,4gb memory, 1tb harddrive
mainserver: server 2008, 8gb memory, amd e-350 dual core, 6tb harddrive and local web host
atomvault 1: server 2008, atom 330 with 4 gb memory, 35TB hardrive space for videos and music..
backup pc : xp, 4gb, atom 330, 10tb harddrive(web, pictures, music, databases)
2 x video backup: atom 330, 2gb, 18tb harddrive
everything on remote login..
check out my builds http://AtomVaults.yolasite.com
learning vb.net and php + mysql   - got most of the basics now.
I WISH THERE WAS MORE TIME IN THE DAY  
-
Jan 24th, 2011, 05:44 PM
#2
Re: char replace
You're going to have to be more descriptive. What are you putting in (value of $plot[1] before your replacement code) and what are you getting out (value of $plott[1] at the end of your code)? You can help yourself troubleshoot by echo'ing out the results each step of the way:
PHP Code:
echo $plot[1] . "\n\n"; $Temp = strip_tags($plot[1], '<br>'); echo $Temp . "\n\n"; $Temp2=str_replace('"','""',$Temp); echo $Temp2 . "\n\n"; $plott[1]=str_replace("'","''",$Temp2); echo $plott[1] . "\n\n";
At which point are you not getting what you expected for the output?
-
Feb 27th, 2011, 05:05 AM
#3
Thread Starter
Hyperactive Member
Re: char replace
hi i solved my problem by using the following
Code:
$Find = array("'",'"');
$ee =$plot[1], '<br>';
$plot[1] = str_replace($Find,"",$ee);
programming pc: laptop. running xp pro and vb.net..
media centre xp pc: dual core 6000,4gb memory, 1tb harddrive
mainserver: server 2008, 8gb memory, amd e-350 dual core, 6tb harddrive and local web host
atomvault 1: server 2008, atom 330 with 4 gb memory, 35TB hardrive space for videos and music..
backup pc : xp, 4gb, atom 330, 10tb harddrive(web, pictures, music, databases)
2 x video backup: atom 330, 2gb, 18tb harddrive
everything on remote login..
check out my builds http://AtomVaults.yolasite.com
learning vb.net and php + mysql   - got most of the basics now.
I WISH THERE WAS MORE TIME IN THE DAY  
-
Feb 27th, 2011, 05:21 AM
#4
Thread Starter
Hyperactive Member
Re: char replace
hi
but now i have come across another problem with the same code..
PHP Code:
# Locations
$locs = $movie->locations();
if (!empty($locs)) {
++$rows;
foreach ($locs as $loc) {
if ( empty($loc['url']) );
else ;
}
}
//this is the main txt im trying to filter this is from $ee
//St. Luke's Hospital - 2632 E. Washington Street, Pasadena, California, USA
//---
$Find = array("'",'"');
$ee =$loc['name'];
$locationsname = str_replace($Find,"",$ee);
when i use the txt im trying to filter direct in to the filter for example.
PHP Code:
$ee="St. Luke's Hospital - 2632 E. Washington Street, Pasadena, California, USA";
the filter works but when im using the text direct from $loc['name']; the filter dont work
programming pc: laptop. running xp pro and vb.net..
media centre xp pc: dual core 6000,4gb memory, 1tb harddrive
mainserver: server 2008, 8gb memory, amd e-350 dual core, 6tb harddrive and local web host
atomvault 1: server 2008, atom 330 with 4 gb memory, 35TB hardrive space for videos and music..
backup pc : xp, 4gb, atom 330, 10tb harddrive(web, pictures, music, databases)
2 x video backup: atom 330, 2gb, 18tb harddrive
everything on remote login..
check out my builds http://AtomVaults.yolasite.com
learning vb.net and php + mysql   - got most of the basics now.
I WISH THERE WAS MORE TIME IN THE DAY  
-
Feb 27th, 2011, 02:40 PM
#5
Re: char replace
.. wait. the entire point of all of this is to eventually add this data to the database, correct? don't use str_replace() at all then. use an escape function, like mysql_real_escape_string():
PHP Code:
$mysql_safe_loc = mysql_real_escape_string($loc['name']);
then, use it in your query:
PHP Code:
$sql = "INSERT INTO locations (name) VALUES ('{$mysql_safe_loc}');";
-
Feb 27th, 2011, 05:04 PM
#6
Thread Starter
Hyperactive Member
programming pc: laptop. running xp pro and vb.net..
media centre xp pc: dual core 6000,4gb memory, 1tb harddrive
mainserver: server 2008, 8gb memory, amd e-350 dual core, 6tb harddrive and local web host
atomvault 1: server 2008, atom 330 with 4 gb memory, 35TB hardrive space for videos and music..
backup pc : xp, 4gb, atom 330, 10tb harddrive(web, pictures, music, databases)
2 x video backup: atom 330, 2gb, 18tb harddrive
everything on remote login..
check out my builds http://AtomVaults.yolasite.com
learning vb.net and php + mysql   - got most of the basics now.
I WISH THERE WAS MORE TIME IN THE DAY  
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|