Complete Beginner with MySQL

WarrenS

Free Member
Mar 5, 2006
17
0
Birmingham, UK
In the famous word of that faulty towers legend... "I know naaathing!"

Can anyone send me in the right direction please. I have just spent the last week of my life learning Dreamweaver and now wish to have a open source db to link my forms to...

<Trapped by my laptop in Brum>
 
I seem to remember web monkey being of great use when I first started out.

There are lots of tutorials on the web jsut start from teh basics and work yoru way out, it will be a long frustrating journey but stick at it. I was fortunate in that I had a php/mysql mentor to guide me through but if you get stuck theres enough of us on here to dig you out.

Gary
 
Upvote 0

DavidHorn

Free Member
Jan 3, 2006
289
30
52
Northern Ireland
If you use rollyo.com, I created a search roll called 'Web Dev Forums' which searches a number of PHP (and other) forums. (Assuming, which may not be the case, that you're using PHP to access MySQL)

Rollyo is an excellent short cut around the web!

If you don't use rollyo, it includes (among others) - phpbuilder.com, php.net, webmasterworld.com, and phpfreaks.com

Good luck!
 
Upvote 0

WarrenS

Free Member
Mar 5, 2006
17
0
Birmingham, UK
OMG!! i have a headache.... I've got Mysql and php on my machine now... but i am confused, do i need apache 1.3 as well? I have created my database but i currently have no idea how to start putting information in. I cant seem to get my host, username and password right in the php so i can link up. I'll have another bash...

Just thought i'd share my pain with you all. I'm sure it will be worth it in the end.
 
Upvote 0
C

climbingmerlin

I know what you mean when you start learning something like this. You will need either apache web server (my choice) or if you are developing on windows then there is Personal Web Server (PWS) or IIS, to 'serve' you PHP & HTML pages.

To connect to Mysql via PHP all you need to do is add the following line to the start of you php script mysql_connect("serverlocation","username","password","databasename")

or mysql_pconnect("serverlocation","username","password")
mysql_select_db("databasename")

Hope this helps
 
Upvote 0
Hi Warren heres a tip for you to save a later headache.

There will be some things such as db connection and functions that need to be called on every page so rather than writing it into every page why not get the php to drag it in for you and then should something change you only need to change one file.

There are 2 ways to do this but personally I use the 'include' function and it works thus.

Set up a file called incConfig.php. then in that file you can put all youu configurations:

Like merlin has put above.

// set here mysql options
$mysqlip='localhost';
$mysqluser='username';
$mysqlpass='password;
$mysqldbname='databsename';


// do not change anything below here
$db = mysql_connect($mysqlip, $mysqluser,$mysqlpass);

if (!$db)
echo "Error: Could Not Connect to mySQL database. Please check Address/User/Pass information in Config File.
";
else
if (!mysql_select_db($mysqldbname,$db))
echo "Error: Could not Select mySQL database. Please Check database Name in Config File.
";

This will then do all your connection business

Then where ever you need to call this file just put:

<? include("incConfig.php"); ?> at the top and it will include that file.

Then when ever you need to use the database you are already connected and all you need to do is as follows for example:

$result=mysql_query("SELECT * FROM yourtable WHERE memberid='2' LIMIT 1",$db);
$myrow=mysql_fetch_array($result);

NB note the $db from the include file.

This is also great for navigation systems that appear on every page and also remember you can include files within include files etc.

I hope this is if help to you

Gary
 
Upvote 0

Latest Articles