Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » PHP Development Tools (PDT) » How create a PDT connection to mysql database
How create a PDT connection to mysql database [message #1818813] Mon, 30 December 2019 00:28 Go to next message
steeves steeves is currently offline steeves steevesFriend
Messages: 1
Registered: December 2019
Junior Member
Hello.
I Will connect to my mysql database with eclipse.
I trying PDO connection in php file but after deploying in the server,
Eclipse notify me with this message: COULD not find driver.
This my question how load mysql driver in eclipse PTD ?

Thank you.
Re: How create a PDT connection to mysql database [message #1819201 is a reply to message #1818813] Thu, 09 January 2020 22:43 Go to previous messageGo to next message
Fleur Pink is currently offline Fleur PinkFriend
Messages: 1
Registered: January 2020
Junior Member
steeves steeves wrote on Mon, 30 December 2019 00:28
Hello.
I Will connect to my mysql database with eclipse.
I trying PDO connection in php file but after deploying in the server,
Eclipse notify me with this message: COULD not find driver.
This my question how load mysql driver in eclipse PTD ?

Thank you.

What is the version of eclipse that you use?
Re: How create a PDT connection to mysql database [message #1819598 is a reply to message #1819201] Fri, 17 January 2020 19:36 Go to previous messageGo to next message
Bansley Jako is currently offline Bansley JakoFriend
Messages: 3
Registered: January 2020
Junior Member
The version of eclipse you have currently will help solve your question
Re: How create a PDT connection to mysql database [message #1821525 is a reply to message #1819598] Fri, 14 February 2020 06:39 Go to previous message
Tell  Media is currently offline Tell MediaFriend
Messages: 1
Registered: February 2020
Junior Member
first, you have to need to add all necessary driver and load or add a driver to project library after write code given below

PDO data base connection and INSERT , UPDATE AND DELETE QUERY


connecting to MySQL database:

<?php
# Connect
mysql_connect('localhost', 'database_user', 'database_password') or die('Could not connect: ' . mysql_error());
?>
//If there is an error in database connection how can we identify so here is try/catch for error handling.

<?php
try {
$conn = new PDO('mysql:host=localhost;dbname=myDB', $db_username, $db_password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
}
?>
PDO::ERRMODE_EXCEPTION will fire exceptions when occur. Using this procedure we can handle any exception.
There is two ways to fetch data query and execute we explain both.
////1. Query

<?php
$string = 'PHPGang'; # user submitted data
try {
#connection
$conn = new PDO('mysql:host=localhost;dbname=myDB', $db_username, $db_password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$data = $conn->query('SELECT * FROM myTable WHERE name = ' . $conn->quote($string)); // $conn->quote used to protect SQL injection
foreach($data as $rows) {
print_r($rows);
}
} catch(PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
}
?>
Previous Topic:settings for debugging php with eclipse mars
Next Topic:Importing Wordpress into Eclipse
Goto Forum:
  


Current Time: Thu Apr 25 15:30:25 GMT 2024

Powered by FUDForum. Page generated in 0.03315 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top