Closed Thread Icon

Preserved Topic: variable scope (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12030" title="Pages that link to Preserved Topic: variable scope (Page 1 of 1)" rel="nofollow" >Preserved Topic: variable scope <span class="small">(Page 1 of 1)</span>\

 
evilclown01
Nervous Wreck (II) Inmate

From:
Insane since: Dec 2001

posted posted 02-03-2002 06:11

1) Is there a way I can define $db so I can use it in any of my functions? Otherwise I have to write same line in both functions.

code:
$db = mysql_connect("localhost", "root");


2) Is there any security issues with using root?

evilclown01

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 02-03-2002 06:56

Basically
global $db;

will work inside the function.

Check this page out http://www.php.net/manual/en/language.variables.scope.php

Yes others may have full access to your db.



:[ Computers let you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila. ]:

evilclown01
Nervous Wreck (II) Inmate

From:
Insane since: Dec 2001

posted posted 02-03-2002 07:05
quote:
Yes others may have full access to your db.


You mean other functions, not people?(just wondering because I thought I saw a security thread that said do not use global variables)

evilclown01

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 02-03-2002 08:22

You shouldn't use "root" user to connect to MySQL database. You should also define a password for that user, since you're connect to your database as root user (which has admin privileges) and you don't have a password defined. You should define password for root, and also other user account which can only access database that you're using...


evilclown01
Nervous Wreck (II) Inmate

From:
Insane since: Dec 2001

posted posted 02-03-2002 18:37

How do I define a password for root? (this is on windows)

How do I create another user? Then how do I give it access to the database?

So there is not a way for someone to see my source and find out my username and password?

So are global variables ok to use if you give them a value in your script so someone can't do: http://www.somewhere.com/index.php?var=value

evilclown01

[This message has been edited by evilclown01 (edited 02-03-2002).]

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 02-03-2002 23:58

I suggest that you take a look at MySQL documentation where you'll find answers to all your question that you may have about MySQL: http://www.mysql.com/documentation/index.html

If you define values of global variables in your script, they should be safe. BTW I suggest you to also take a look at constants: http://www.php.net/manual/en/language.constants.php




[This message has been edited by mr.maX (edited 02-04-2002).]

lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 02-04-2002 15:01
quote:
How do I define a password for root? (this is on windows)

How do I create another user? Then how do I give it access to the database?



use a visual tool such as MySqlFront, this have a dialog for adding and removing users w/ priviliges visually (under Tools/Users menu)

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 02-04-2002 19:55

There shouldn't be an issue with global vars They are only related to scope

The issue with the root db access it that MySQL is a server. You can access it as if it were a web page from remote hosts without the appropriate security in place.



:[ Computers let you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila. ]:

jiblet
Paranoid (IV) Inmate

From: Minneapolis, MN, USA
Insane since: May 2000

posted posted 02-05-2002 01:25

By the way, you only need that $db variable if you are maintaining connections to multiple databases. mysql_query uses the default connection if only one connection is open.

-jiblet

« BackwardsOnwards »

Show Forum Drop Down Menu