please help noob i dont know how to connect mysql to php

Problems with the Windows version of XAMPP, questions, comments, and anything related.

please help noob i dont know how to connect mysql to php

Postby hi5 » 09. May 2010 02:38

i have download xampp and i dont know how to connect mysql to php. i dont know were to save the file that i have create.
so i have been reading some tutorial about conecting my mysql to php and iam not sure were to put these file.
So, my question is is the code right and were do i save this files. :| :cry:

i have create 3 files.

1st file named connection.php

Code: Select all
<?php
$dbhost = 'localhost';
$db      = 'info';
$dbuser = 'root';
$dbpass = 'trun';                         // password not real  so people cant hack it

}

?>


second file name is index.php
i dont know were to save this file
Code: Select all
<?php

   include ('connection.php');
   
   $connect = mysql_connect($dbhost, $db_user, $db_pass);
if(!connect){

   die ( "could not coect tothe database: <br />". mysql_error());
}

?>



3rd file data.php
i dont know were to save this file
Code: Select all

$db_select=mysql_select_db($info);
if(!$db_select)
{
   die ("could not select the database: <br />". mysql_error());
}
hi5
 
Posts: 6
Joined: 09. May 2010 02:18

Re: please help noob i dont know how to connect mysql to php

Postby JonB » 09. May 2010 02:49

If you install XAMPP, "it" will make all the connections for you.

That will install Apache, MySQL, PHP, Perl and FileZilla FTP server.

So - Install XAMPP, and then use the Control Panel to start Apache and MySQL.

then look at the tutorials about XAMPP on this page
http://www.apachefriends.org/en/xampp-windows.html

Good Luck
:roll:
Last edited by JonB on 09. May 2010 02:51, edited 1 time in total.
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: please help noob i dont know how to connect mysql to php

Postby hi5 » 09. May 2010 02:51

so do i need all those code?? because i want to be able to create a database driving web site
hi5
 
Posts: 6
Joined: 09. May 2010 02:18

Re: please help noob i dont know how to connect mysql to php

Postby JonB » 09. May 2010 02:53

No - you don't need that code you wrote. All the hard wiork has been done

read the tutorials
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: please help noob i dont know how to connect mysql to php

Postby hi5 » 09. May 2010 02:56

yea i cant find the tutorials all i find is a bunch of question
hi5
 
Posts: 6
Joined: 09. May 2010 02:18

Re: please help noob i dont know how to connect mysql to php

Postby JonB » 09. May 2010 03:09

XAMPP is really an installer for a group of programs. Apache PHP, Perl MySQL and so on.

So the tutorials are about running XAMPP. To learn how to develop a database driven site is not the purpose of those tutorials. They are there to make XAMPP work.

In your browser type in: http://localhost

you should find that XAMPP is installed. There is a huge amount of info about how all the parts are configured when you launch XAMPP on your machine.

THEN you will be ready to start trying to apply knowledge gained from subject speicific tutorials to build a web site.

:roll:
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: please help noob i dont know how to connect mysql to php

Postby hi5 » 09. May 2010 03:10

thank, for your help
hi5
 
Posts: 6
Joined: 09. May 2010 02:18

Re: please help noob i dont know how to connect mysql to php

Postby MC10 » 24. May 2010 03:31

By the way, $db_user and $db_pass in index.php are undefined, as they are $dbuser and $dbpass in your connection.php.
MC10
 
Posts: 148
Joined: 20. February 2010 20:13


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 63 guests