Running PHP source code and connecting to database
Posted by: Tech Central (---.safaricombusiness.co.ke)
Date: May 25, 2017 04:12PM

I have received a source code of a pharmacy POS in PHP and mySQL db but i am unable to get it connected to the DB. First of all, the DB doesn't show under the database column within the myPHPAdmin, i am only able able to see other previous databases; i do not understand is it because the said DB is in SQL query or what and the errot message i get is"Unable to select database", i have tried all methods to my understanding to locate the DB like changing the PHP file which contains the code to connect to the DB to no avail.
A full explanation or demonstration of how to get a PHP source code with an existing database to run would be a great help.
Here's a snipet of the connect code:

<?php
/* Database config */
$db_host = 'localhost';
$db_user = 'root';
$db_pass = '';
$db_database = 'sales';

/* End config */

$db = new PDO('mysql:host='.$db_host.';dbname='.$db_database, $db_user, $db_pass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

?>


Thank you in advance.
Regards,
Tech Central.

Options: ReplyQuote
Re: Running PHP source code and connecting to database
Posted by: RiggsFolly (Moderator)
Date: May 25, 2017 07:38PM

Hi

Quote

First of all, the DB doesn't show under the database column within the myPHPAdmin

Did you create the database?

Quote

i do not understand is it because the said DB is in SQL query

What is SQL query?

Quote

I have received a source code of a pharmacy POS in PHP and mySQL

If you do not know how to install the software you have acquired, I suggest you ask the author what you need to do to properly install their software.
It would seem fairly obvious that this is not a WAMPServer issue, but instead a lack of knowledge and/or understanding on your behalf

We do not SUPPORT EACH AND EVERY piece of software that exists in the universe

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.1.3 32bit & 64bit)
<Apache 2.4.29/2.2.31> <PHP 7.2/7.1/7.0/5.6/5.5/5.4> <MySQL 5.7.19/5.6.39/5.5.28>
<MariaDB 10.2.14> <phpMyAdmin4.8.1> <MySQL Workbench 6.3.10>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your MySQL databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-



Edited 2 time(s). Last edit at 05/25/2017 07:41PM by RiggsFolly.

Options: ReplyQuote


Sorry, only registered users may post in this forum.