Jump to content


Photo

why doesnt this code work??


  • Please log in to reply
2 replies to this topic

#1 alfman05302001

alfman05302001
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 30 March 2006 - 03:04 PM

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

#2 LordStanley

LordStanley
  • Members
  • Pip
  • Newbie
  • 6 posts

Posted 30 March 2006 - 03:13 PM

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
I am available for jobs

My IPB Modifications (8)

#3 alfman05302001

alfman05302001
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 31 March 2006 - 03:56 AM

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..../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....g/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....g/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 ?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users