1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
NeTakaya
3 years ago
10

HOW DO I CONNECT TO MY mysql server on my computer locally using php and also how to run it on the browser

Computers and Technology
1 answer:
zhuklara [117]3 years ago
7 0

Answer:

<?php

$mysqli = new mysqli("127.0.0.1:3307", "myUser", "myPass", "databasename");

$query = "SELECT * FROM users ORDER BY name";

if($result = $mysqli->query($query))

{

   echo '<ul>';

while ($obj = $result->fetch_object())

   {

       echo '<li>'.$obj->name.'</li>';

   }

   $result->free();

   echo '</ul>';

}

else

{

   die("nothing found");

}

$mysqli->Close();

?>

Explanation:

This should get you started.

You might be interested in
A shipping company uses the following function to calculate the cost in dollars of shipping based on the weight of the package (
Gwar [14]

Answer:

I am writing the code in JAVA and C++. Let me know if you want the code in some other programming language. Both the programs works the same but the only difference is that i have used logical operator AND (&&) with C++ code to check each condition.

JAVA code:

import java.util.Scanner;    // to take input from the user

public class ShippingCost {  // ShippingCost class

public static void main(String[] args) {   // main method entry to the program

Scanner input = new Scanner(System.in);  //allows to take input from user

System.out.print("please enter the weight of the package: "); /*prompts the user to enter the weight of package.*/

double weight = input.nextDouble();  /*reads and stores the input values(weight) entered by the user*/

       double cost=0;  //holds the value of cost

 if (weight<=0)  /* checks if the user enters weight value less than or equals to 0 */

 { System.out.println("invalid input."); //prints invalid input

     System.exit(0); //exits the program

 }

    else if (weight > 0 && weight <= 1)  /*if weight is greater than 0 and less than or equal to 1*/

   cost = 3.5;  /*if the above condition is true then it stores the value 3.5 in cost variable */

 else if (weight <= 3)  // if value of weight is less than or equal to 3

   cost = 5.5;  /*if the above condition is true then it stores the value 5.5 in cost variable */

 else if (weight <= 10)  // if value of weight is less than or equal to 10

   cost = 8.5;  /*if the above condition is true then it stores the value 8.5 in cost variable */

 else if (weight <= 20)  // if value of weight is less than or equal to 20

   cost = 10.5;/*if the above condition is true then it stores the value 10.5 in cost variable */

 else  // if the value of weight is greater than 20

 {  System.out.println("The package cannot be shipped");

// displays package cannot be shipped

      System.exit(0);  //exits the program if weight>20}

 System.out.println("The shipping cost is: $" + cost);     /*prints the value stored in the cost from any of the above conditions */

} }

C++ Code

#include <iostream>//to use input output functions

using namespace std;

int main() // start of main() function body

{ double weight; //stores weight value

   double cost= 0; //stores cost value

cout << "please enter the weight of the package:" << endl;

//prompts user to enter the weight

cin >> weight;    

//reads the value of weight entered by the user

  if (weight<=0) //if value of weight entered by user is less than or equal to 0

 { cout<<"invalid input."; //displays invalid input

     exit(0); //exits the program

 }

/*the below else if conditions are checked, if any one of them is true then the cost displayed in the output will be the which is assigned to cost variable of that specific if condition's body which evaluates to true. */

    else if (weight > 0 && weight <= 1)

   cost = 3.5;

 else if (weight > 1 && weight <=3)

   cost = 5.5;

 else if (weight > 3 && weight <= 10)

   cost = 8.5;

 else if (weight> 10 && weight <= 20)

   cost = 10.5;

 else //if weight>20

//displays the message below and exits the program

 {  cout<<"The package can not be shipped";

      exit(0); }

 cout<<"The shipping cost is: $"<<cost;  /*displays the value stored in cost variable of that else-if condition which evaluates to true */

}

Explanation:

Everything is well explained in the comments above. I will summarize it all.

The program takes the input weight from the user and checks the value of weight.

If and else-if conditions are used to check the value of weight.

if the value of weight is less than 0 or equal to 0 then invalid input is displayed.

Else the weight value is checked for the given ranges. && operator is used in each else if statement which is used to specify the range of the weight values the input weight should be in order to display the shipping cost.

For example take this statement: else if (weight > 0 && weight <= 1)

This statement checks the value entered by the user that if it lies in the range mentioned in this statement which is that the weight value should be greater than 0 AND less than or equal to 1. The value cannot lie above or below the given range in order for this condition to be true so && operator is used here.

If the weight entered by user exceeds 20 then the message is displayed:The package can not be shipped and the program exits. In JAVA System.exit(0) and in c++ exit(0) function is used to exit the program.

The output of both the programs is as following:

please enter the weight of the package: 3

The shipping cost is: $ 5.5

8 0
3 years ago
Para que se emplean los operando en una formula
sergejj [24]

Explanation:

what are you mobile-gws-wiz-serp now and black and son in a new medicine that is not the only way that we know you are in a

4 0
4 years ago
You receive an email from your school's head of IT. There is a concern for a potential hack to the school's servers. IT knows so
creativ13 [48]

Answer:

a.) This could be a phishing attempt. If the situation is as described in the email, this is also serious, but the method suggested is the same methods used by social hackers. Look up your IT Departments; phone number and call them about the email.

Explanation:

This makes sense because many people do these types of scams to trick people into logging into their accounts and actually hack them from there, I actually got an email like this last week to my iCloud address. Make sure that the email actually came from the IT department by checking the domain the email comes from, and call the IT department to make sure.

Hope this helps!

5 0
3 years ago
The Internet can both reduce and increase the bargaining power of suppliers, depending on the specific circumstances.
slamgirl [31]

Answer:

True                                                                                

Explanation:

Internet can reduce bargaining power of suppliers:

Internet is a powerful means which has strengthen competitiveness in organizations. This has led to competition which results in price wars. This decreases the bargaining power of suppliers as the competition among different suppliers intensifies and the need of the buyers to buy only from a few suppliers is lessened. This also results in the increased bargaining power of buyers. Internet enables buyers to save their time and money and has increased transparency e.g. services costs which resulted in increase bargaining power of buyers while reducing the bargaining power of suppliers. This transparency increased price competition and competitiveness . Consequently buyers are less loyal to certain suppliers and can choose the suppliers who meet their requisites.

Internet can increase bargaining power of suppliers:

Through internet the bargaining power of suppliers can be increased. The internet has given a cost effective platform to suppliers to reach to their customers which has increased competition between suppliers. Suppliers can access more customers and provides better services to them. With internet connectivity suppliers can directly communicate with their customers. The internet can increase the bargaining power of suppliers by allowing reduction of entry barriers and increasing number of competitors.

7 0
4 years ago
Complete the sentence describing computer languages.
kari74 [83]

Answer:

A low level language uses zeros and ones.

Explanation:

7 0
4 years ago
Other questions:
  • This is tech question related to mobile and PC.
    6·1 answer
  • The image type used for graphics that need smaller sizes with no loss of quality is a ___________.
    8·1 answer
  • When you adopt a certain framework or strategy for solving a series of problems, you may fail to see other, more efficient ways
    12·1 answer
  • Differentiate between Software as a service, platform as a service and infrastructure as a service.
    14·1 answer
  • Exactly how thin is the air in outer space?
    10·1 answer
  • Which statement is correct? (Note: Our selectionsort picks largest items first.) A. The algorithm might be either selectionsort
    9·1 answer
  • Email, instant messaging and most web traffic go across the internet in the clear; that is, anyone who can capture that informat
    15·2 answers
  • Does this mean that the radius is the input aka 3 ? what about the PI ?
    14·1 answer
  • A time line may identify cause or effect of an event?<br> True or False?
    7·1 answer
  • What are the six things you will learn this week on Scratch?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!