So this:

        function close() {
						// this is to close the connection to the DB
							 if(!mysql_close()) {
										return 0;
								} end if
								//then we return success
										return 1; 
			 	}//end close

Or this?

        function close() {
						// this is to close the connection to the DB
							 mysql_close()
}//end close

    How about this for the query?

            function query($sql) {
    					if($retVal = mysql_query("SELECT my_col FROM my_tbl") {
    							return $retVal;
    						} else {
    						//class variables and function calls are always proceeded with $this->
                    //from inside their own class.
                  $this->error = "dbAccess num_rows error: " . mysql_error() . " in " . __FILE__ . " on line " . __LINE__;
                    //we cannot return 0 because their might not be any rows in which case this 
                    //would return 0 on a success. 
    								return -1;
    						} //end if						
    				}//end query
    

    I know I have to replace both my_col and my_tbl but don't know with what! I have 2 tables in the DB, bills and paid.

      the first one, except that you're not setting this->error in the fail so how is a programmer supposed to use this to report their error?

        Originally posted by drawmack
        the first one, except that you're not setting this->error in the fail so how is a programmer supposed to use this to report their error?

        So like this?

        				function close() { 
                   // this is to close the connection to the DB 
                   if(!mysql_close()) { 
        					 //we set our internal error code and return failure instead of dying 
        					 			$this->error = __FILE__ . " on line " . __LINE__ . "Could not close: " . mysql_error();  
        return 0; } end if //then we return success return 1;
        }//end close

          yeah that's it now onto the remaining functions

            How about this for query?

                    function query($sql) {
                       // this is to query the DB tables 				
            					if($retVal = mysql_query("SELECT my_col FROM my_tbl") {
            							return $retVal;
            						} else {
            						//class variables and function calls are always proceeded with $this->
                            //from inside their own class.
                          $this->error = __FILE__ . " on line " . __LINE__  . "Could not query: " . mysql_error();
                            //we cannot return 0 because their might not be any rows in which case this 
                            //would return 0 on a success. 
            								return -1;
            						} //end if						
            				}//end query
            

            What do I replace my_col and my_tbl with ? I think I need to assign a variable, but where do I get the variable from ?

            The DB contains 2 tables, bill and paid.

              you are passing in the sql statement as a parameter

              so you have

              mysql_query($sql) as the appropriate way to call the function

              that should clean that function up.

                function query($sql)

                in this line of code $sql is a parameter. In other words it is a string of text that gets passed into the function

                If you don't know what sql is or how to write it you may wish to search on google for a basic sql tutorial.

                in your code from the manual you have mysql_query("select my_col from my_table") we don't want that as it embeds the sql statement directly into the call and we want to use our parameter so we want to use mysql_query($sql)

                does that make sense?

                  So basicaly I need to remove:

                          function query($sql) {
                             // this is to query the DB tables 				
                  					if($retVal = mysql_query("SELECT my_col FROM my_tbl") {
                  							return $retVal;
                  						} else {
                  						//class variables and function calls are always proceeded with $this->
                                  //from inside their own class.
                                $this->error = __FILE__ . " on line " . __LINE__  . "Could not query: " . mysql_error();
                                  //we cannot return 0 because their might not be any rows in which case this 
                                  //would return 0 on a success. 
                  								return -1;
                  						} //end if						
                  				}//end query
                  

                  and replace it with :

                          function query($sql) {
                             // this is to query the DB tables 				
                  					if($retVal = mysql_query($sql) {
                  							return $retVal;
                  						} else {
                  						//class variables and function calls are always proceeded with $this->
                                  //from inside their own class.
                                $this->error = __FILE__ . " on line " . __LINE__  . "Could not query: " . mysql_error();
                                  //we cannot return 0 because their might not be any rows in which case this 
                                  //would return 0 on a success. 
                  								return -1;
                  						} //end if						
                  				}//end query
                  

                    corrected

                    What about free_result:

                            function free_result($resource) {
                    								 // this will free all memory associated with the result identifier resource 				
                    					if(!mysql_free_result()) {
                    					 //we set our internal error code and return failure instead of dying 
                    					 			$this->error = __FILE__ . " on line " . __LINE__ . "Could not free result: " . mysql_error();  
                    return 0; } end if //then we return success return 1; }//end free_result
                              function free_result($resource) {
                      								 // this will free all memory associated with the result identifier resource 				
                      					if(!mysql_free_result()) {
                      					 //we set our internal error code and return failure instead of dying 
                      					 			$this->error = __FILE__ . " on line " . __LINE__ . "Could not free result: " . mysql_error();  
                      return 0; } end if //then we return success return 1; }//end free_result

                        mysql_free_result requires a parameter, namely $resource

                        so mysql_free_result() should be mysql_free_result($resource)

                          I thought I did not have to enter ($resource) ?
                          At least that's what I got from the PHP book under mysql_free_result

                          Ok, Here is the dbaccess.php, let me know if it looks ok.

                            There are four parse errors in this file. Luckily Parse errors are easy to find. Just upload the script to your web-space and then browse to it with your browser. The parse errors should show up in your browser window with the line number.

                            When you see this

                            dbAccess requires that we include globals.php in /home/drawmack/public_html/budget/classes/dbAccess.php on line 8

                            you have gotten all the parse errors taken care of and it is time for the next step - a thorough test of this class. I'll explain how we do that when you're ready.

                              you didn't code result

                              oh and I looked it up you don't technically need to supply a resource to mysql_free_result, however if you do not it will free them all. This could be a lot of headaches in the long run.

                                It says parse error line 35.
                                I don't see any problems with line 35 !?!?!

                                Line 35 is

                                } end if

                                I had to replace that line with

                                } end;

                                to make the error go away.

                                Also it, after fixing the above, says parse error on line 54. Line 54 is

                                if($retVal = mysql_query($sql) {

                                edit found this error to be a ) after ($sql)

                                I cannot seem to be able to fix this error.

                                What do you mean i did not code result? OH ok, I fergot that one. Let's fix theses parse errors first!

                                Ok.... now it givin me the famous

                                dbAccess requires that we include globals.php in /home/electric/public_html/npereira/budget/classes/dbAccess.php on line 8

                                Please review the parse errors I corrected. Something is not right but I cannot put my finguer on what it is !