Get up to 80 % extra points for free! More info:

Discussion: Lesson 2 - First database table and MySQL PHP drivers

Back

 

Comments
Avatar
Inactive member:1/28/2017 1:32

Is the db.php your creation or?

Reply
1/28/2017 1:32
Inactive user account.
Avatar
Replies to Inactive member
David Capka Hartinger:1/28/2017 9:47

Yes, it's our wrapper for working with the database.

Reply
1/28/2017 9:47
You can walk through a storm and feel the wind but you know you are not the wind.
Avatar
Replies to David Capka Hartinger
Inactive member:1/29/2017 1:31

Exactly what license does this source code use?

Reply
1/29/2017 1:31
Inactive user account.
Avatar
Replies to Inactive member
David Capka Hartinger:1/29/2017 4:08

It's under ICT.social free license. Basically, the only thing you need to do is to keep our link in the source code. More at https://www.ict.social/licenses

Reply
1/29/2017 4:08
You can walk through a storm and feel the wind but you know you are not the wind.
Avatar
Daouda Sanogo
Member
Avatar
Daouda Sanogo:2/4/2017 0:49

Hello,I am having this issue.. may someone help me please? Thanks!

Fatal error: Undefined class constant 'PDO::MYSQL_AT­TR_INIT_COMMAN­D' in C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\DatabaseTes­t\Db.php on line 52

 
Reply
2/4/2017 0:49
Avatar
Daouda Sanogo
Member
Avatar
Replies to IT Man
Daouda Sanogo:2/4/2017 11:59

Thanks it solved the prob! Now i am running on to another problem, i can not connect to my database.
Briefly, i am not using the default port of localhost which is supposed to be '80', i changed it for particular reason to '90' and phpmyadmin is working fine.
Now when i run this code:
<?php
require_once ('Db.php');
$host = "localhost:90";
$database = "web_database";
$user = "root";
$password = "admin";

$success = Db::connect($host, $database, $user, $password);
if($success){
echo 'Connected!';
}else
echo 'Error occurred';
?>

I got this error message:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it. ' in C:\xampp\htdoc­s\DatabaseTes­t\Db.php:54 Stack trace: #0 C:\xampp\htdoc­s\DatabaseTes­t\Db.php(54): PDO->__construct('mys­ql:host=loca.­..', 'root', '', Array) #1 C:\xampp\htdoc­s\DatabaseTes­t\index.php(8): Db::connect('lo­calhost:90', 'web_database', 'root', '') #2 {main} thrown in C:\xampp\htdoc­s\DatabaseTes­t\Db.php on line 54

Could anybody help?

 
Reply
2/4/2017 11:59
Avatar
IT Man
Member
Avatar
Replies to Daouda Sanogo
IT Man:2/5/2017 2:37

Try this:

$host = 'localhost;port=90';
 
Reply
2/5/2017 2:37
Avatar
Tabish Ali
Member
Avatar
Tabish Ali:2/9/2017 12:45

the wrapper you made , is it necessary to understand it for beginners to database?

Reply
2/9/2017 12:45
there is no limit to learn.
Avatar
Replies to Tabish Ali
David Capka Hartinger:2/9/2017 13:20

Absolutely not, you should be only able to use it :)

Reply
2/9/2017 13:20
You can walk through a storm and feel the wind but you know you are not the wind.
To maintain the quality of discussion, we only allow registered members to comment. Sign in. If you're new, Sign up, it's free.

10 messages from 10 displayed.