[PHP-DB] problem with functin newbie please help

2001-04-29 Thread Greg Kelly

I have a function that I have defined in a filed called config.php. name of
function is dbconnect() when I go to call the function I get a
Parse error: parse error in /home/test/public_html/include/config.php on
line 9

Fatal error: Call to undefined function: dbconnect() in
/home/test/public_html/login.php on line 5

Can some please tell me what i am doing wrong ?

Thank You


index.php
?php
require(include/config.php);
include(include/register.php);
include(include/login.php);
dbconnect();

?

config.php
?php
$boardurl = /var/www/html/contest;
$hostname = localhost;
$user = test;
$password = test;
$database = test;
$boardname= test

function dbconnect() {
global $hostname, $user, $password, $database;
mysql_connect($localhost,$user,$password)
or die (Unable to connect to MYSQL SERVER);
mysql_select_db($database)
or die (Unable to connect to database please try back later);
}
?



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] problem with functin newbie please help

2001-04-29 Thread Beau Lebens

also, on line 11 you use a variable called $localhost, i think you mean
$hostname, which has the value localhost :) that won't help since it will
pass a null value and mysql_connect will bork at having too few parameters.

and you need to assign your mysql connection to a variable, so that you can
use it in other functions, for example

$connection = mysql_connect($db_location,$db_username,$db_password);
mysql_select_db($db_name, $connection);

otherwise mysql can get lost as to which database connection you are talking
about (if you ever use more than one)

HTH

Beau

// -Original Message-
// From: Tyrone Mills [mailto:[EMAIL PROTECTED]]
// Sent: Sunday, 29 April 2001 11:35 PM
// To: Greg Kelly; [EMAIL PROTECTED]
// Subject: RE: [PHP-DB] problem with functin newbie please help
//
//
// Hi Greg,
//
// In config.php, line 6 needs a semi-colon on the end. Try that
// and see if it
// does the trick.
//
// Tyrone
//
// -Original Message-
// From: Greg Kelly [mailto:[EMAIL PROTECTED]]
// Sent: Sunday, April 29, 2001 11:28 AM
// To: [EMAIL PROTECTED]
// Subject: [PHP-DB] problem with functin newbie please help
//
//
// I have a function that I have defined in a filed called
// config.php. name of
// function is dbconnect() when I go to call the function I get a
// Parse error: parse error in /home/test/public_html/include/config.php on
// line 9
//
// Fatal error: Call to undefined function: dbconnect() in
// /home/test/public_html/login.php on line 5
//
// Can some please tell me what i am doing wrong ?
//
// Thank You
//
//
// index.php
// ?php
// require(include/config.php);
// include(include/register.php);
// include(include/login.php);
// dbconnect();
//
// ?
//
// config.php
// ?php
// $boardurl = /var/www/html/contest;
// $hostname = localhost;
// $user = test;
// $password = test;
// $database = test;
// $boardname= test
//
// function dbconnect() {
// global $hostname, $user, $password, $database;
// mysql_connect($localhost,$user,$password)
// or die (Unable to connect to MYSQL SERVER);
// mysql_select_db($database)
// or die (Unable to connect to database please try back later);
// }
// ?
//
//
//
// --
// PHP Database Mailing List (http://www.php.net/)
// To unsubscribe, e-mail: [EMAIL PROTECTED]
// For additional commands, e-mail: [EMAIL PROTECTED]
// To contact the list administrators, e-mail: [EMAIL PROTECTED]
//
//
//
// --
// PHP Database Mailing List (http://www.php.net/)
// To unsubscribe, e-mail: [EMAIL PROTECTED]
// For additional commands, e-mail: [EMAIL PROTECTED]
// To contact the list administrators, e-mail: [EMAIL PROTECTED]
//


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]