Jump to content

Archived

This topic is now archived and is closed to further replies.

alfman05302001

why doesnt this code work??

Recommended Posts

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:

<?php

require ("/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 connect

The error is as follows:
Parse error: parse error, unexpected T_VARIABLE in /home/oalodge/public_html/mysql_test/connection.php on line 6

Share this post


Link to post
Share on other sites
require ("/mysql_test/dbConfig/db_config.php")

thats your problem. it should be

require ("/mysql_test/dbConfig/db_config.php");

you forgot the ending semi-colon

Share this post


Link to post
Share on other sites
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 3

Warning: 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 3

Fatal 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 3


What is .:/usr/lib/php:/usr/local/lib/php ?

Share this post


Link to post
Share on other sites

×

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.