Sorry this is more a php, maybe mySQL, question: (again), but...
I'm working on the php module to manually create a batch of new articles by using an INSERT query to add records to the "cur" table in mySQL. The text that I'm starting these new articles with contains a pair of Extension Tags, and the slash in the End Tag is giving me trouble. I'm guessing that I need to escape it, but can't figure out how to. I've tried a backslash, and 1-3 slashes in front. I either get the text string truncated at the slash, or everything passes through, can't get the single slash by itself: I tried experimenting with the addslashes function, but either didn't do it right or it isn't the solution. Here's the snippet.
$theText = '<1905GazetteerProtParishTable>'.$town.'</1905GazetteerProtParishTable>';
and here's the essential parts of the function that it's in: (would appreciate any help with bad coding, I know just enough php to be dangerous. In particular, is " ! " the correct negation operator: if (!($row2 = mysql_fetch_array($result2))) is this the best way to test for a null text value: if ($town <> "") and is anything obviously wrong with the construction of the last (INSERT) sql query?
TIA, James =======================================================
function makeJurisdictionArticles( $input ) //$input = Kreis ("county") { ( db connection logic here)
$query = "SELECT JurisProt FROM Gazetteer1905 WHERE Kreis LIKE '".$theKreis."'"." GROUP BY JurisProt ORDER BY JurisProt ASC"; $output = ""; // in case I output some debugging to calling routine. $result = mysql_query($query); while($row = mysql_fetch_array($result)) //for each Protestant church town { $town = $row['JurisProt']; // extract the town name of the Protestant parish if ($town <> "") { $theTitle = 'Protestant_parish_of_'.spaces2underscores($town); // title of the new article will be...
$query2 = "SELECT cur_title FROM cur WHERE cur_title LIKE '".$theTitle."'";
$result2 = mysql_query($query2); if (!($row2 = mysql_fetch_array($result2))) // if no article with this title exists yet... { $theText = '<1905GazetteerProtParishTable>'.$town.'</1905GazetteerProtParishTable>'; $theText .= '<br>Parish began ????, split off from ?????'; echo($theText); // debug $query3 = 'INSERT INTO cur (cur_namespace, cur_title, cur_text, cur_user, cur_user_text, cur_timestamp, cur_random) VALUES ("0", "'.$theTitle.'", "'.$theText.'", "1", "WikiSysop", UNIX_TIMESTAMP( ) , RAND( ))'; $result3 = mysql_query ($query3); } } } return $output; // (if debugging) }