DB Questions


#1

Greetings… i have two question…

Im making my index.php access the login.php and the login.php access the config.php to get serverip and user/password to connect to the database… but i got this error each time i try to login:

Warning: main(config.php) [function.main]: failed to open stream: No such file or directory in /home/.pearlite/vilela/homealog.com/login.php on line 2

Warning: main(config.php) [function.main]: failed to open stream: No such file or directory in /home/.pearlite/vilela/homealog.com/login.php on line 2

Fatal error: main() [function.require]: Failed opening required ‘config.php’ (include_path=’.:/usr/local/lib/php’) in /home/.pearlite/vilela/homealog.com/login.php on line 2

my config.php as:

<? $dbhost= '127.0.0.1'; $dbuser= 'douthinkimcrazyenoughtogiveyouthis?'; $dbpass= 'douthinkimcrazyenoughtogiveyouthis?'; $lochost= '127.0.0.1'; $database = 'douthinkimcrazyenoughtogiveyouthis?'; $msconnect=mssql_connect("$dbhost","$dbuser","$dbpass"); if ($msconnect <= 0){die (" We are currently under development! try again later.");exit();} $msdb=mssql_select_db("$database",$msconnect); ?>

help meeeeeee :stuck_out_tongue:

oh… my other question was… can i connect to my DB via Navicat? if yes how?

Thanks for all ur support


#2

If this is a common application you are running, it would help if you told us what it is and where it can be found on the web. If it is something your wrote, it would help a lot if we could at least see the code where the error was generated. :wink:

That said, your error messages are pretty straight-forward: Line 2 of login.php can’t find and open config.php. You need to inpspect the code in that line, and either move your config file into the appropriate directory so it can be found, or change that line to so that it will find the file.

One another note, you will never get connected to a MySQL server on Dreamhost with the code in your config file even if your login.php manages to get it properly loaded.

Your code is trying to connect to a Micros*ft SQL server on “localhost” Dreamhost does not support mssql server, and you will not be able to specify a MySQL host as “localhost” on Dreamhost. I suggest you read the Dreamhost Wiki on using MySQL, and try again. :wink:

Oh yeah, and your second question- If you have your MySQL database properly setup via the control panel, and have the user accessing the database configured to be allowed to access the database from the IP address of the computer that is running Navicat, there is no reason why you should not be able to use it with your Dreamhost database. You enable the IP address for the user from the Control Panel–>Goodies–>ManageMySQL screen. Just click on the user name, and add the appropriate IP address where instructed by the screen that appears.

–rlparker


#3

humm well im making this script part by part… getting codes from internet and matching each other…

the 2nd line of login.php is:

line 1 <?php
line 2 require(“config.php”); <- (should i link like “www.myhost.com/config.php”?)

hummm what is the best way to make it work via mysql then?
:\ im kinda noob with scripting my thing is webdesign not mastering hehe

Thanks Navicat really helps :stuck_out_tongue:

Thanks for all your support and sorry for botter u


#4

will this help?

$connect=MYSQL_CONNECT($dbhost,$dbuser,$dbpass) or die (“Server under Maintnence”);
MYSQL_SELECT_DB($dbname) or die (“Server under Maintnence”);

$get_config_data=“SELECT online FROM characters WHERE online>0”;
$config_data=MYSQL_QUERY($get_config_data);
$config[‘num_online’]=mysql_num_rows($config_data);


#5

well… i tested my script under easyphp program at my home and everything worked well… whats wrong with it then? why does it says cant find config.php? is it because is being runned under linux and i need to locate the config by other ways? :\


#6

There is no way I can keep up with your posts, as you continue to post replies to yourself before anyone can answer your posts :wink: .

While I am willing to help, you need to help yourself to some degree. The questions you are asking lead me to believe that you need to take a deep breath, and spend a few hours with a good “Beginning PHP” and “Using MySQL with PHP” book or tutorial. Once you have done that, learning to “include” your config file, and set up a connection to your database will probably be trivial for you. Fortunately, there are very good tutorials on the web that are free. Just Google for “beginning PHP”, etc. and you will find lot’s of information.

I happen to like phpbuilder,net and codewalkers.com for tutorials, and while there is some “advanced” stuff there, there is a lot for beginners.

I’m sorry I can’t “interactively” teach you PHP on the forum (there just is not time), but I remain happy to answer a question if you run into a specific problem, or point you to a resource that might help - I just can’t go through your code, line by line, to help you “write” your application.

Your first problem is to succesfully include your config file contents in your login.php file. You can accomplish that using the include() or the require() fuctions. W3 Schools has an excellent beginning tutorial on include() require() fuctions, with many examples.

If you thoroughly review that tutorial, you should understand how to do this; it explains it far better than I could in this post. :slight_smile:

After you get that resolved, you need to use the control panel at Dreamhost to create a MySQL database. In doing that you will create a “host”, a “database”, a “user”, and a “password”. Using these, with a tutorial on how to connect to a MySQL database using PHP, will be your next step.

Don’t be discouraged, and don’t get impatient. Sometimes it can be hard to learn something, there really isn’t a way to do this kind of stuff on the web without that investment of time. Good Luck!

–rlparker


#7

sorry about the multiple posting hehe

well thanks for all your support and for the tutorial!

Nah i never give up learning… its 4 am here and i could be playing or with my wife sleeping… but i love to learn! i can’t avoid what i feel :stuck_out_tongue:

thanks again


#8

the problem was the config file had *.PHP instead of *.php

stupid things…

Thank you all for your support


#9

Good Deal! Keep at it, and you will get there. :slight_smile:

–rlparker