Skip to content
WJunction - Webmaster Forum

replacing mysql $link supplied data, a question?

Status
Not open for further replies.

XSLTel

Banned
Banned
876
2010
225
Hello,

most of you know that php is using
Code:
$link = mysql_connect('localhost', $mysql_user, $mysql_pass);
to connect to mysql databases.

I want to do something like replacing those data after they are executed (I mean after variables getting replaced with real values) I want to change the real values.

to be more specific I want to change the $mysql_user after it gets replaced by variable value.

or forcing a php script to use 1 user and only 1 user with script(s) and drop the above mentioned variables

may be its not possible but was just wondering if anyone has an idea about that.

and please understand I don't know a lot in php and I didn't used google yet so don't judge me for a noob question

Highest Regards
Mohammed H
 

10 comments

no Lock Down I didn't meant that but thanks for reply

below example can make my request clearer :

PHP:
$mysql_user = "root";
$mysql_pass = "rootpassword"

now after it gets executed
PHP:
$link = mysql_connect('localhost', $mysql_user, $mysql_pass);

by default the code will resulted in this
PHP:
$link = mysql_connect('localhost', 'root', 'rootpassword');

I want to change the above resulted code with another username (root) only username without touching the variables mentioned above :P
 
hmm i still don't see what the problem is and what you are trying to achieve

mysql_connect(); is a function that takes 3 arguments, server_ip, username and password . now you can write those details directly when you call that function or you can use variables to store those mysql login values to it and instead place the variable names there.
 
php had to be running in safe mode to be able to override mysql options with the ones in php.ini file. That is not a good solution for this problem trough.
 
Ah guys, He wants to change the value of username and password once they're substituted in the command!

So 'root' | 'password' has to be replaced with 'rooter' | 'new-pass'.

He's trying to build an interactive client based app(I guess), And wants the logins to change :/

@OP, Is this correct? If yes, Then why don't you take the values from user rather than trying to change them in mid program?
 
@NEC yes I've looked at sql.safe_mode but it won't work in most scripts.

@V3g3t4 exactly that is what I need and I must change them in the mid of application it can fool a lot of script kiddies (they will see default value in config.php but another values will be used when the program executed) that's the main idea.
 
You could always keep the config.php settings and dureing the middle of the app make it switch to the new sql settings makeing the first sql settings dummy settings trying to fool the hacker that those are the real settings...

Or make a series of sql connections to switch them... Its a hard concept with php
 
The easiest way would be to leave the fake info in the config.ini and hard code the real info in the function that checks the connection.

Or you can have the real information in a file that is not accessible to www an get it during the connection function.
 
Last edited:
Status
Not open for further replies.

About the author

XSLTel
Banned · Joined
876
Messages
225
Reactions
43
Points
Grow your business

Advertise on WJunction

Connect with an established international community of webmasters, hosting providers, developers and online entrepreneurs.

  • Premium & Premium+ Sticky
  • Dedicated section banners
  • Site-wide banner advertising
Explore advertising options
Back
Top Bottom