[Solved] String Var with int var [closed]

If I understand your question, then this System.out.println(tot); System.out.print(a + b + c); should be System.out.print(tot); System.out.println(a + b + c); When I make the change above, I get output like you seem to be asking for – Number 1: 1 Number 2: 3 Number 3: 5 Total: 9 Another option would be to use … Read more

[Solved] plain mysql prepare statement prevent injection attack?

[I assume that you meant $mysqli is mysqli connection.] Although the execution of stmt1 (the last of your three queries) is safe, the multi-query function you wrote is very unsafe. Running something like userQuery(“‘; delete from user; select * from user where username=””); will actually delete all users from your user table. Assuming $username represents … Read more

[Solved] How to convert decimal to binary?

Just like you divide this 18 by 2 repeatedly to form a decimal representation for it, you need to do the reverse to convert the decimal part of the number to binary. You need to multiply that decimal portion of the number by 2 repeatedly until it gives a standalone digit. The result(product) of the … Read more

[Solved] Why is the output Negative? [closed]

Many notations use “^” as a power operator, but in PHP (and other C-based languages) that is actually the XOR operator. You need to use this ‘pow’ function, there is no power operator. In your code $keone = $vone ^ 2; Should be $keone = pow($vone,2); Rest of your code is fine. That pow function … Read more

[Solved] JavaScript variable from function used outside the function [duplicate]

The problem is that you’ve declared sum inside your function, but then this code hidden away at the bottom of your fiddle tries to use it **outside* the function (It has nothing to do with loops; in fact, I don’t see any loops in your code): <script>document.getElementById(“total”).innerHTML=sum</script> That fails because there is no global sum … Read more

[Solved] How to insert a variable in a query in asp.net c#? [closed]

Your method is open to SQL Injection. You should try this: protected void Button1_Click(object sender, EventArgs e) { string email = Request.QueryString[“Email”]; cmd.Connection = cn; cmd.CommandType = CommandType.Text; cmd.CommandText = “INSERT INTO Job (Industry, JobPosition, ExactAddress, Region, Salary, JobDesc, EmployerID) VALUES (@industry, @jobPosition, @exactAddress, @region, @salary, @jobDesc, (Select employerid from employer where email = @email))”; … Read more

[Solved] Regex pattern for file extraction via url?

Regex for this is overkill. It’s too heavy, and considering the format of the string will always be the same, you’re going to find it easier to debug and maintain using splitting and substrings. class Program { static void Main(string[] args) { String s = “<A HREF=\”/data/client/Action.log\”>Action.log</A><br> 6/8/2015 3:45 PM “; String[] t = s.Split(‘”‘); … Read more

[Solved] Use of global for mysqli_insert_id()

class MySQLiConnection { private static $conn = null; private function __construct() { } public static function getConnection() { if (static::$conn === null) { static::$conn = mysqli_connect(/* your params go here */); } return static::$conn; } } Then you can replace all global $conn with $conn = MySQLiConnection::getConnection() 4 solved Use of global for mysqli_insert_id()

[Solved] Another coredump issue in C

I would think you would need to add check on your externally accepted values (using assert might be a start) Like : checking tm>0 ler>0 C[i]<tm A[i]!=NULL B[i]!=NULL As mentionned in the comment it an off by one issue : in LER the values should be from 0 to tm-1 or use B[i][j]=C[k]-1; at line … Read more

[Solved] C# Add nodes in xml

This projects both sets into an anonymous object List, makes comparisons, and gives you a set of anonymous objects that don’t yet exist by which you can add to the out XML. public static List<object> GetInStudents(XDocument sourceXmlDoc) { IEnumerable<XElement> inStudentsElements = sourceXmlDoc.Root.Elements(“Classes”).Descendants(“Class”) .Descendants(“Students”).Descendants(“Student”); return inStudentsElements.Select(i => new { Id = i.Elements().First().Value, Name = i.Elements().Last().Value }).Cast<object>().ToList(); … Read more

[Solved] Postfix notation stack C++ [closed]

Using stack.top() is illegal if the stack is empty. Change while((!highPrecedence(stack.top(),c)) && (stack.size()!=0)){ to while((!stack.empty()) && (!highPrecedence(stack.top(),c))){ The initiali value of i is not good and you are printing uninitialized variable, which has indeterminate value. Change int i=0; to int i=-1; 1 solved Postfix notation stack C++ [closed]