mark103 Posted September 18, 2010 Share Posted September 18, 2010 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 Quote Link to comment Share on other sites More sharing options...
Username: Posted September 18, 2010 Share Posted September 18, 2010 *curious how name is relevant to thread contents Can you explain a bit more? Quote Link to comment Share on other sites More sharing options...
mark103 Posted September 18, 2010 Author Share Posted September 18, 2010 *curious how name is relevant to thread contents Can you explain a bit more? Well, I want to hide the actual url in the config file that I wish to connect to. So, is the code I have posted is the correct source to use or if I have to adjust them? Quote Link to comment Share on other sites More sharing options...
fortnox007 Posted September 18, 2010 Share Posted September 18, 2010 Forget my ignorance, but as long as you don't echo it out, no one will see the stuff in your php unless the server is facked up. Quote Link to comment Share on other sites More sharing options...
mark103 Posted September 18, 2010 Author Share Posted September 18, 2010 Ok please can you post the source that would hide the url similar as my first post? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted September 18, 2010 Share Posted September 18, 2010 Your question is about as clear as mud. What is the purpose of what you're trying to do? Quote Link to comment Share on other sites More sharing options...
mark103 Posted September 18, 2010 Author Share Posted September 18, 2010 My purpose is to protected the site I am connect to, so should I use something like this? <?php $connect = http.www.mysite.com/script.php } Quote Link to comment Share on other sites More sharing options...
litebearer Posted September 18, 2010 Share Posted September 18, 2010 think he wants to keep location of his script from showing in browser Quote Link to comment Share on other sites More sharing options...
mark103 Posted September 18, 2010 Author Share Posted September 18, 2010 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? Quote Link to comment Share on other sites More sharing options...
NLCJ Posted September 18, 2010 Share Posted September 18, 2010 $url = curl_init("yoururl"); curl_exec($url); curl_close($url); Quote Link to comment Share on other sites More sharing options...
litebearer Posted September 18, 2010 Share Posted September 18, 2010 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 Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 19, 2010 Share Posted September 19, 2010 What makes you think that anyone can see the URL in your .php files? Quote Link to comment Share on other sites More sharing options...
mark103 Posted September 19, 2010 Author Share Posted September 19, 2010 $url = curl_init("yoururl"); curl_exec($url); curl_close($url); Is it for hidden the url as similar for mysql?? Quote Link to comment Share on other sites More sharing options...
mark103 Posted September 19, 2010 Author Share Posted September 19, 2010 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? Quote Link to comment Share on other sites More sharing options...
NLCJ Posted September 19, 2010 Share Posted September 19, 2010 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... Quote Link to comment Share on other sites More sharing options...
mark103 Posted September 19, 2010 Author Share Posted September 19, 2010 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? Quote Link to comment Share on other sites More sharing options...
NLCJ Posted September 19, 2010 Share Posted September 19, 2010 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... Quote Link to comment Share on other sites More sharing options...
mark103 Posted September 19, 2010 Author Share Posted September 19, 2010 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. Quote Link to comment Share on other sites More sharing options...
NLCJ Posted September 19, 2010 Share Posted September 19, 2010 Just use include then. Quote Link to comment Share on other sites More sharing options...
mark103 Posted September 19, 2010 Author Share Posted September 19, 2010 Just use include then. Yeah, so is the script are correct? <?php $url = curl_init("yoururl"); curl_exec($url); curl_close($url); } <?php try { include_once('myscript.php'); } Please let me know! Quote Link to comment Share on other sites More sharing options...
NLCJ Posted September 19, 2010 Share Posted September 19, 2010 Try the second one, and if that's not what you want, use the first one. Quote Link to comment Share on other sites More sharing options...
mark103 Posted September 21, 2010 Author Share Posted September 21, 2010 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. Quote Link to comment Share on other sites More sharing options...
Username: Posted September 22, 2010 Share Posted September 22, 2010 l2basicgrammarplz :shrug: Quote Link to comment Share on other sites More sharing options...
mark103 Posted September 22, 2010 Author Share Posted September 22, 2010 Try the second one, and if that's not what you want, use the first one. Can I use both methods to post and get data from php scripts? Quote Link to comment Share on other sites More sharing options...
Rifts Posted September 23, 2010 Share Posted September 23, 2010 I think you are confused if you have this <?php $MYSECRETURL = www.google.com ?> no one can see any of that Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.