[Solved] Replace text inside .txt file or .xml file using loop [closed]

Using xml linq : using System; using System.Collections.Generic; using System.Collections; using System.Linq; using System.Text; using System.Xml; using System.Xml.Linq; namespace ConsoleApplication { class Program { static void Main(string[] args) { string xml = @”<Root> <Tag1> <USA></USA> <UK></UK> </Tag1> <Tag2> <FRA></FRA> <USA></USA> </Tag2> </Root>”; XDocument doc = XDocument.Parse(xml); List<XElement> tags = doc.Descendants().Where(x => x.Name.LocalName.StartsWith(“Tag”)).ToList(); List<string> countries = … Read more

[Solved] Why print ‘NaN’ value in javascript? [closed]

Replace , with = it will also work fine! Initialize variable var scores = { val1: 90, val2: 100, val3: 98, val4: 95 } function calcAverage() { var sum = size = 0; for (var key in this) { sum += this[key]; size++; } return sum / size; } console.log(calcAverage.apply(scores)); 5 solved Why print ‘NaN’ … Read more

[Solved] PDO login.php needs help finishing [closed]

The prepare statement returns an object, you can execute that object. Thus $query->execute() – the first parameter of execute can be an array. Alternatively, you can use the bindParam function first on that same $query object instead of passing an array though. Anyways, here you are: <?php if(isset($_POST[‘username’], $_POST[‘password’])){ try{ $username=”root”; $password = ”; $conn … Read more

[Solved] Undefined offset:1, 2 3 etc

$csv_array[1];, $csv_array[2]; and $csv_array[3]; don’t exists inside your $csv_array. As suggested, do a var_dump($csv_array) below $csv_array = explode(“,”, $csv_data[$i]); and see what is in there! 0 solved Undefined offset:1, 2 3 etc

[Solved] Trying to convert mysql to mysqli, not working

Just for a quick testing purpose, try this below which is a bare bones method. You can then slowly build up sanitizing and troubleshoot from thereon. <?php $username = $_POST[‘username’]; $password = sha1($_POST[‘password’]); $link = mysqli_connect(‘xxx’, ‘xxx’, ‘xxx’, ‘xxx’); $query = “SELECT password, id FROM users WHERE username=”$username” AND password=’$password'”; $result = mysqli_query($link, $query); if(mysqli_num_rows($result) … Read more

[Solved] How to replace the string [closed]

I think using Regular Expression works better. private static String setSize(String htmlString) { String reg = “size=”[0-9]+””; Pattern pattern = Pattern.compile(reg); Matcher matcher = pattern.matcher(htmlString); while (matcher.find()) { String sizeString = matcher.group(); pattern = Pattern.compile(“[0-9]+”); Matcher numMatcher = pattern.matcher(sizeString); if (numMatcher.find()) { String size = numMatcher.group(); int realSize = Integer.parseInt(size); int resultSize = realSize / … Read more

[Solved] Adding Google Maps to an Html File and Using It With Knockouts [closed]

A really quick google revealed: Google maps and knockoutjs http://chadmullins.com/misc-php/knockout-series-three.php and perhaps most usefully: http://hoonzis.blogspot.co.uk/2012/03/knockoutjs-and-google-maps-binding.html. Without further information I can’t be more specific. 2 solved Adding Google Maps to an Html File and Using It With Knockouts [closed]

[Solved] gcc 4.7 Give me error message

The error says it all. Trying adding -std=c++11 or -std=gnu++11 to the compiler options in your NetBeans IDE. I’ve not used Netbeans but see this link where a snapshot of build variables is shown and that is where you need to add the compiler options. 1 solved gcc 4.7 Give me error message

[Solved] Golang shadowing behavior explanation [duplicate]

Go is lexically scoped using blocks. In this example: list := []string{“a”, “b”, “c”} for { list := repeat(list) The second list shadows the first within the for block, and doesn’t alter the outer list variable. Because the arguments to repeat are evaluated before the inner list is declared and assigned, repeat receives the value … Read more