alfman05302001 Posted March 30, 2006 Share Posted March 30, 2006 I am trying to connect to a MySQL db using an include statement to help secure the connection. My connection variables are as follows:<?php$db_server = "localhost";$database = "oalodge_plst1";$db_table = "user";$db_user = "oalodge_dbUser";$db_password = "**********";?>And my connection statement looks like:<?phprequire ("/mysql_test/dbConfig/db_config.php")//require ("$_SERVER["DOCUMENT_ROOT"]."/dbConfig/db_config.php");$dbh = mysql_connect ($db_server, $db_user, $db_password) or die ('I cannot connect to the database because: ' . mysql_error());mysql_select_db ("oalodge_plst1");?>But it will not let me connectThe error is as follows:Parse error: parse error, unexpected T_VARIABLE in /home/oalodge/public_html/mysql_test/connection.php on line 6 Quote Link to comment Share on other sites More sharing options...
LordStanley Posted March 30, 2006 Share Posted March 30, 2006 require ("/mysql_test/dbConfig/db_config.php")thats your problem. it should berequire ("/mysql_test/dbConfig/db_config.php");you forgot the ending semi-colon Quote Link to comment Share on other sites More sharing options...
alfman05302001 Posted March 31, 2006 Author Share Posted March 31, 2006 So the initial part of my script is still the same (where I define the variables for the require statement), but my script has changed to the following:<?php require ("http://wwww.oalodge.org/mysql_test/dbConfig/db_config.php"); //require ("$_SERVER["DOCUMENT_ROOT"]."/dbConfig/db_config.php""); $dbh = mysql_connect ($db_server, $db_user, $db_password) or die ('I cannot connect to the database because: ' . mysql_error()); //mysql_select_db ("oalodge_plst1");?>I am now reciving the following errors:Warning: main() [function.main]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/oalodge/public_html/mysql_test/connection.php on line 3Warning: main(http://wwww.oalodge.org/mysql_test/dbConfig/db_config.php) [function.main]: failed to open stream: Success in /home/oalodge/public_html/mysql_test/connection.php on line 3Fatal error: main() [function.require]: Failed opening required 'http://wwww.oalodge.org/mysql_test/dbConfig/db_config.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/oalodge/public_html/mysql_test/connection.php on line 3What is .:/usr/lib/php:/usr/local/lib/php ? 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.