Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

user and password in file and mysql_connect()
Here's my code:

<?php
$file_pointer_error='Der skete en fejl ved åbning af filen til
initialisering af koder<br>';
$mysql_connect_error='Beklager, der skete en fejl! - prøv igen en
anden gang!<br>(Webmaster må gerne vide, at det var en
<u>mysql_connect-fejl!</u> )';

 $DOCUMENT_ROOT=$HTTP_SERVER_VARS['DOCUME
NT_ROOT'];
$fp=fopen("$DOCUMENT_ROOT/mysql/koder.php","r");
if(!$fp){echo $file_pointer_error; exit;}
$file_user=fgets($fp);
$file_passwd=fgets($fp);
fclose($fp);

$db_oplysninger =
array('db_name'=>'fuk_arrangement','host'=>'localhost','user'=>$file_user,'p
asswd'=>$file_passwd);

$db_conn = mysql_connect($db_oplysninger['host'], $db_oplysninger['user'],
$db_oplysninger['passwd']) or die( $mysql_connect_error);
?>

My file consists of user and password information.
I did echo $db_oplysninger['user'] and  it shows the right letters.

What is wrong here?

Report this thread to moderator Post Follow-up to this message
Old Post
Claus Ladekjær Wilson
10-31-04 08:56 PM


Re: user and password in file and mysql_connect()
Claus Ladekjær Wilson wrote:
> Here's my code:
>
> <?php
> $file_pointer_error='Der skete en fejl ved åbning af filen til
> initialisering af koder<br>';
> $mysql_connect_error='Beklager, der skete en fejl! - prøv igen en
> anden gang!<br>(Webmaster må gerne vide, at det var en
> <u>mysql_connect-fejl!</u> )';
>
>  $DOCUMENT_ROOT=$HTTP_SERVER_VARS['DOCUME
NT_ROOT'];

/* > $fp=fopen("$DOCUMENT_ROOT/mysql/koder.php","r");
> if(!$fp){echo $file_pointer_error; exit;}
> $file_user=fgets($fp);
> $file_passwd=fgets($fp);
> fclose($fp);

wouldn't it be easier to use */

include_once("$DOCUMENT_ROOT/mysql/koder.php");

/* Where the koder.php would look like:
<?PHP
$db_oplysninger = array('db_name'=>'fuk_arrangement',
'host'=>'localhost',
'user'=>'username',
'passwd'=>'thepasswordtouse');
?>
*/

> $db_conn = mysql_connect($db_oplysninger['host'], $db_oplysninger['user'],
> $db_oplysninger['passwd']) or die( $mysql_connect_error);
> ?>
>
> My file consists of user and password information.
> I did echo $db_oplysninger['user'] and  it shows the right letters.
>
> What is wrong here?

As you don't provide with the error message, it's a bit difficult to say wha
t
is wrong, do the following:

1. Check that the case and spelling of both username and password
2. Check that the connection is really made from localhost and not from the
hostname that the machine has (you could add that to the grant list).
3. Check that the mysql server is really running
4. Check that the needed mysql dll is loaded in the php.ini (or else you
don't have mysql support).


//Aho

Report this thread to moderator Post Follow-up to this message
Old Post
J.O. Aho
10-31-04 08:56 PM


Re: user and password in file and mysql_connect()
Thanks for your answer! A great help!

J.O. Aho wrote:

> Claus Ladekjær Wilson wrote: 
>
> /* > $fp=fopen("$DOCUMENT_ROOT/mysql/koder.php","r"); 
>
> wouldn't it be easier to use */
>
> include_once("$DOCUMENT_ROOT/mysql/koder.php");
>
> /* Where the koder.php would look like:
> <?PHP
> $db_oplysninger = array('db_name'=>'fuk_arrangement',
>                          'host'=>'localhost',
>                          'user'=>'username',
>                          'passwd'=>'thepasswordtouse');
> ?>
> */
> 
>
> As you don't provide with the error message, it's a bit difficult to say
> what is wrong, do the following:
>
>   1. Check that the case and spelling of both username and password
>   2. Check that the connection is really made from localhost and not from
>   the
>      hostname that the machine has (you could add that to the grant list).
>   3. Check that the mysql server is really running
>   4. Check that the needed mysql dll is loaded in the php.ini (or else you
>      don't have mysql support).
>
>
>   //Aho


Report this thread to moderator Post Follow-up to this message
Old Post
Claus Ladekjær Wilson
11-01-04 08:56 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP SQL archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:42 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.