Commit 4a7a6d87 authored by michael lundquist's avatar michael lundquist
Browse files

Committing this because I'm at a stage where I can connect to MySQL from PHP...

Committing this because I'm at a stage where I can connect to MySQL from PHP and perform basic queries. I had to change MySQL's authentication method on my local machine described [here](https://serverfault.com/questions/924367/php-7-2-8-pdo-fails-to-connect-to-mysql-8-0-12-ga-in-aws-ec2-lemp-stack/939903#939903), the other changes were just fixing minor bugs in directory paths.
parent 7c7bab4e
<?php
include_once(dirname(__FILE__)."/queryPrep.php");
//echo phpinfo();
$res = resultQuery("select count(*) from zip",[]);
echo $res->num_rows."<br/>";
echo $res->fetch_row()[0]."<br/>";
$res->close();
?>
HELLO WORLD!
\ No newline at end of file
......@@ -19,18 +19,20 @@ http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers
include_once(dirname(__FILE__)."/configNuts.php");
function SQLlogin(){
$server = "localhost";
$server = "127.0.0.1";
$username = "root";
$password = "root";
if(strstr(PHP_ROOT,"nuts") === FALSE){
if(strstr(PHP_ROOT,"public_html") === TRUE){
//greengeeks credentials
echo "here";
$server = "mikeroservices.com";
$username = "sellmysh";
$password = "j8C4Rrh5f9";
}
$con = new mysqli($server,$username,$password);
$con->select_db("sellmysh_zip");//TRUE on success, FALSE on fail
return $con;
......
<?php
//configure the database name?
if(is_dir(dirname(__FILE__)."/../nuts/nutrition")){
if(is_dir(dirname(__FILE__)."/../zipAPI")){
//localhost
define("PHP_ROOT", $_SERVER["DOCUMENT_ROOT"]."/nuts/nutrition");
define("HTML_ROOT", "/nuts/nutrition");
define("PHP_ROOT", $_SERVER["DOCUMENT_ROOT"]."/zipAPI");
define("HTML_ROOT", "/zipAPI");
define("URL", "http://localhost/nuts/nutrition/");
}elseif(is_dir(dirname(__FILE__)."/../public_html")){
}elseif(is_dir(dirname(__FILE__)."/../../public_html")){
//SMS
define("PHP_ROOT", $_SERVER["DOCUMENT_ROOT"]);
define("HTML_ROOT", "");
define("URL", "https://mynutrients123.com/");//can't be www. this is a different domain (cert won't work)
define("URL", "https://mikeroservices.com/zipAPI/");//can't be www. this is a different domain (cert won't work)
}else{
exit("configME 2 failure in configNuts.php");
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment