well, here is the snipit of code I have been messing with:
- Code: Select all
//pull the Name from rss
$start = $namesymbol_start;
$end = $namesymbol_end;
$namesymb = get_string_between($string, $start, $end);
$remove = "$start$namesymb$end";
// preg_match("/^([\w\d\s\.]*)\(.*[A-z]:([\w]*)\)$/", $namesymb, $matches);
preg_match("/^([-a-zA-Z0-9%,&;_\s\.]*)\(.*[A-z]:([\w]*)\)$/", $namesymb, $matches);
$name = $matches[1];
$symbol = $matches[2];
$string = str_replace ($remove, "" , $string);
$name = htmlspecialchars_decode($name);
//$name = htmlspecialchars($name, ENT_QUOTES);
$name = str_replace("&", '&',$name);
$name = str_replace("'", '`',$name);
// $name = str_replace("'", '&rsquo',$name);
The "//" are from me doing trial and error, so I am not sure if I need to replace those. The script is grabbing data from an XML doc and placing into a temp file where the "Macy's" get placed into. Its when it grabbing it out of the XML, running through the preg_match and assigning the name to $name from $matches[1]. I'm sure you knew that.
Then this code puts it into the db:
- Code: Select all
//insert rss item into database store
//mysql_real_escape_string($name);
/*
$insert_query = "INSERT INTO $tablestocks (
`symbol`,
`name`,
`price`,
`change`,
`pchange`
) VALUES (
'$symbol',
'$name',
'$price',
'$change',
'$pchange')";
So I am not sure where I am going wrong. I have not done addslashes() or strip slashes() yet. I will have to look at the php book for that!
