DamienRoche Posted July 29, 2008 Share Posted July 29, 2008 I am having huge trouble trying to connect to my website through php, then to my database. The database is easy to connect to but I can't figure out how to connect to my website. The reason I'm doing this is because I am looking to protect from sql injection in my forms but the no_escape function seems to be requiring me to connect to my website first. Am I going about it the wrong way? Thanks, Damien. Link to comment https://forums.phpfreaks.com/topic/117150-connecting-to-site-then-databasenot-through-localhost/ Share on other sites More sharing options...
stublackett Posted July 29, 2008 Share Posted July 29, 2008 I am having huge trouble trying to connect to my website through php, then to my database. The database is easy to connect to but I can't figure out how to connect to my website. The reason I'm doing this is because I am looking to protect from sql injection in my forms but the no_escape function seems to be requiring me to connect to my website first. Am I going about it the wrong way? Thanks, Damien. What do you mean by connecting to your website through PHP?? Link to comment https://forums.phpfreaks.com/topic/117150-connecting-to-site-then-databasenot-through-localhost/#findComment-602527 Share on other sites More sharing options...
DamienRoche Posted July 29, 2008 Author Share Posted July 29, 2008 What do you mean by connecting to your website through PHP?? Like when you connect to a database, you connect to localhost. Well I want to connect to my website, but not through the localhost command. Like through an ip. Thing is, if I am connect from elsewhere, then surely I will have to provide login details of the website and NOT the database. I'm totally confused ??? Link to comment https://forums.phpfreaks.com/topic/117150-connecting-to-site-then-databasenot-through-localhost/#findComment-602530 Share on other sites More sharing options...
d.shankar Posted July 29, 2008 Share Posted July 29, 2008 I'm totally confused ??? Dude lol ! I wanna help you out but you are making me LMAO.. Link to comment https://forums.phpfreaks.com/topic/117150-connecting-to-site-then-databasenot-through-localhost/#findComment-602532 Share on other sites More sharing options...
stublackett Posted July 29, 2008 Share Posted July 29, 2008 I'm totally confused ??? Dude lol ! I wanna help you out but you are making me LMAO.. I'm with d.shankar on this...... Your also making me laugh and confusing me ??? Are you on about actually putting files to your website? You'll need FTP to do that (If thats what your on about)? Link to comment https://forums.phpfreaks.com/topic/117150-connecting-to-site-then-databasenot-through-localhost/#findComment-602535 Share on other sites More sharing options...
DamienRoche Posted July 29, 2008 Author Share Posted July 29, 2008 I'm totally confused ??? Dude lol ! I wanna help you out but you are making me LMAO.. I'm with d.shankar on this...... Your also making me laugh and confusing me ??? Are you on about actually putting files to your website? You'll need FTP to do that (If thats what your on about)? Sorry guys, I'm having a hard time explaining it. I just don't understand what I'm talking about lol. Here goes.You know like you connect to a database like this: $DBhost = "localhost"; $DBuser = "wwwdami_new"; $DBpass = "new"; $DBName = "wwwdami_new"; Is there a similar function to connect to a site: $host = "45.153.4778:45" //dummy ip. $siteuser = ; $sitepass = ; If that is a stupid question. How about this. I am trying to use mysql_real_escape_string but I don't have the right privileges. It keeps asking me to connect to the host...I can connect to the database.. I hope someone can decipher my ramblings. Thanks. Link to comment https://forums.phpfreaks.com/topic/117150-connecting-to-site-then-databasenot-through-localhost/#findComment-602540 Share on other sites More sharing options...
samshel Posted July 29, 2008 Share Posted July 29, 2008 by connecting to a "site", you mean connecting to a mysql server on some differnt machine (your server). for that you can use IP as host and username and pass word of MYSQL on your server. Although on your mysql server you will have to add entry in the hosts table in mysql database of the IP of the server you are connecting from. then only it will allow to connect. hope this is what you want.. Link to comment https://forums.phpfreaks.com/topic/117150-connecting-to-site-then-databasenot-through-localhost/#findComment-602545 Share on other sites More sharing options...
d.shankar Posted July 29, 2008 Share Posted July 29, 2008 Actually you can use cURL to do this. www.php.net/curl Link to comment https://forums.phpfreaks.com/topic/117150-connecting-to-site-then-databasenot-through-localhost/#findComment-602547 Share on other sites More sharing options...
samshel Posted July 29, 2008 Share Posted July 29, 2008 CURL ?? he wants to connect to a MySQL server on some other machine...i dont know how CURL could be useful here. Sorry if i got you completely wrong.. Link to comment https://forums.phpfreaks.com/topic/117150-connecting-to-site-then-databasenot-through-localhost/#findComment-602549 Share on other sites More sharing options...
TempleDMDKrazd Posted July 29, 2008 Share Posted July 29, 2008 well, if its on a shared hosting account, then by default you can only connect on a local host, but the hosting provider let's you have remote connection also. if your hosting provider offers you cpanel then do the following: 1) log into cpanel 2) click on "mySQL databases" 3) scroll down to "access hosts" 4) either type in your IP address or type in with wildcards such as "%" (be warned of the wildcards though if you set it as all wildcards anyone can hacked your mySQL database) enjoy!! Link to comment https://forums.phpfreaks.com/topic/117150-connecting-to-site-then-databasenot-through-localhost/#findComment-602581 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.