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 7 Pro 32bit) (Wampserver 3.0.6 32bit)
<Apache 2.4.23/2.2.31> <PHP 7.1.2/7.0.16/5.6.28/5.5.38/5.4.45/5.3.29> <MySQL 5.7.10/5.6.17/5.5.28>
<MariaDB 10.1.21> <phpMyAdmin4.7.5> <MySQL Workbench 6.3.6.511>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin -- WAMPServer alternate Repo
-?-?-?- Backup your MySQL databases regularly Here is How dont regret it later! Yes even when developing -?-?-?-



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.