Jump to content

Create config php to hide url


mark103

Recommended Posts

Hi guys,

 

I want to set up a php script to connect to php sources on another site, something is like this:

 

 

<?php

$mysql = array
(
    'host' => 'http://www.mysite.com/myscript.php',
} 

 

 

 

<?php

try
{
    include_once('mysql_connect.php');
}

 

 

Is the source is correct to use that I want to read the script while hide the actual url in the config php script??

 

 

 

Thanks,

Mark

Link to comment
Share on other sites

think he wants to keep location of his script from showing in browser

 

are you being a fool? I want to keep the url address that I wish to connect to to be hidden so I could connect it to the mysql database which the db details will be inside that script. Now understand?

Link to comment
Share on other sites

are you being a fool? I want to keep the url address that I wish to connect to to be hidden so I could connect it to the mysql database which the db details will be inside that script. Now understand?

 

perhaps a well thought out first question would aid people in their attempts to HELP YOU

Link to comment
Share on other sites

What makes you think that anyone can see the URL in your .php files?

 

It isn't, it will be in the myscript.php so no body can see the url, only myscript.php, just like this:

 

<?php

try
{
    include_once('myscript.php');
}

 

 

The url will be hidden in that file. Why do you want to know for and what it is important to know?

Link to comment
Share on other sites

Try to explain it more. And give details! We're all trying to help you but no-one understands you...

Does the site that you want to have in your PHP script stay at a different server, or your server? What does it do and WHAT do you want to achieve. We know that you want to hide something, but have no idea what. If you mean that they can't see the file when you include it: No they can't, PHP is a server-side language so it makes the whole page at the server and then parses it to the user.

 

Have you ever thought about TRYING any of those suggestions? And then look for yourself if it is the thing that YOU want?! We can keep giving suggestions while we don't know what you want, but in this way we get frustrated and you won't get your answer. Try something...

Link to comment
Share on other sites

Try to explain it more. And give details! We're all trying to help you but no-one understands you...

Does the site that you want to have in your PHP script stay at a different server, or your server? What does it do and WHAT do you want to achieve. We know that you want to hide something, but have no idea what. If you mean that they can't see the file when you include it: No they can't, PHP is a server-side language so it makes the whole page at the server and then parses it to the user.

 

Have you ever thought about TRYING any of those suggestions? And then look for yourself if it is the thing that YOU want?! We can keep giving suggestions while we don't know what you want, but in this way we get frustrated and you won't get your answer. Try something...

 

What more do you want to know and what got to do with you? I want to hide the url same as mysql config, which it would be like this:

 

 

<?php

$mysql = array
(
    'host' => 'localhost',
    'user' => 'mysql_user',
    'pass' => 'password',
    'db' => 'database_name'
);

if(!isset($mysqlconn) || !is_resource($mysqlconn))
{
    $mysqlconn = mysql_connect($mysql['host'], $mysql['user'], $mysql['pass']);
    if(!$mysqlconn)
    {
        throw new Exception ('Unable to connect to MySQL host.');
    }

    if(!mysql_select_db($mysql['db']))
    {
        throw new Exception ('Unable to select database.');
    }
} 

 

 

 

<?php

try
{
    include_once('mysql_connect.php');
}
catch(Exception $e)
{
    // There was an error connecting to the database.  Now, just show an error; however,
    // You probably want to die() or exit() after echoing the error.
    echo '<p>' . $e->getMessage() . '</p>';
} 

 

 

The database details will be store in the mysql_connect.php, so no one can see it until they catch my details to get access to my server with the host name, username and password. You see the db details in the mysql_connect.php, I want it to hide for url instead of mysql.

 

Hope you get this now?

Link to comment
Share on other sites

First, if users go directly to the mysql_connect.php they will get a blank page since the script doesn't return any information.

Second, why can't you use incude('fileyouwant.php'); into your script, they won't be able to see what file you've included...

Link to comment
Share on other sites

First, if users go directly to the mysql_connect.php they will get a blank page since the script doesn't return any information.

Second, why can't you use incude('fileyouwant.php'); into your script, they won't be able to see what file you've included...

 

I am not going to use mysql_connect.php, only fileyouwant.php. I want to use it on my own site and another site, and it will returns the information if I connect the script on my another host before connect to the mysql database.

 

I guess that it should be possible similar as the previous post I have already posted.

Link to comment
Share on other sites

Try the second one, and if that's not what you want, use the first one. :)

 

 

Hmmmm, but I have got question: will the script post the data and receive them while I uses both methods??

 

And could you please post the try\catch errors for both scripts??

 

 

Thanks alot.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.