Jump to content

Using githup to make php code opensource, keeping details of server secure


thehitechpanky

Recommended Posts

Hi Little Help Needed
I have created a new website
In the index.php file i want to show records from database

Now, here is how the problem arise
I want to import codes from github intead of hosting those files on my server because i want to keep it opensource

Below is the code I am using
<?php
// connect to the database
include('connect-db.php');

// get results from database
$sql = "SELECT id, upadhi, name FROM munishri";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"]. " - Name: " . $row["upadhi"]. " " . $row["name"]. "<br>";
}
} else {
echo "0 results";
}

// close connection
$conn->close();
?>

Can i host the code to show result in another file and use something like
<?php
// connect to the database
include('connect-db.php');

// get results from database
include('http://rawgit.com/thehitechpanky/jainmunilocator/master/database.php');
?>

...no.

 

First, open source is a concept - a license, really - not an implementation. You don't have to host your code on GitHub for it to be open source, and putting it on GitHub doesn't make it open source.

 

Second, GitHub and others are code repositories. You don't keep your code there and then try to run it from there. It's a place you can store your files on the internet. When you want to run them, you download them (in the case of GitHub, using git) and run them. Locally. You could just as well put the files in a .zip on an FTP server and download the code for all it matters.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.