View Full Version : Complete Beginner with MySQL
WarrenS
14th March 2006, 07:21
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>
mattk
14th March 2006, 07:29
Have a look at thiis bad boy PHP/MySQL Tutorial (http://www.webmonkey.com/webmonkey/programming/php/tutorials/tutorial4.html)
creospace
14th March 2006, 07:39
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
climbingmerlin
14th March 2006, 08:23
For reference for php and mysql I also use http://www.phpfreaks.com, lots of tutorials and code snippets. Was a life saver when writing some php applications.
WarrenS
14th March 2006, 08:32
Brilliant... Pad the walls, lock the doors and ignore the screams of pain... I'm going in!
DavidHorn
14th March 2006, 09:39
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!
WarrenS
14th March 2006, 22:45
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.
climbingmerlin
15th March 2006, 06:32
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
creospace
15th March 2006, 06:52
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