take a look at dbAccess.php I created a shell only. I did one of the functions as an example but the rest are just stubs

function query($sql) {}//end query

you need to write the functions that go into the stubs. I did this as an example of how to structure and set up a class file.

    I don't know how ! What do I put in?

      Is this what you mean and is this the right syntax?

              function open($link) {
      		$link = mysql_connect("localhost", "mysql_user", "mysql_password")
      	        or die("Could not connect: " . mysql_error());
      
      			}//end open
      
          function close($link) {
      	mysql_close($link);
      			}//end close
      
          function query($sql) {
      	$sql = mysql_query("SELECT my_col FROM my_tbl")
      or die("Invalid query: " . mysql_error());
      			}//end query
      

        you can edit the php files right in html-kit that's one of the big reasons I use it it recognizes php, perl, css, javascript, html, asp and some others.

        What you want to do is open dbAcess.php in html-kit then you want to write the code for the dirrefent functions that are currently just stubs in the file

                function open() {}//end open
                function close() {}//end close
                function query($sql) {}//end query
                function free_result($resource) {}//end free_result

        I already coded num_rows so you can use that for an example. The function you posted above is a correct function but it's not one of them from the dbAccess.php file.

        If you want to attempt one and post it here to see if you're doing it right try coding open(). BTW: this should implement two commands and set up the program so that a quers will work you need to use mysql_connect and mysql_select_db for this
        here are the manual pages on these functions
        http://us2.php.net/mysql_connect
        http://us2.php.net/mysql_select_db

          I'm going blind here !

                  function open($link) {
          					if($retVal = mysql_connect (("localhost", "mysql_user", "mysql_password")
                  		or die("Could not connect: " . mysql_error());
          				mysql_close($link);
          
          				else if($retVal = mysql_select_db("your database") 
          					or die(mysql_error());
          				}//end open
          

            Originally posted by npereira

                    function open($link) {
            					if($retVal = mysql_connect (("localhost", "mysql_user", "mysql_password")
                    		or die("Could not connect: " . mysql_error());
            				mysql_close($link);
            
            				else if($retVal = mysql_select_db("your database") 
            					or die(mysql_error());
            				}//end open
            

            Okay there are a couple of problems here's the corrrected code:

            function open() {
                //you want to use your globals here
                if(!mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)) {
                    //we set our internal error code and return failure instead of dying
                    $this->error = __FILE__ . " on line " . __LINE__ . "Could not connect: " . mysql_error();
                     return 0;
                } elseif (!mysql_select_db(DB_NAME)) {
                    $this->error = __FILE__ . " on line " . __LINE__ . "Could not select database: " . mysql_error();
                     return 0;
                 } end if
                 //then we return success
                 return 1;
            }//end open
            

            NOTE: I coded this into the message board so there might be syntax errors or what not.

            Also note that I am using a gloabal that's not in globals.php so it would probably be a good idea to add that now DB_HOST.

              OK I added the DB_HOST in the includes/globals.php

              Corrected the function open ($link)

              So what about function clode ()?

              Is this correct syntax?

                      function close($link) {
              						// 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 connect: " . mysql_error(); 
              										return 0;
              								} end if
              								//then we return success
              										return 1; 
              			 	}//end close
              
              

                almost

                close has no paramters so your first line should read
                function close();

                also change the error message, we're not trying to connect to the database, we're trying to close the database.

                  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