Question

I don't know why my script is receiving so many errors class DB { private$dbHost="localhost"; private...

I don't know why my script is receiving so many errors

class DB

{

private$dbHost="localhost";

private $dbUsername="sixfoour";

private $dbPassword="499e9n3";

private $dbName="sleep";

public $db_con;

public function _construct()

{

if(!isset($this->db)

{

try {

$pdo = new PDO("mysql:host=".$this->dbHost.",;dbname=".$this-dbName", $this->dbUsername,$this->dbPassword);

$this->dbPassword;

$this->setAttribute(PDO::ATTR,PDO::ERROMODE_EXECEPTION);

$this->db_con=$pdo;

}

catch(PDOEXECEPTION $e)

{

die("Failed to connect with mySQL": $e->getMessage());

}

}

}

public function login($user_name, $user_password)

{

$stmt= $this->db _con->prepare("SELECT * FROM Login_Info WHERE user_name=:user_name");

$stmt->execute(array(":user_name"=>$user_name));

$row=$stmt->fetch(PDO::FETCH_ASSOC);

$count=$stmt->rowCount();

if($row['user_password']==$user_password)

{

return $count;

}

else

{

return false;

}

}

public function regrister($name,$user_name, $user_password)

{

$sql="INSERT into Login_Info(name,user_name,user_password)VALUES(:name, :user_name, :user_password);

$stmt=$this->db_con->prepare($sql);

$stmt->bindParams(:name, $name);

$stmt->bindParams(:user_name, $user_name);

$stmt->bindParams(:user_password, $user_password);

}

}

?>

0 0
Add a comment Improve this question Transcribed image text
Answer #1

class DB

{

private$dbHost="localhost";

private $dbUsername="sixfoour";

private $dbPassword="499e9n3";

private $dbName="sleep";

public $db_con;

public function _construct()

{

if(!isset($this->db)

{

try {

$pdo = new PDO("mysql:host=".$this->dbHost.",;dbname=".$this->dbName, $this->dbUsername,$this->dbPassword);

$this->dbPassword;

$this->setAttribute(PDO::ATTR,PDO::ERROMODE_EXECEPTION);

$this->db_con=$pdo;

}

catch(PDOEXECEPTION $e)

{

die("Failed to connect with mySQL": $e->getMessage());

}

}

}

public function login($user_name, $user_password)

{

$stmt= $this->db _con->prepare("SELECT * FROM Login_Info WHERE user_name=:user_name");

$stmt->execute(array(":user_name"=>$user_name));

$row=$stmt->fetch(PDO::FETCH_ASSOC);

$count=$stmt->rowCount();

if($row['user_password']==$user_password)

{

return $count;

}

else

{

return false;

}

}

public function regrister($name,$user_name, $user_password)

{

$sql="INSERT into Login_Info(name,user_name,user_password)VALUES(:name, :user_name, :user_password)";

$stmt=$this->db_con->prepare($sql);

$stmt->bindParams(:name, $name);

$stmt->bindParams(:user_name, $user_name);

$stmt->bindParams(:user_password, $user_password);

}

}

Add a comment
Know the answer?
Add Answer to:
I don't know why my script is receiving so many errors class DB { private$dbHost="localhost"; private...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PHP PDO lab Reorganize the code (refactor), write a separate class that implements the interface StudentInterface...

    PHP PDO lab Reorganize the code (refactor), write a separate class that implements the interface StudentInterface and use the methods in this class to show the list of students and details of a student. - All SQL queries are moved into the methods defined in the interface and the methods return data back to the calling program. - Use prepared statements for queries that take one or more input parameters. interface StudentInterface {    public function visAlle() : array;   ...

  • I need help showing the first column of the table to show up exactly with the...

    I need help showing the first column of the table to show up exactly with the mysql table into the php page. Is there a way to fix it ? So I created a php form where the user enters the information. sand.truman.edu/~jyl6557/assignment5/hw5-dataentry.php . it asks for name, hometown, gender(only male and female) and status (freshman, sophmore, junior, senior). once it checks and passes through those tests, it would say added successfully and then show the links to add another...

  • I am creating an Android application that has a login/registration page. To be able to use...

    I am creating an Android application that has a login/registration page. To be able to use the application, the user must be 21 + years old. I have previously created php files for login, register, and update user info. I am having trouble on where to add code that will check if the user is 21+ into the update_user_info.php file I have created. I have figured out the correct mysql command to add to the php file, I am just...

  • For this code below, I need to add the form information to mysql when I click...

    For this code below, I need to add the form information to mysql when I click on submit, at the same time when I click on submit I need to move to another page like Welcome.php WITH NOTE THAT THE ENTERED INFORMATION NOW ALREADY IN DATABASE how can I male that with my code below? THANKS ................................................................................................................................................   <form method="POST"> <div class="container">    <label for="fname"><b>First Name</b></label> <input type="text" placeholder="Enter First Name" name="fname" required> <label for="lname"><b>Last Name</b></label> <input type="text" placeholder="Enter Last Name"...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT