djmartins Posted October 31, 2011 Report Share Posted October 31, 2011 (edited) Ja es esmu izveidojies uz bemzaksas hostinga datubāzi ar parametriem: $host: fdb3.runhosting.com $user: 123 $password: 123 Pati mājas lapa atrodās uz cita hostinga, kā īsti varu pieslēgties šai konkrētajai datubāzei, kura atrodās, savukārt, uz cita hostinga? Izmantojot zemak redzamo kodu, parāda kļūdas paziņojumu: A connection attempt failed because the connected party did not <?php $host= 'fdb3.runhosting.com'; $user='123'; $password='123'; $link = mysql_connect('$host', '$user', '$password'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_close($link); ?> Edited October 31, 2011 by djmartins Quote Link to comment Share on other sites More sharing options...
briedis Posted October 31, 2011 Report Share Posted October 31, 2011 (edited) Virs mysql_connect izvadi: echo '$password'; echo '$host'; echo '$user'; Varbūt sapratīsi, kur kļūda :p Edited October 31, 2011 by briedis Quote Link to comment Share on other sites More sharing options...
CyHex Posted October 31, 2011 Report Share Posted October 31, 2011 Briedi, esi žēlīgs! :) Vienkāršāk tak būtu pateikt mysql_connect($host, $user, $password) tobiš bez apostrofiem. Quote Link to comment Share on other sites More sharing options...
Swear Posted November 1, 2011 Report Share Posted November 1, 2011 $link = mysql_connect('$host', '$user', '$password'); parastās quotes neizvada mainīgo vērtības, aizvāc '. un nedomāju ka arī tas būs risinājums. hostingiem parasti ugusmūris nelaiž klāt pie mysql no ārpuses. Quote Link to comment Share on other sites More sharing options...
nikidijs Posted November 1, 2011 Report Share Posted November 1, 2011 ...un nedomāju ka arī tas būs risinājums. hostingiem parasti ugusmūris nelaiž klāt pie mysql no ārpuses. Tieši tā. Es ar vienreiz kautko tamlīdzīgu biju mēģinājis un nefiga. Beigās vai nu lapu hosto tur pat, vai db pārnes uz citurieni. Quote Link to comment Share on other sites More sharing options...
briedis Posted November 1, 2011 Report Share Posted November 1, 2011 Izmanto SQLite, kas ir datubāze 1 failā. Tandēmā ar kādu foršu ORM'u (piemēram, RedBean) strādāt var bez problēmām! 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.