Ok well I have tried to read up on the documentation at http://pear.php.net/manual/en/package.database.mdb2 and it's not very useful to someone who only started working in PHP/MySQL about 2 weeks ago!!!

I just need someone to start me off with an example so I can compare and see how much of my code needs to be changed etc....

Here's an example of a page:

Code:
<?php 
ob_start();
require( "header.php" );
?>

<?php
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

session_start();   
$_SESSION['redirect'] = "addpost.php";
require_once("auth.php");

// check levelid is ok for this page
if ($db_level<1) // user doesnt have access
{
die(header("Location: notauth.php"));
}

?>

<h3>Add post!</h3>
<p>Use the form below</p>
<br />

<?php
include("config.php");

$userinfo = mysql_real_escape_string($_COOKIE['my_username']);

$check = mysql_query("SELECT Userid FROM Users WHERE Username = '$userinfo'")or die(header("Location: notloggedin.php"));
$userid=mysql_result($check,$i,"Userid");
if ($userid < 1) {
die("Location: notloggedin.php");
} 
?>

<form name="addpostform" action="postme.php" method="post" onsubmit="return formCheck(this);">
User id: <? echo "$userid"; ?><input type="hidden" name="userid" value="<? echo "$userid"; ?>"><br />
Title: <input type="text" name="title">
<script>
displaylimit("document.addpostform.title","",50)
</script><br /><br />
Category: <select name="category">
<?php

$query="SELECT * FROM Categories";
$result=mysql_query($query) or die( "Unable to do query");

$num=mysql_num_rows($result);

if ($num==0) {
echo "The database contains no categories";
} else {

$i=0;
while ($i < $num) {

$catid=htmlentities(mysql_result($result,$i,"Catid"));
$catname=htmlentities(mysql_result($result, $i, "Catname"));
echo "<option value='$catid'>$catname</option>";

$i++;
}
}

?>
</select>
<br />
Info: <textarea rows="10" cols="40" name="info"></textarea>
<script>
displaylimit("document.addpostform.info","",500)
</script><br />
Location: <input type="text" name="location">
<script>
displaylimit("document.addpostform.location","",50)
</script><br /><br />
Requirements:<br />
<?php

$query="SELECT * FROM Skills";
$result=mysql_query($query) or die( "Unable to do query");

$num=mysql_num_rows($result);

if ($num==0) {
echo "The database contains no skills";
} else {

$i=0;
while ($i < $num) {

$skillid=htmlentities(mysql_result($result,$i,"Skillid"));
$skillname=htmlentities(mysql_result($result,$i,"Skillname"));

echo "<input name='skills[]' type='checkbox' value='$skillid'>$skillname: <textarea wrap=virtual rows='3' cols='30' name='txt[$skillid]'></textarea><br />
(150 characters max)<br />";

$i++;
}

mysql_close();

}

?>
<br />
<input type="Submit" value="Post">
</form>

<?php
require( "footer.php" ); 
ob_end_flush();
?>



Now I am sure there are many things in this code which can be done better - can you please point these out so I can get to fixing ALL of my pages! Mainly I need to know how to begin to start converting this for use with PEAR::MDB2.....

Any ideas: I'm feelin like this at the moment , and it was all going so well ..lol