Jump to content

why doesnt this code work??


alfman05302001

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
Link to comment
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 ?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.