Unable to connect to the database server at this time."; Error_exit($Got_an_error); } // Select the Linux database if (! @mysql_select_db($database_name)) { $Got_an_error = "Convert Microsoft to LINUX: Intro to MySQL
This is an example of using MySQL. Using the built in Control Panel on my Linux host with the PHP Admin utility, I created a simple Database containing an abbreviated list of Linux Distros with a little info about each. The database consisted of an info text field of 400 characters and a Linux_name field of 30 characters, which functioned as the primary key. This excellent MySQL Tutorial was used to write the php code.
For a list of all the commands in mysql please go to my commands page.
Abbreviated List of Linux Distros (Distributions)
Here are all the Distros in our Database
Error performing query: " . mysql_error() . ""; Error_exit($Got_an_error); } // Display the text of each database row in a paragraph while ( $row = mysql_fetch_array($result) ) { print "$row[Name_linux] "; print " " ; print " Website: "; print " " ; print "$row[Website_linux] "; print "// Linux_website = $Linux_website$row[Text_linux]
"; } // Done, please close the database! // and free up the memory too. mysql_free_result($result); mysql_close(); ?>
// Linux_text = $Linux_text
"; // pass on to Database if valid $result = Checkqueryinput($Linux_name, $Linux_website, $Linux_text); // process the data If ($result != "1") { $Got_an_error = "
There was an error in the values you input on the form,. please try again! Click on the Refresh Link below.
"; Error_exit($Got_an_error); } ConnectandOpenDb($hostname, $database_name, $username, $password); $query = " INSERT INTO $database_name.$table_name VALUES ( '$Linux_name', '$Linux_website', '$Linux_text')"; $InsertResult = PerformDBAction($query); If ($InsertResult != "1") { $Got_an_error = "
You can not insert a duplicate record,. please try again! Click on Refresh Link below.
"; Error_exit($Got_an_error); } // Done, please close the database! // // print "This is InsertResult = <$InsertResult>
"; mysql_close(); } // end else for getting Input data from Form. ?> Refresh this page. Refresh this page.If you do not see your favorite Distro, you can add it in here with this form. Please include the website and a short explanation of the distro. Note, I am doing some checking so the spiders out there do not put junk in this database.
Unable to locate the Distro database at this time.
" ; Error_exit($Got_an_error); } } function PerformDBaction($query) // Note , $DBActionResult is returned from this function // It takes the query, does it and returns the value // "1" if successfully inserted. { // input is query to perform // output is $DBActionResult. // print "this is the query <$query> \n"; $DBActionResult = @mysql_query($query); // print " \n this is the DBActionResult = <$DBActionResult> \n"; if ($DBActionResult != "1") { echo("Error performing INSERT query:
" . mysql_error() .
"